From a83c24f33622b86c3cb2a53f959a042d67ab7258 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 25 Dec 2002 23:27:03 -0800 Subject: [FB] Fix minor typos wrt readq/writeq support on 64-bit targets. --- include/linux/fb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/linux') diff --git a/include/linux/fb.h b/include/linux/fb.h index 23dd4c02ddec..188da2f94589 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -424,9 +424,11 @@ struct fb_info { #define fb_readb __raw_readb #define fb_readw __raw_readw #define fb_readl __raw_readl +#define fb_readq __raw_readq #define fb_writeb __raw_writeb #define fb_writew __raw_writew #define fb_writel __raw_writel +#define fb_writeq __raw_writeq #define fb_memset memset_io #else -- cgit v1.2.3 From 61426cf2ce361f3b06fbe855f5cc56df2e24edd2 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 26 Dec 2002 17:39:46 -0800 Subject: [PATCH] usbcore dma updates (and doc) Attached is a patch leveraging some of the new generic dma stuff: - Replaces dma mapping calls in usbcore with generic equivalents. This is a minor code shrink (which we'd hoped could happen). - Pass dma mask along, so net drivers can notice it'd be good to set NETIF_F_HIGHDMA; or scsi ones can set highmem_io. (Some Intel EHCI setups are able to support this kind of DMA.) - Updates one net driver (usbnet) to set NETIF_F_HIGHDMA when appropriate, mostly as an example (since I can't test this). - Provides Documentation/usb/dma.txt, describing current APIs. (Unchanged by this patch, except dma mask visibility.) - Converted another info() to dev_info(), and likewise a couple dbg() to dev_dbg() conversions in the modified routine. The number of FIXMEs was conserved: the generic API doesn't yet fix the error reporting bugs in the PCI-specific mapping API. --- Documentation/usb/dma.txt | 104 ++++++++++++++++++++++++++++++++++++++++ drivers/usb/core/buffer.c | 100 ++------------------------------------- drivers/usb/core/hcd-pci.c | 3 +- drivers/usb/core/hcd.c | 20 +++----- drivers/usb/core/hcd.h | 37 --------------- drivers/usb/core/usb.c | 105 +++++++++++++++++------------------------ drivers/usb/host/ehci-hcd.c | 7 +-- drivers/usb/host/ohci-sa1111.c | 3 +- drivers/usb/net/usbnet.c | 11 ++++- include/linux/usb.h | 16 +++---- 10 files changed, 184 insertions(+), 222 deletions(-) create mode 100644 Documentation/usb/dma.txt (limited to 'include/linux') diff --git a/Documentation/usb/dma.txt b/Documentation/usb/dma.txt new file mode 100644 index 000000000000..fae537186570 --- /dev/null +++ b/Documentation/usb/dma.txt @@ -0,0 +1,104 @@ +In Linux 2.5 kernels (and later), USB device drivers have additional control +over how DMA may be used to perform I/O operations. The APIs are detailed +in the kernel usb programming guide (kerneldoc, from the source code). + + +API OVERVIEW + +The big picture is that USB drivers can continue to ignore most DMA issues, +though they still must provide DMA-ready buffers (see DMA-mapping.txt). +That's how they've worked through the 2.4 (and earlier) kernels. + +OR: they can now be DMA-aware. + +- New calls enable DMA-aware drivers, letting them allocate dma buffers and + manage dma mappings for existing dma-ready buffers (see below). + +- URBs have an additional "transfer_dma" field, as well as a transfer_flags + bit saying if it's valid. (Control requests also needed "setup_dma".) + +- "usbcore" will map those DMA addresses, if a DMA-aware driver didn't do it + first and set URB_NO_DMA_MAP. HCDs don't manage dma mappings for urbs. + +- There's a new "generic DMA API", parts of which are usable by USB device + drivers. Never use dma_set_mask() on any USB interface or device; that + would potentially break all devices sharing that bus. + + +ELIMINATING COPIES + +It's good to avoid making CPUs copy data needlessly. The costs can add up, +and effects like cache-trashing can impose subtle penalties. + +- When you're allocating a buffer for DMA purposes anyway, use the buffer + primitives. Think of them as kmalloc and kfree that give you the right + kind of addresses to store in urb->transfer_buffer and urb->transfer_dma, + while guaranteeing that hidden copies through DMA "bounce" buffers won't + slow things down. You'd also set URB_NO_DMA_MAP in urb->transfer_flags: + + void *usb_buffer_alloc (struct usb_device *dev, size_t size, + int mem_flags, dma_addr_t *dma); + + void usb_buffer_free (struct usb_device *dev, size_t size, + void *addr, dma_addr_t dma); + + The memory buffer returned is "dma-coherent"; sometimes you might need to + force a consistent memory access ordering by using memory barriers. It's + not using a streaming DMA mapping, so it's good for small transfers on + systems where the I/O would otherwise tie up an IOMMU mapping. + + Asking for 1/Nth of a page (as well as asking for N pages) is reasonably + space-efficient. + +- Devices on some EHCI controllers could handle DMA to/from high memory. + Driver probe() routines can notice this using a generic DMA call, then + tell higher level code (network, scsi, etc) about it like this: + + if (dma_supported (&intf->dev, 0xffffffffffffffffULL)) + net->features |= NETIF_F_HIGHDMA; + + That can eliminate dma bounce buffering of requests that originate (or + terminate) in high memory, in cases where the buffers aren't allocated + with usb_buffer_alloc() but instead are dma-mapped. + + +WORKING WITH EXISTING BUFFERS + +Existing buffers aren't usable for DMA without first being mapped into the +DMA address space of the device. + +- When you're using scatterlists, you can map everything at once. On some + systems, this kicks in an IOMMU and turns the scatterlists into single + DMA transactions: + + int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, + struct scatterlist *sg, int nents); + + void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, + struct scatterlist *sg, int n_hw_ents); + + void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, + struct scatterlist *sg, int n_hw_ents); + + It's probably easier to use the new usb_sg_*() calls, which do the DMA + mapping and apply other tweaks to make scatterlist i/o be fast. + +- Some drivers may prefer to work with the model that they're mapping large + buffers, synchronizing their safe re-use. (If there's no re-use, then let + usbcore do the map/unmap.) Large periodic transfers make good examples + here, since it's cheaper to just synchronize the buffer than to unmap it + each time an urb completes and then re-map it on during resubmission. + + These calls all work with initialized urbs: urb->dev, urb->pipe, + urb->transfer_buffer, and urb->transfer_buffer_length must all be + valid when these calls are used: + + struct urb *usb_buffer_map (struct urb *urb); + + void usb_buffer_dmasync (struct urb *urb); + + void usb_buffer_unmap (struct urb *urb); + + The calls manage urb->transfer_dma for you, and set URB_NO_DMA_MAP so that + usbcore won't map or unmap the buffer. + diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 4f4211af98b6..6e4392596750 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -24,11 +24,14 @@ /* - * DMA-Consistent Buffers + * DMA-Coherent Buffers */ /* FIXME tune these based on pool statistics ... */ static const size_t pool_max [HCD_BUFFER_POOLS] = { + /* platforms without dma-friendly caches might need to + * prevent cacheline sharing... + */ 32, 128, 512, @@ -133,98 +136,3 @@ void hcd_buffer_free ( } pci_free_consistent (hcd->pdev, size, addr, dma); } - - -/* - * DMA-Mappings for arbitrary memory buffers - */ - -int hcd_buffer_map ( - struct usb_bus *bus, - void *addr, - dma_addr_t *dma, - size_t size, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - // FIXME pci_map_single() has no standard failure mode! - *dma = pci_map_single (hcd->pdev, addr, size, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); - return 0; -} - -void hcd_buffer_dmasync ( - struct usb_bus *bus, - dma_addr_t dma, - size_t size, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_dma_sync_single (hcd->pdev, dma, size, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} - -void hcd_buffer_unmap ( - struct usb_bus *bus, - dma_addr_t dma, - size_t size, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_unmap_single (hcd->pdev, dma, size, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} - -int hcd_buffer_map_sg ( - struct usb_bus *bus, - struct scatterlist *sg, - int *n_hw_ents, - int nents, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - // FIXME pci_map_sg() has no standard failure mode! - *n_hw_ents = pci_map_sg(hcd->pdev, sg, nents, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); - return 0; -} - -void hcd_buffer_sync_sg ( - struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_dma_sync_sg(hcd->pdev, sg, n_hw_ents, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} - -void hcd_buffer_unmap_sg ( - struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, - int direction -) { - struct usb_hcd *hcd = bus->hcpriv; - - pci_unmap_sg(hcd->pdev, sg, n_hw_ents, - (direction == USB_DIR_IN) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); -} diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index e66aaac9fa78..9ca856cd6a42 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -138,7 +138,8 @@ clean_2: hcd->pdev = dev; hcd->self.bus_name = dev->slot_name; hcd->product_desc = dev->dev.name; - hcd->controller = &dev->dev; + hcd->self.controller = &dev->dev; + hcd->controller = hcd->self.controller; if ((retval = hcd_buffer_create (hcd)) != 0) { clean_3: diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 74a3993826fd..624beac700b4 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1031,19 +1031,19 @@ static int hcd_submit_urb (struct urb *urb, int mem_flags) /* lower level hcd code should use *_dma exclusively */ if (!(urb->transfer_flags & URB_NO_DMA_MAP)) { if (usb_pipecontrol (urb->pipe)) - urb->setup_dma = pci_map_single ( - hcd->pdev, + urb->setup_dma = dma_map_single ( + hcd->controller, urb->setup_packet, sizeof (struct usb_ctrlrequest), - PCI_DMA_TODEVICE); + DMA_TO_DEVICE); if (urb->transfer_buffer_length != 0) - urb->transfer_dma = pci_map_single ( - hcd->pdev, + urb->transfer_dma = dma_map_single ( + hcd->controller, urb->transfer_buffer, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? PCI_DMA_FROMDEVICE - : PCI_DMA_TODEVICE); + ? DMA_FROM_DEVICE + : DMA_TO_DEVICE); } status = hcd->driver->urb_enqueue (hcd, urb, mem_flags); @@ -1265,12 +1265,6 @@ struct usb_operations usb_hcd_operations = { .deallocate = hcd_free_dev, .buffer_alloc = hcd_buffer_alloc, .buffer_free = hcd_buffer_free, - .buffer_map = hcd_buffer_map, - .buffer_dmasync = hcd_buffer_dmasync, - .buffer_unmap = hcd_buffer_unmap, - .buffer_map_sg = hcd_buffer_map_sg, - .buffer_dmasync_sg = hcd_buffer_sync_sg, - .buffer_unmap_sg = hcd_buffer_unmap_sg, }; EXPORT_SYMBOL (usb_hcd_operations); diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index 0db63cf30e7a..99cb0f4b2c84 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -145,26 +145,6 @@ struct usb_operations { dma_addr_t *dma); void (*buffer_free)(struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma); - - int (*buffer_map) (struct usb_bus *bus, - void *addr, dma_addr_t *dma, - size_t size, int direction); - void (*buffer_dmasync) (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); - void (*buffer_unmap) (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); - - int (*buffer_map_sg) (struct usb_bus *bus, - struct scatterlist *sg, int *n_hw_ents, - int nents, int direction); - void (*buffer_dmasync_sg) (struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, int direction); - void (*buffer_unmap_sg) (struct usb_bus *bus, - struct scatterlist *sg, - int n_hw_ents, int direction); }; /* each driver provides one of these, and hardware init support */ @@ -248,23 +228,6 @@ void *hcd_buffer_alloc (struct usb_bus *bus, size_t size, void hcd_buffer_free (struct usb_bus *bus, size_t size, void *addr, dma_addr_t dma); -int hcd_buffer_map (struct usb_bus *bus, - void *addr, dma_addr_t *dma, - size_t size, int direction); -void hcd_buffer_dmasync (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); -void hcd_buffer_unmap (struct usb_bus *bus, - dma_addr_t dma, - size_t size, int direction); -int hcd_buffer_map_sg (struct usb_bus *bus, struct scatterlist *sg, - int *n_hw_ents, int nents, int direction); -void hcd_buffer_sync_sg (struct usb_bus *bus, struct scatterlist *sg, - int n_hw_ents, int direction); - -void hcd_buffer_unmap_sg (struct usb_bus *bus, struct scatterlist *sg, - int n_hw_ents, int direction); - /* generic bus glue, needed for host controllers that don't use PCI */ extern struct usb_operations usb_hcd_operations; extern void usb_hcd_irq (int irq, void *__hcd, struct pt_regs *r); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 1325fc9b8a09..df15296da8a6 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -41,6 +41,11 @@ #endif #include +#include +#include +#include +#include + #include "hcd.h" #include "usb.h" @@ -803,7 +808,7 @@ void usb_disconnect(struct usb_device **pdev) *pdev = NULL; - info("USB disconnect on device %d", dev->devnum); + dev_info (dev->dev, "USB disconnect, address %d\n", dev->devnum); /* Free up all the children before we remove this device */ for (i = 0; i < USB_MAXCHILDREN; i++) { @@ -812,7 +817,7 @@ void usb_disconnect(struct usb_device **pdev) usb_disconnect(child); } - dbg ("unregistering interfaces on device %d", dev->devnum); + dev_dbg (dev->dev, "unregistering interfaces\n"); if (dev->actconfig) { for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface = &dev->actconfig->interface[i]; @@ -822,7 +827,7 @@ void usb_disconnect(struct usb_device **pdev) } } - dbg ("unregistering the device %d", dev->devnum); + dev_dbg (dev->dev, "unregistering device\n"); /* Free the device number and remove the /proc/bus/usb entry */ if (dev->devnum > 0) { clear_bit(dev->devnum, dev->bus->devmap.devicemap); @@ -980,6 +985,9 @@ int usb_new_device(struct usb_device *dev, struct device *parent) sprintf (&dev->dev.bus_id[0], "%d-%s", dev->bus->busnum, dev->devpath); + /* dma masks come from the controller; readonly, except to hcd */ + dev->dev.dma_mask = parent->dma_mask; + /* USB device state == default ... it's not usable yet */ /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... @@ -1104,6 +1112,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) interface->dev.parent = &dev->dev; interface->dev.driver = NULL; interface->dev.bus = &usb_bus_type; + interface->dev.dma_mask = parent->dma_mask; sprintf (&interface->dev.bus_id[0], "%d-%s:%d", dev->bus->busnum, dev->devpath, desc->bInterfaceNumber); @@ -1206,24 +1215,21 @@ void usb_buffer_free ( struct urb *usb_buffer_map (struct urb *urb) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!urb || usb_pipecontrol (urb->pipe) || !urb->dev || !(bus = urb->dev->bus) - || !(op = bus->op) - || !op->buffer_map) + || !(controller = bus->controller)) return 0; - if (op->buffer_map (bus, - urb->transfer_buffer, - &urb->transfer_dma, - urb->transfer_buffer_length, + urb->transfer_dma = dma_map_single (controller, + urb->transfer_buffer, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? USB_DIR_IN - : USB_DIR_OUT)) - return 0; + ? DMA_FROM_DEVICE : DMA_TO_DEVICE); + // FIXME generic api broken like pci, can't report errors + // if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; urb->transfer_flags |= URB_NO_DMA_MAP; return urb; } @@ -1235,22 +1241,19 @@ struct urb *usb_buffer_map (struct urb *urb) void usb_buffer_dmasync (struct urb *urb) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!urb || !(urb->transfer_flags & URB_NO_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) - || !(op = bus->op) - || !op->buffer_dmasync) + || !(controller = bus->controller)) return; - op->buffer_dmasync (bus, - urb->transfer_dma, - urb->transfer_buffer_length, + dma_sync_single (controller, + urb->transfer_dma, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } /** @@ -1262,23 +1265,21 @@ void usb_buffer_dmasync (struct urb *urb) void usb_buffer_unmap (struct urb *urb) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!urb || !(urb->transfer_flags & URB_NO_DMA_MAP) || !urb->dev || !(bus = urb->dev->bus) - || !(op = bus->op) - || !op->buffer_unmap) + || !(controller = bus->controller)) return; - op->buffer_unmap (bus, - urb->transfer_dma, - urb->transfer_buffer_length, + dma_unmap_single (controller, + urb->transfer_dma, urb->transfer_buffer_length, usb_pipein (urb->pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } + /** * usb_buffer_map_sg - create scatterlist DMA mapping(s) for an endpoint * @dev: device to which the scatterlist will be mapped @@ -1297,6 +1298,7 @@ void usb_buffer_unmap (struct urb *urb) * to complete before starting the next I/O. This is particularly easy * to do with scatterlists. Just allocate and submit one URB for each DMA * mapping entry returned, stopping on the first error or when all succeed. + * Better yet, use the usb_sg_*() calls, which do that (and more) for you. * * This call would normally be used when translating scatterlist requests, * rather than usb_buffer_map(), since on some hardware (with IOMMUs) it @@ -1308,26 +1310,17 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int nents) { struct usb_bus *bus; - struct usb_operations *op; - int n_hw_ents; + struct device *controller; if (!dev || usb_pipecontrol (pipe) || !(bus = dev->bus) - || !(op = bus->op) - || !op->buffer_map_sg) - return -1; - - if (op->buffer_map_sg (bus, - sg, - &n_hw_ents, - nents, - usb_pipein (pipe) - ? USB_DIR_IN - : USB_DIR_OUT)) + || !(controller = bus->controller)) return -1; - return n_hw_ents; + // FIXME generic api broken like pci, can't report errors + return dma_map_sg (controller, sg, nents, + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } /** @@ -1344,20 +1337,15 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int n_hw_ents) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!dev || !(bus = dev->bus) - || !(op = bus->op) - || !op->buffer_dmasync_sg) + || !(controller = bus->controller)) return; - op->buffer_dmasync_sg (bus, - sg, - n_hw_ents, - usb_pipein (pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + dma_sync_sg (controller, sg, n_hw_ents, + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } /** @@ -1373,20 +1361,15 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, struct scatterlist *sg, int n_hw_ents) { struct usb_bus *bus; - struct usb_operations *op; + struct device *controller; if (!dev || !(bus = dev->bus) - || !(op = bus->op) - || !op->buffer_unmap_sg) + || !(controller = bus->controller)) return; - op->buffer_unmap_sg (bus, - sg, - n_hw_ents, - usb_pipein (pipe) - ? USB_DIR_IN - : USB_DIR_OUT); + dma_unmap_sg (controller, sg, n_hw_ents, + usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 48d9b806fcb2..239e398861df 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -405,9 +405,10 @@ static int ehci_start (struct usb_hcd *hcd) * streaming mappings for I/O buffers, like pci_map_single(), * can return segments above 4GB, if the device allows. * - * NOTE: layered drivers can't yet tell when we enable that, - * so they can't pass this info along (like NETIF_F_HIGHDMA) - * (or like Scsi_Host.highmem_io) ... usb_bus.flags? + * NOTE: the dma mask is visible through dma_supported(), so + * drivers can pass this info along ... like NETIF_F_HIGHDMA, + * Scsi_Host.highmem_io, and so forth. It's readonly to all + * host side drivers though. */ if (HCC_64BIT_ADDR (hcc_params)) { writel (0, &ehci->regs->segment); diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index d03fce1c7da5..11d4fed34233 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c @@ -176,7 +176,8 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, hcd->irq = dev->irq[1]; hcd->regs = dev->mapbase; hcd->pdev = SA1111_FAKE_PCIDEV; - hcd->controller = &dev->dev; + hcd->self.controller = &dev->dev; + hcd->controller = hcd->self.controller; retval = hcd_buffer_create (hcd); if (retval != 0) { diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c index 17eb48408556..bf8ca2f5daf3 100644 --- a/drivers/usb/net/usbnet.c +++ b/drivers/usb/net/usbnet.c @@ -146,6 +146,11 @@ #endif #include +#include +#include +#include +#include + /* minidrivers _could_ be individually configured */ #define CONFIG_USB_AN2720 @@ -2169,9 +2174,13 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) memcpy (net->dev_addr, node_id, sizeof node_id); // point-to-point link ... we always use Ethernet headers - // supports win32 interop and the bridge driver. + // supports win32 interop (some devices) and the bridge driver. ether_setup (net); + // possible with some EHCI controllers + if (dma_supported (&udev->dev, 0xffffffffffffffffULL)) + net->features |= NETIF_F_HIGHDMA; + net->change_mtu = usbnet_change_mtu; net->get_stats = usbnet_get_stats; net->hard_start_xmit = usbnet_start_xmit; diff --git a/include/linux/usb.h b/include/linux/usb.h index 88557d5957a7..b1d92b8c585f 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -28,14 +28,6 @@ static __inline__ void wait_ms(unsigned int ms) mdelay(ms); } -/* - * USB device number allocation bitmap. There's one bitmap - * per USB tree. - */ -struct usb_devmap { - unsigned long devicemap[128 / (8*sizeof(unsigned long))]; -}; - struct usb_device; /*-------------------------------------------------------------------------*/ @@ -159,10 +151,16 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size, struct usb_operations; +/* USB device number allocation bitmap */ +struct usb_devmap { + unsigned long devicemap[128 / (8*sizeof(unsigned long))]; +}; + /* - * Allocated per bus we have + * Allocated per bus (tree of devices) we have: */ struct usb_bus { + struct device *controller; /* host/master side hardware */ int busnum; /* Bus number (in order of reg) */ char *bus_name; /* stable id (PCI slot_name etc) */ -- cgit v1.2.3 From 9e314023895e31d1decb8e55505bcb852eb7507b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 26 Dec 2002 19:33:42 -0800 Subject: [PATCH] USB: remove private_data pointer from struct usb_interface, as it shouldn't be used anymore Also added usb_get_intfdata() and usb_set_intfdata() functions to set the struct usb_interface private pointer easier. --- drivers/usb/core/usb.c | 4 ++-- drivers/usb/misc/usbtest.c | 1 - include/linux/usb.h | 11 ++++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index df15296da8a6..134a79120215 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -298,7 +298,7 @@ void usb_driver_claim_interface(struct usb_driver *driver, struct usb_interface dbg("%s driver claimed interface %p", driver->name, iface); iface->driver = driver; - iface->private_data = priv; + usb_set_intfdata(iface, priv); } /** @@ -341,7 +341,7 @@ void usb_driver_release_interface(struct usb_driver *driver, struct usb_interfac return; iface->driver = NULL; - iface->private_data = NULL; + usb_set_intfdata(iface, NULL); } /** diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 7d6ee5ba3e86..222f066e63f9 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -978,7 +978,6 @@ static void usbtest_disconnect (struct usb_interface *intf) dev_set_drvdata (&intf->dev, 0); info ("unbound %s", dev->id); - kfree (intf->private_data); } /* Basic testing only needs a device that can source or sink bulk traffic. diff --git a/include/linux/usb.h b/include/linux/usb.h index b1d92b8c585f..e0d1269dc779 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -111,12 +111,21 @@ struct usb_interface { struct usb_driver *driver; /* driver */ kdev_t kdev; /* node this interface is bound to */ struct device dev; /* interface specific device info */ - void *private_data; }; #define to_usb_interface(d) container_of(d, struct usb_interface, dev) #define interface_to_usbdev(intf) \ container_of(intf->dev.parent, struct usb_device, dev) +static inline void *usb_get_intfdata (struct usb_interface *intf) +{ + return dev_get_drvdata (&intf->dev); +} + +static inline void usb_set_intfdata (struct usb_interface *intf, void *data) +{ + return dev_set_drvdata (&intf->dev, data); +} + /* USB_DT_CONFIG: Configuration descriptor information. * * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the -- cgit v1.2.3 From acdc277a1ab96e584127f465c9323d0ae8a3f47a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 26 Dec 2002 23:04:08 -0800 Subject: [FB] fb_blank is an fbops hook, not a standalone function. --- drivers/video/console/fbcon.c | 2 +- include/linux/fb.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'include/linux') diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 6b3bc39bc559..6933d2d3d39c 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -1993,7 +1993,7 @@ static int fbcon_blank(struct vc_data *vc, int blank) update_screen(vc->vc_num); return 0; } else - return fb_blank(blank, info); + return info->fbops->fb_blank(blank, info); } static void fbcon_free_font(struct display *p) diff --git a/include/linux/fb.h b/include/linux/fb.h index 188da2f94589..1edbaf1b14be 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -449,7 +449,6 @@ struct fb_info { extern int fb_set_var(struct fb_var_screeninfo *var, struct fb_info *info); extern int fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); -extern int fb_blank(int blank, struct fb_info *info); extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); extern void cfb_fillrect(struct fb_info *info, struct fb_fillrect *rect); extern void cfb_copyarea(struct fb_info *info, struct fb_copyarea *area); -- cgit v1.2.3 From 6c56ca7bd3310403f595c5329e3b468acc0639fd Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Fri, 27 Dec 2002 00:15:49 -0800 Subject: Cset exclude: rth@are.twiddle.net|ChangeSet|20021227230408|33498 --- drivers/video/console/fbcon.c | 2 +- include/linux/fb.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 6933d2d3d39c..6b3bc39bc559 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -1993,7 +1993,7 @@ static int fbcon_blank(struct vc_data *vc, int blank) update_screen(vc->vc_num); return 0; } else - return info->fbops->fb_blank(blank, info); + return fb_blank(blank, info); } static void fbcon_free_font(struct display *p) diff --git a/include/linux/fb.h b/include/linux/fb.h index 1edbaf1b14be..188da2f94589 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -449,6 +449,7 @@ struct fb_info { extern int fb_set_var(struct fb_var_screeninfo *var, struct fb_info *info); extern int fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); +extern int fb_blank(int blank, struct fb_info *info); extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor); extern void cfb_fillrect(struct fb_info *info, struct fb_fillrect *rect); extern void cfb_copyarea(struct fb_info *info, struct fb_copyarea *area); -- cgit v1.2.3 From d92e1bbd4a82f39cfaf7b0dd7d9d5e4f5d2907ee Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 27 Dec 2002 03:29:40 -0800 Subject: [PATCH] USB: rename usb_free_dev() to usb_put_dev() This was done to make the next reference count patch easier, and because almost everyone was already calling usb_put_dev() anyway... --- drivers/usb/core/hub.c | 4 ++-- drivers/usb/core/usb.c | 7 +++---- drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/host/hc_sl811_rh.c | 2 +- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/uhci-hcd.c | 2 +- include/linux/usb.h | 3 +-- 7 files changed, 10 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index e48f6d646bf8..d013ec009f87 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -876,7 +876,7 @@ static void usb_hub_port_connect_change(struct usb_hub *hubstate, int port, /* Reset the device, and detect its speed */ if (usb_hub_port_reset(hub, port, dev, delay)) { - usb_free_dev(dev); + usb_put_dev(dev); break; } @@ -928,7 +928,7 @@ static void usb_hub_port_connect_change(struct usb_hub *hubstate, int port, goto done; /* Free the configuration if there was an error */ - usb_free_dev(dev); + usb_put_dev(dev); /* Switch to a long reset time */ delay = HUB_LONG_RESET_TIME; diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 134a79120215..815a2e2ee8ad 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -716,7 +716,7 @@ struct usb_device *usb_get_dev (struct usb_device *dev) } /** - * usb_free_dev - free a usb device structure when all users of it are finished. + * usb_put_dev - free a usb device structure when all users of it are finished. * @dev: device that's been disconnected * Context: !in_interrupt () * @@ -727,7 +727,7 @@ struct usb_device *usb_get_dev (struct usb_device *dev) * gone, everything is cleaned up, so it's time to get rid of these last * records of this device. */ -void usb_free_dev(struct usb_device *dev) +void usb_put_dev(struct usb_device *dev) { if (atomic_dec_and_test(&dev->refcnt)) { if (dev->bus->op->deallocate) @@ -738,7 +738,6 @@ void usb_free_dev(struct usb_device *dev) } } - /** * usb_get_current_frame_number - return current bus frame number * @dev: the device whose bus is being queried @@ -1454,7 +1453,7 @@ EXPORT_SYMBOL(usb_device_probe); EXPORT_SYMBOL(usb_device_remove); EXPORT_SYMBOL(usb_alloc_dev); -EXPORT_SYMBOL(usb_free_dev); +EXPORT_SYMBOL(usb_put_dev); EXPORT_SYMBOL(usb_get_dev); EXPORT_SYMBOL(usb_hub_tt_clear_buffer); diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 239e398861df..3da8c9b228ef 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -476,7 +476,7 @@ done2: ehci_ready (ehci); ehci_reset (ehci); bus->root_hub = 0; - usb_free_dev (udev); + usb_put_dev (udev); retval = -ENODEV; goto done2; } diff --git a/drivers/usb/host/hc_sl811_rh.c b/drivers/usb/host/hc_sl811_rh.c index 786bb4dec196..203a909fdcd5 100644 --- a/drivers/usb/host/hc_sl811_rh.c +++ b/drivers/usb/host/hc_sl811_rh.c @@ -566,7 +566,7 @@ static int rh_connect_rh (hci_t * hci) hci->bus->root_hub = usb_dev; usb_connect (usb_dev); if (usb_new_device (usb_dev) != 0) { - usb_free_dev (usb_dev); + usb_put_dev (usb_dev); return -ENODEV; } diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index af15bea5fa45..17a794b3ce54 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -515,7 +515,7 @@ static int hc_start (struct ohci_hcd *ohci) usb_connect (udev); udev->speed = USB_SPEED_FULL; if (usb_register_root_hub (udev, ohci->hcd.controller) != 0) { - usb_free_dev (udev); + usb_put_dev (udev); ohci->hcd.self.root_hub = NULL; disable (ohci); ohci->hc_control &= ~OHCI_CTRL_HCFS; diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index f258f2b92ccb..3b5768ee1812 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -2280,7 +2280,7 @@ err_alloc_skelqh: uhci->term_td = NULL; err_alloc_term_td: - usb_free_dev(udev); + usb_put_dev(udev); hcd->self.root_hub = NULL; err_alloc_root_hub: diff --git a/include/linux/usb.h b/include/linux/usb.h index e0d1269dc779..c3c2c69ff244 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -261,8 +261,7 @@ struct usb_device { extern struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *); extern struct usb_device *usb_get_dev(struct usb_device *dev); -extern void usb_free_dev(struct usb_device *); -#define usb_put_dev usb_free_dev +extern void usb_put_dev(struct usb_device *dev); /* mostly for devices emulating SCSI over USB */ extern int usb_reset_device(struct usb_device *dev); -- cgit v1.2.3 From b14d209d075901fe9faacbf973c2379025345edd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 27 Dec 2002 07:29:19 -0800 Subject: [PATCH] USB: use the driver model to handle reference counting of struct usb_device --- drivers/usb/core/config.c | 1 + drivers/usb/core/usb.c | 78 ++++++++++++++++++++++++++++++----------------- include/linux/usb.h | 1 - 3 files changed, 51 insertions(+), 29 deletions(-) (limited to 'include/linux') diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 3a3dfdc54e97..69a4e2f83045 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -108,6 +108,7 @@ static int usb_parse_interface(struct usb_interface *interface, unsigned char *b interface->act_altsetting = 0; interface->num_altsetting = 0; interface->max_altsetting = USB_ALTSETTINGALLOC; + device_initialize(&interface->dev); interface->altsetting = kmalloc(sizeof(*interface->altsetting) * interface->max_altsetting, GFP_KERNEL); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 815a2e2ee8ad..6a3c6fe12cb8 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -23,6 +23,13 @@ */ #include + +#ifdef CONFIG_USB_DEBUG + #define DEBUG +#else + #undef DEBUG +#endif + #include #include #include @@ -33,12 +40,6 @@ #include #include #include - -#ifdef CONFIG_USB_DEBUG - #define DEBUG -#else - #undef DEBUG -#endif #include #include @@ -677,13 +678,14 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus) memset(dev, 0, sizeof(*dev)); + device_initialize(&dev->dev); + usb_bus_get(bus); if (!parent) dev->devpath [0] = '0'; dev->bus = bus; dev->parent = parent; - atomic_set(&dev->refcnt, 1); INIT_LIST_HEAD(&dev->filelist); init_MUTEX(&dev->serialize); @@ -695,7 +697,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus) } /** - * usb_get_dev - increments the reference count of the device + * usb_get_dev - increments the reference count of the usb device structure * @dev: the device being referenced * * Each live reference to a device should be refcounted. @@ -708,36 +710,54 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus) */ struct usb_device *usb_get_dev (struct usb_device *dev) { - if (dev) { - atomic_inc (&dev->refcnt); - return dev; - } - return NULL; + struct device *tmp; + + if (!dev) + return NULL; + + tmp = get_device(&dev->dev); + if (tmp) + return to_usb_device(tmp); + else + return NULL; } /** - * usb_put_dev - free a usb device structure when all users of it are finished. + * usb_put_dev - release a use of the usb device structure * @dev: device that's been disconnected - * Context: !in_interrupt () * * Must be called when a user of a device is finished with it. When the last * user of the device calls this function, the memory of the device is freed. - * - * Used by hub and virtual root hub drivers. The device is completely - * gone, everything is cleaned up, so it's time to get rid of these last - * records of this device. */ void usb_put_dev(struct usb_device *dev) { - if (atomic_dec_and_test(&dev->refcnt)) { - if (dev->bus->op->deallocate) - dev->bus->op->deallocate(dev); - usb_destroy_configuration (dev); - usb_bus_put (dev->bus); - kfree (dev); - } + if (dev) + put_device(&dev->dev); +} + +/** + * usb_release_dev - free a usb device structure when all users of it are finished. + * @dev: device that's been disconnected + * + * Will be called only by the device core when all users of this usb device are + * done. + */ +static void usb_release_dev(struct device *dev) +{ + struct usb_device *udev; + + udev = to_usb_device(dev); + if (!udev) + return; + + if (udev->bus && udev->bus->op && udev->bus->op->deallocate) + udev->bus->op->deallocate(udev); + usb_destroy_configuration (udev); + usb_bus_put (udev->bus); + kfree (udev); } + /** * usb_get_current_frame_number - return current bus frame number * @dev: the device whose bus is being queried @@ -980,6 +1000,8 @@ int usb_new_device(struct usb_device *dev, struct device *parent) dev->dev.parent = parent; dev->dev.driver = &usb_generic_driver; dev->dev.bus = &usb_bus_type; + dev->dev.release = usb_release_dev; + usb_get_dev(dev); if (dev->dev.bus_id[0] == 0) sprintf (&dev->dev.bus_id[0], "%d-%s", dev->bus->busnum, dev->devpath); @@ -1096,7 +1118,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) #endif /* put into sysfs, with device and config specific files */ - err = device_register (&dev->dev); + err = device_add (&dev->dev); if (err) return err; usb_create_driverfs_dev_files (dev); @@ -1130,7 +1152,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) desc->bInterfaceNumber); } dbg ("%s - registering %s", __FUNCTION__, interface->dev.bus_id); - device_register (&interface->dev); + device_add (&interface->dev); usb_create_driverfs_intf_files (interface); } diff --git a/include/linux/usb.h b/include/linux/usb.h index c3c2c69ff244..bcbfa72423c3 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -217,7 +217,6 @@ struct usb_device { struct usb_tt *tt; /* low/full speed dev, highspeed hub */ int ttport; /* device port on that tt hub */ - atomic_t refcnt; /* Reference count */ struct semaphore serialize; unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ -- cgit v1.2.3 From 85cabc0ce214a39ce7b5d68e50604333e8562c12 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 27 Dec 2002 19:09:40 -0800 Subject: Get rid of atari-specific "ide_intr_lock" from generic IDE code --- drivers/ide/ide-io.c | 4 ++-- drivers/ide/ide.c | 12 ++---------- include/asm-m68k/ide.h | 14 ++++++++------ include/linux/ide.h | 4 ++-- 4 files changed, 14 insertions(+), 20 deletions(-) (limited to 'include/linux') diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 89e956d8b011..64ee462aaa97 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -743,7 +743,7 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) ide_startstop_t startstop; /* for atari only: POSSIBLY BROKEN HERE(?) */ - ide_get_lock(&ide_intr_lock, ide_intr, hwgroup); + ide_get_lock(ide_intr, hwgroup); /* necessary paranoia: ensure IRQs are masked on local CPU */ local_irq_disable(); @@ -783,7 +783,7 @@ void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq) */ /* for atari only */ - ide_release_lock(&ide_intr_lock); + ide_release_lock(); hwgroup->busy = 0; } diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 9b4130b92ae6..3c07fbefa9bf 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -181,14 +181,6 @@ spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED; static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */ -#ifdef IDE_ARCH_LOCK -/* - * ide_lock is used by the Atari code to obtain access to the IDE interrupt, - * which is shared between several drivers. - */ -static int ide_intr_lock; -#endif /* IDE_ARCH_LOCK */ - #ifdef CONFIG_IDEDMA_AUTO int noautodma = 0; #else @@ -2097,12 +2089,12 @@ void __init ide_init_builtin_drivers (void) #ifdef CONFIG_BLK_DEV_IDE if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) - ide_get_lock(&ide_intr_lock, NULL, NULL); /* for atari only */ + ide_get_lock(NULL, NULL); /* for atari only */ (void) ideprobe_init(); if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) - ide_release_lock(&ide_intr_lock); /* for atari only */ + ide_release_lock(); /* for atari only */ #endif /* CONFIG_BLK_DEV_IDE */ #ifdef CONFIG_PROC_FS diff --git a/include/asm-m68k/ide.h b/include/asm-m68k/ide.h index 1471687982a9..6b451e47441c 100644 --- a/include/asm-m68k/ide.h +++ b/include/asm-m68k/ide.h @@ -147,26 +147,28 @@ static __inline__ void ide_init_default_hwifs(void) #ifdef CONFIG_ATARI #define ATA_ARCH_LOCK -static __inline__ void ide_release_lock (int *ide_lock) +extern int ide_intr_lock; + +static __inline__ void ide_release_lock (void) { if (MACH_IS_ATARI) { - if (*ide_lock == 0) { + if (ide_intr_lock == 0) { printk("ide_release_lock: bug\n"); return; } - *ide_lock = 0; + ide_intr_lock = 0; stdma_release(); } } -static __inline__ void ide_get_lock (int *ide_lock, void (*handler)(int, void *, struct pt_regs *), void *data) +static __inline__ void ide_get_lock(void (*handler)(int, void *, struct pt_regs *), void *data) { if (MACH_IS_ATARI) { - if (*ide_lock == 0) { + if (ide_intr_lock == 0) { if (in_interrupt() > 0) panic( "Falcon IDE hasn't ST-DMA lock in interrupt" ); stdma_lock(handler, data); - *ide_lock = 1; + ide_intr_lock = 1; } } } diff --git a/include/linux/ide.h b/include/linux/ide.h index 033e94a6d6e4..2e2718ebfd98 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -360,8 +360,8 @@ extern int ide_irq_lock; /* Currently only Atari needs it */ #ifndef IDE_ARCH_LOCK -# define ide_release_lock(lock) do {} while (0) -# define ide_get_lock(lock, hdlr, data) do {} while (0) +# define ide_release_lock() do {} while (0) +# define ide_get_lock(hdlr, data) do {} while (0) #endif /* IDE_ARCH_LOCK */ /* -- cgit v1.2.3 From 33dfd4fe2bf28981189797be51961fe315d6651b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 27 Dec 2002 19:15:20 -0800 Subject: [PATCH] Mac/m68k Nubus updates Mac/m68k Nubus updates (from Ray Knight in 2.4.x) - Add missing Nubus devices. --- include/linux/nubus.h | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'include/linux') diff --git a/include/linux/nubus.h b/include/linux/nubus.h index a3fd37b33fdd..870e66a96286 100644 --- a/include/linux/nubus.h +++ b/include/linux/nubus.h @@ -28,18 +28,18 @@ enum nubus_category { }; enum nubus_type_network { - NUBUS_TYPE_ETHERNET = 0x0001, - NUBUS_TYPE_RS232 = 0x0002 + NUBUS_TYPE_ETHERNET = 0x0001, + NUBUS_TYPE_RS232 = 0x0002 }; enum nubus_type_display { - NUBUS_TYPE_VIDEO = 0x0001 + NUBUS_TYPE_VIDEO = 0x0001 }; enum nubus_type_cpu { - NUBUS_TYPE_68020 = 0x0003, - NUBUS_TYPE_68030 = 0x0004, - NUBUS_TYPE_68040 = 0x0005 + NUBUS_TYPE_68020 = 0x0003, + NUBUS_TYPE_68030 = 0x0004, + NUBUS_TYPE_68040 = 0x0005 }; /* Known tuples: (according to TattleTech and Slots) @@ -80,22 +80,24 @@ enum nubus_type_cpu { /* Add known DrSW values here */ enum nubus_drsw { /* NUBUS_CAT_DISPLAY */ - NUBUS_DRSW_APPLE = 0x0001, - NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */ + NUBUS_DRSW_APPLE = 0x0001, + NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */ /* NUBUS_CAT_NETWORK */ - NUBUS_DRSW_CABLETRON = 0x0001, - NUBUS_DRSW_SONIC_LC = 0x0001, - NUBUS_DRSW_KINETICS = 0x0103, - NUBUS_DRSW_ASANTE = 0x0104, - NUBUS_DRSW_DAYNA = 0x010b, - NUBUS_DRSW_FARALLON = 0x010c, - NUBUS_DRSW_APPLE_SN = 0x010f, - NUBUS_DRSW_FOCUS = 0x011a, - NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */ + NUBUS_DRSW_CABLETRON = 0x0001, + NUBUS_DRSW_SONIC_LC = 0x0001, + NUBUS_DRSW_KINETICS = 0x0103, + NUBUS_DRSW_ASANTE = 0x0104, + NUBUS_DRSW_DAYNA = 0x010b, + NUBUS_DRSW_FARALLON = 0x010c, + NUBUS_DRSW_APPLE_SN = 0x010f, + NUBUS_DRSW_DAYNA2 = 0x0115, + NUBUS_DRSW_FOCUS = 0x011a, + NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */ + NUBUS_DRSW_DAYNA_LC = 0x011e, /* NUBUS_CAT_CPU */ - NUBUS_DRSW_NONE = 0x0000, + NUBUS_DRSW_NONE = 0x0000, }; /* DrHW: Uniquely identifies the hardware interface to a board (or at @@ -106,11 +108,13 @@ enum nubus_drsw { enum nubus_drhw { /* NUBUS_CAT_DISPLAY */ NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */ + NUBUS_DRHW_APPLE_HRVC = 0x0013, /* Mac II High Res Video card */ NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */ NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */ NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */ + NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */ NUBUS_DRHW_APPLE_VALKYRIE = 0x002e, - NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */ + NUBUS_DRHW_THUNDER24 = 0x02cb, /* SuperMac Thunder/24 */ /* NUBUS_CAT_NETWORK */ NUBUS_DRHW_INTERLAN = 0x0100, @@ -119,6 +123,11 @@ enum nubus_drhw { NUBUS_DRHW_CABLETRON = 0x0109, NUBUS_DRHW_ASANTE_LC = 0x010f, NUBUS_DRHW_SONIC = 0x0110, + NUBUS_DRHW_SONIC_NB = 0x0118, + NUBUS_DRHW_SONIC_LC = 0x0119, + + /* NUBUS_CAT_COMMUNICATIONS */ + NUBUS_DRHW_DOVEFAX = 0x0100, }; /* Resource IDs: These are the identifiers for the various weird and @@ -153,8 +162,8 @@ enum nubus_board_res_id { NUBUS_RESID_SECONDINIT = 0x0026, /* Not sure why Apple put these next two in here */ - NUBUS_RESID_VIDNAMES = 0x0041, - NUBUS_RESID_VIDMODES = 0x007e + NUBUS_RESID_VIDNAMES = 0x0041, + NUBUS_RESID_VIDMODES = 0x007e }; /* Fields within the vendor info directory */ -- cgit v1.2.3 From 8ad65876172145c1d26caa837bf5ebe4fe4db7fb Mon Sep 17 00:00:00 2001 From: Robert Love Date: Sat, 28 Dec 2002 04:09:48 -0800 Subject: [PATCH] deprecated function attribute This patch adds support for usage of the attribute as "deprecated" and is backward-compatible. Usage is: int deprecated foo(void) etc.. If we mark a function as deprecated, then each use of the function emits a warning like: foo.c:12: warning: `baz' is deprecated (declared at bar.c:60) Which is very informative, giving both the location of each usage and where the little bastard is declared. --- include/linux/compiler.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/linux') diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 6b19413b47a6..51cfdb71594b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -13,6 +13,19 @@ #define likely(x) __builtin_expect((x),1) #define unlikely(x) __builtin_expect((x),0) +/* + * Allow us to mark functions as 'deprecated' and have gcc emit a nice + * warning for each use, in hopes of speeding the functions removal. + * Usage is: + * int deprecated foo(void) + * and then gcc will emit a warning for each usage of the function. + */ +#if __GNUC__ >= 3 +#define deprecated __attribute__((deprecated)) +#else +#define deprecated +#endif + /* This macro obfuscates arithmetic on a variable address so that gcc shouldn't recognize the original var, and make assumptions about it */ #define RELOC_HIDE(ptr, off) \ -- cgit v1.2.3 From ed8ea4d42880cb197dbe21041f1182a82f775e07 Mon Sep 17 00:00:00 2001 From: William Stinson Date: Sat, 28 Dec 2002 04:15:23 -0800 Subject: [PATCH] mark check_region "deprecated" This marks check_region "deprecated". This gives a nice warning messages for programs that still use check_region for example: drivers/parport/parport_pc.c:2215: warning: `__check_region' is deprecated (declared at include/linux/ioport.h:111) --- include/linux/ioport.h | 3 ++- kernel/resource.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 020bd1596ab9..7c48dfa36962 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -8,6 +8,7 @@ #ifndef _LINUX_IOPORT_H #define _LINUX_IOPORT_H +#include /* * Resources are tree-like, allowing * nesting etc.. @@ -107,7 +108,7 @@ extern struct resource * __request_region(struct resource *, unsigned long start #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) -extern int __check_region(struct resource *, unsigned long, unsigned long); +extern int deprecated __check_region(struct resource *, unsigned long, unsigned long); extern void __release_region(struct resource *, unsigned long, unsigned long); #define get_ioport_list(buf) get_resource_list(&ioport_resource, buf, PAGE_SIZE) diff --git a/kernel/resource.c b/kernel/resource.c index 9664ad073db7..7e23211ac0a9 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -237,7 +237,7 @@ struct resource * __request_region(struct resource *parent, unsigned long start, return res; } -int __check_region(struct resource *parent, unsigned long start, unsigned long n) +int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) { struct resource * res; -- cgit v1.2.3 From a869e179069a3ef64870eec58ee2aaf1a59a6070 Mon Sep 17 00:00:00 2001 From: Hirofumi Ogawa Date: Sat, 28 Dec 2002 23:54:15 -0800 Subject: [PATCH] Simplify ramfs_getattr() and move it to the generic libfs.c This moves ramfs_getattr() to fs/libfs.c as simple_getattr() --- fs/libfs.c | 9 +++++++++ fs/ramfs/inode.c | 24 +----------------------- include/linux/fs.h | 1 + kernel/ksyms.c | 1 + 4 files changed, 12 insertions(+), 23 deletions(-) (limited to 'include/linux') diff --git a/fs/libfs.c b/fs/libfs.c index 813bc9046bcd..e3d30987c919 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -6,6 +6,15 @@ #include #include +int simple_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat) +{ + struct inode *inode = dentry->d_inode; + generic_fillattr(inode, stat); + stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); + return 0; +} + int simple_statfs(struct super_block *sb, struct statfs *buf) { buf->f_type = sb->s_magic; diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 09709443911f..15418ab4f490 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -116,28 +116,6 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode) return ramfs_mknod(dir, dentry, mode | S_IFREG, 0); } -static int ramfs_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) -{ - struct inode *inode = dentry->d_inode; - - stat->dev = inode->i_sb->s_dev; - stat->ino = inode->i_ino; - stat->mode = inode->i_mode; - stat->nlink = inode->i_nlink; - stat->uid = inode->i_uid; - stat->gid = inode->i_gid; - stat->rdev = kdev_t_to_nr(inode->i_rdev); - stat->atime = inode->i_atime; - stat->mtime = inode->i_mtime; - stat->ctime = inode->i_ctime; - stat->size = inode->i_size; - stat->blocks = inode->i_mapping->nrpages << (PAGE_CACHE_SHIFT - 9); - stat->blksize = inode->i_blksize; - - return 0; -} - static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char * symname) { struct inode *inode; @@ -171,7 +149,7 @@ static struct file_operations ramfs_file_operations = { }; static struct inode_operations ramfs_file_inode_operations = { - .getattr = ramfs_getattr, + .getattr = simple_getattr, }; static struct inode_operations ramfs_dir_inode_operations = { diff --git a/include/linux/fs.h b/include/linux/fs.h index 500cb3ac421e..5c00caf3edf1 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1300,6 +1300,7 @@ extern int dcache_dir_open(struct inode *, struct file *); extern int dcache_dir_close(struct inode *, struct file *); extern loff_t dcache_dir_lseek(struct file *, loff_t, int); extern int dcache_readdir(struct file *, void *, filldir_t); +extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *); extern int simple_statfs(struct super_block *, struct statfs *); extern int simple_link(struct dentry *, struct inode *, struct dentry *); extern int simple_unlink(struct inode *, struct dentry *); diff --git a/kernel/ksyms.c b/kernel/ksyms.c index f634f12d4bef..cd49778dd1f3 100644 --- a/kernel/ksyms.c +++ b/kernel/ksyms.c @@ -299,6 +299,7 @@ EXPORT_SYMBOL(dcache_dir_open); EXPORT_SYMBOL(dcache_dir_close); EXPORT_SYMBOL(dcache_dir_lseek); EXPORT_SYMBOL(dcache_readdir); +EXPORT_SYMBOL(simple_getattr); EXPORT_SYMBOL(simple_statfs); EXPORT_SYMBOL(simple_lookup); EXPORT_SYMBOL(simple_dir_operations); -- cgit v1.2.3 From 6b57bcef60f1413afd6c69bb5d1bc64415005da5 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 29 Dec 2002 00:01:53 -0800 Subject: [PATCH] fix "deprecated" typos This corrects the misspellings of "deprecated" in a few places. --- drivers/video/aty128fb.c | 2 +- include/asm-arm/arch-arc/io.h | 2 +- include/asm-arm/arch-cl7500/io.h | 2 +- include/asm-arm/arch-rpc/io.h | 2 +- include/asm-arm/memory.h | 4 ++-- include/asm-arm/setup.h | 2 +- include/linux/ax25.h | 2 +- net/ax25/af_ax25.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include/linux') diff --git a/drivers/video/aty128fb.c b/drivers/video/aty128fb.c index 69f2d8d618c3..5545dbdb50ac 100644 --- a/drivers/video/aty128fb.c +++ b/drivers/video/aty128fb.c @@ -1415,7 +1415,7 @@ aty128fb_setup(char *options) } #endif #ifdef CONFIG_ALL_PPC - /* vmode and cmode depreciated */ + /* vmode and cmode deprecated */ if (!strncmp(this_opt, "vmode:", 6)) { unsigned int vmode = simple_strtoul(this_opt+6, NULL, 0); if (vmode > 0 && vmode <= VMODE_MAX) diff --git a/include/asm-arm/arch-arc/io.h b/include/asm-arm/arch-arc/io.h index 11c9ce687ab4..5aab0c88953f 100644 --- a/include/asm-arm/arch-arc/io.h +++ b/include/asm-arm/arch-arc/io.h @@ -246,7 +246,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) /* diff --git a/include/asm-arm/arch-cl7500/io.h b/include/asm-arm/arch-cl7500/io.h index 376ca94ebb9c..16a926084d5f 100644 --- a/include/asm-arm/arch-cl7500/io.h +++ b/include/asm-arm/arch-cl7500/io.h @@ -236,7 +236,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) #endif diff --git a/include/asm-arm/arch-rpc/io.h b/include/asm-arm/arch-rpc/io.h index cb39453f5c9f..3a1c18ad63bb 100644 --- a/include/asm-arm/arch-rpc/io.h +++ b/include/asm-arm/arch-rpc/io.h @@ -238,7 +238,7 @@ DECLARE_IO(int,l,"") #define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p)) #define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p)) #define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p)) -/* the following macro is depreciated */ +/* the following macro is deprecated */ #define ioaddr(port) __ioaddr((port)) #define insb(p,d,l) __raw_readsb(__ioaddr(p),d,l) diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h index c936883e5f0e..38682a28d121 100644 --- a/include/asm-arm/memory.h +++ b/include/asm-arm/memory.h @@ -44,7 +44,7 @@ static inline void *phys_to_virt(unsigned long x) /* * Virtual <-> DMA view memory address translations * Again, these are *only* valid on the kernel direct mapped RAM - * memory. Use of these is *depreciated*. + * memory. Use of these is *deprecated*. */ #define virt_to_bus(x) (__virt_to_bus((unsigned long)(x))) #define bus_to_virt(x) ((void *)(__bus_to_virt((unsigned long)(x)))) @@ -109,7 +109,7 @@ static inline void *phys_to_virt(unsigned long x) #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) /* - * We should really eliminate virt_to_bus() here - it's depreciated. + * We should really eliminate virt_to_bus() here - it's deprecated. */ #define page_to_bus(page) (virt_to_bus(page_address(page))) diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h index 38f4ba0ecc67..f3319e9b4f29 100644 --- a/include/asm-arm/setup.h +++ b/include/asm-arm/setup.h @@ -68,7 +68,7 @@ struct tag_ramdisk { /* describes where the compressed ramdisk image lives (virtual address) */ /* * this one accidentally used virtual addresses - as such, - * its depreciated. + * it's deprecated. */ #define ATAG_INITRD 0x54410005 diff --git a/include/linux/ax25.h b/include/linux/ax25.h index 6dfc8fc9116d..56c11f0dbd80 100644 --- a/include/linux/ax25.h +++ b/include/linux/ax25.h @@ -85,7 +85,7 @@ struct ax25_ctl_struct { }; /* this will go away. Please do not export to user land */ -struct ax25_info_struct_depreciated { +struct ax25_info_struct_deprecated { unsigned int n2, n2count; unsigned int t1, t1timer; unsigned int t2, t2timer; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 82a847128a31..1eedb5ed6cb2 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1786,7 +1786,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) warned=1; } - if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_depreciated))) { + if (copy_to_user((void *)arg, &ax25_info, sizeof(struct ax25_info_struct_deprecated))) { res = -EFAULT; break; } -- cgit v1.2.3 From 2cdea2157dfbe0ea2a28bf6d4dc6c53013e4088f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 00:35:42 -0800 Subject: [PATCH] more deprectation bits Rename the deprecated attribute to __deprecated to make it obvious this is something special and to avoid namespace clashes. Mark old module interfaces deprecated. --- include/linux/compiler.h | 4 ++-- include/linux/ioport.h | 2 +- include/linux/module.h | 34 ++++++++++++++++++++++++++-------- kernel/resource.c | 2 +- 4 files changed, 30 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 51cfdb71594b..f88889740949 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -21,9 +21,9 @@ * and then gcc will emit a warning for each usage of the function. */ #if __GNUC__ >= 3 -#define deprecated __attribute__((deprecated)) +#define __deprecated __attribute__((deprecated)) #else -#define deprecated +#define __deprecated #endif /* This macro obfuscates arithmetic on a variable address so that gcc diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 7c48dfa36962..edd1eadb98b8 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -108,7 +108,7 @@ extern struct resource * __request_region(struct resource *, unsigned long start #define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n)) #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n)) -extern int deprecated __check_region(struct resource *, unsigned long, unsigned long); +extern int __deprecated __check_region(struct resource *, unsigned long, unsigned long); extern void __release_region(struct resource *, unsigned long, unsigned long); #define get_ioport_list(buf) get_resource_list(&ioport_resource, buf, PAGE_SIZE) diff --git a/include/linux/module.h b/include/linux/module.h index 2392edcc3307..c033488d6eeb 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -296,9 +296,20 @@ extern spinlock_t modlist_lock; #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ -#define __MOD_INC_USE_COUNT(mod) \ - do { __unsafe(mod); (void)try_module_get(mod); } while(0) -#define __MOD_DEC_USE_COUNT(mod) module_put(mod) +static inline void __deprecated __MOD_INC_USE_COUNT(struct module *module) +{ + __unsafe(module); + /* + * Yes, we ignore the retval here, that's why it's deprecated. + */ + try_module_get(module); +} + +static inline void __deprecated __MOD_DEC_USE_COUNT(struct module *module) +{ + module_put(module); +} + #define SET_MODULE_OWNER(dev) ((dev)->owner = THIS_MODULE) struct obsolete_modparm { @@ -319,14 +330,21 @@ struct obsolete_modparm __parm_##var __attribute__((section("__obsparm"))) = \ /* People do this inside their init routines, when the module isn't "live" yet. They should no longer be doing that, but meanwhile... */ +static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module) +{ + __unsafe(module); + #if defined(CONFIG_MODULE_UNLOAD) && defined(MODULE) -#define MOD_INC_USE_COUNT \ - do { __unsafe(THIS_MODULE); local_inc(&THIS_MODULE->ref[get_cpu()].count); put_cpu(); } while (0) + local_inc(&module->ref[get_cpu()].count); + put_cpu(); #else -#define MOD_INC_USE_COUNT \ - do { __unsafe(THIS_MODULE); (void)try_module_get(THIS_MODULE); } while (0) + try_module_get(module); #endif -#define MOD_DEC_USE_COUNT module_put(THIS_MODULE) +} +#define MOD_INC_USE_COUNT \ + _MOD_INC_USE_COUNT(THIS_MODULE) +#define MOD_DEC_USE_COUNT \ + __MOD_DEC_USE_COUNT(THIS_MODULE) #define try_inc_mod_count(mod) try_module_get(mod) #define EXPORT_NO_SYMBOLS extern int module_dummy_usage; diff --git a/kernel/resource.c b/kernel/resource.c index 7e23211ac0a9..83d04826245d 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -237,7 +237,7 @@ struct resource * __request_region(struct resource *parent, unsigned long start, return res; } -int deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) +int __deprecated __check_region(struct resource *parent, unsigned long start, unsigned long n) { struct resource * res; -- cgit v1.2.3 From afe0458b256d78a37ba9f244cce29e141e1c658a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 00:40:46 -0800 Subject: [PATCH] avoid deprecated module functions in core code A second start at removing them from kernel/*.c and fs/*.c. Note that module_put is fine for a NULL argument. --- crypto/api.c | 3 +-- drivers/block/genhd.c | 6 ++---- fs/block_dev.c | 11 +++++------ fs/dquot.c | 3 +-- fs/exec.c | 17 ++++++++++------- fs/nls/nls_base.c | 3 +-- fs/partitions/check.c | 3 +-- include/linux/binfmts.h | 8 +------- include/linux/fs.h | 4 ++-- include/linux/personality.h | 18 ------------------ kernel/exec_domain.c | 7 ++----- kernel/exit.c | 6 +++--- kernel/fork.c | 14 ++++++++------ kernel/intermodule.c | 2 +- 14 files changed, 38 insertions(+), 67 deletions(-) (limited to 'include/linux') diff --git a/crypto/api.c b/crypto/api.c index 626437fb5dea..64886f4d6335 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -29,8 +29,7 @@ static inline int crypto_alg_get(struct crypto_alg *alg) static inline void crypto_alg_put(struct crypto_alg *alg) { - if (alg->cra_module) - __MOD_DEC_USE_COUNT(alg->cra_module); + module_put(alg->cra_module); } struct crypto_alg *crypto_alg_lookup(const char *name) diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 98a62d7c7a6b..c133b454b2fb 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -168,15 +168,13 @@ retry: best = p->range; *part = dev - p->dev; if (p->lock && p->lock(dev, data) < 0) { - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); continue; } read_unlock(&gendisk_lock); disk = probe(dev, part, data); /* Currently ->owner protects _only_ ->probe() itself. */ - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); if (disk) return disk; goto retry; diff --git a/fs/block_dev.c b/fs/block_dev.c index e6fc5b1984e3..2e0b69ff70a1 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -623,8 +623,7 @@ static int do_open(struct block_device *bdev, struct inode *inode, struct file * } } else { put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); if (bdev->bd_contains == bdev) { if (bdev->bd_disk->fops->open) { ret = bdev->bd_disk->fops->open(inode, file); @@ -651,8 +650,7 @@ out_first: blkdev_put(bdev->bd_contains, BDEV_RAW); bdev->bd_contains = NULL; put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); out: up(&bdev->bd_sem); unlock_kernel(); @@ -723,9 +721,10 @@ int blkdev_put(struct block_device *bdev, int kind) } if (!bdev->bd_openers) { struct module *owner = disk->fops->owner; + put_disk(disk); - if (owner) - __MOD_DEC_USE_COUNT(owner); + module_put(owner); + bdev->bd_disk = NULL; bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info; if (bdev != bdev->bd_contains) { diff --git a/fs/dquot.c b/fs/dquot.c index 5da20a7049ce..8781f7201a87 100644 --- a/fs/dquot.c +++ b/fs/dquot.c @@ -111,8 +111,7 @@ static struct quota_format_type *find_quota_format(int id) static void put_quota_format(struct quota_format_type *fmt) { - if (fmt->qf_owner) - __MOD_DEC_USE_COUNT(fmt->qf_owner); + module_put(fmt->qf_owner); } /* diff --git a/fs/exec.c b/fs/exec.c index 1699f5bdf92e..901b8e12388f 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -102,8 +102,7 @@ int unregister_binfmt(struct linux_binfmt * fmt) static inline void put_binfmt(struct linux_binfmt * fmt) { - if (fmt->module) - __MOD_DEC_USE_COUNT(fmt->module); + module_put(fmt->module); } /* @@ -1108,14 +1107,18 @@ out_file: return retval; } -void set_binfmt(struct linux_binfmt *new) +int set_binfmt(struct linux_binfmt *new) { struct linux_binfmt *old = current->binfmt; - if (new && new->module) - __MOD_INC_USE_COUNT(new->module); + + if (new) { + if (!try_module_get(new->module)) + return -1; + } current->binfmt = new; - if (old && old->module) - __MOD_DEC_USE_COUNT(old->module); + if (old) + module_put(old->module); + return 0; } #define CORENAME_MAX_SIZE 64 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c index 0af5e08cb950..3ea711688341 100644 --- a/fs/nls/nls_base.c +++ b/fs/nls/nls_base.c @@ -245,8 +245,7 @@ struct nls_table *load_nls(char *charset) void unload_nls(struct nls_table *nls) { - if (nls->owner) - __MOD_DEC_USE_COUNT(nls->owner); + module_put(nls->owner); } wchar_t charset2uni[256] = { diff --git a/fs/partitions/check.c b/fs/partitions/check.c index da216ea3efa6..b1d436feb241 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -565,8 +565,7 @@ char *partition_name(dev_t dev) dname->name = NULL; if (hd) { dname->name = disk_name(hd, part, dname->namebuf); - if (hd->fops->owner) - __MOD_DEC_USE_COUNT(hd->fops->owner); + module_put(hd->fops->owner); put_disk(hd); } if (!dname->name) { diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index ae1b454395b5..bd929e344d75 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h @@ -58,13 +58,7 @@ extern int copy_strings(int argc,char ** argv,struct linux_binprm *bprm); extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); extern void compute_creds(struct linux_binprm *binprm); extern int do_coredump(long signr, int exit_code, struct pt_regs * regs); -extern void set_binfmt(struct linux_binfmt *new); - - -#if 0 -/* this went away now */ -#define change_ldt(a,b) setup_arg_pages(a,b) -#endif +extern int set_binfmt(struct linux_binfmt *new); #endif /* __KERNEL__ */ #endif /* _LINUX_BINFMTS_H */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 5c00caf3edf1..6c3188b991e6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -983,13 +983,13 @@ struct super_block *get_sb_pseudo(struct file_system_type *, char *, /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \ (((fops) && (fops)->owner) \ - ? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \ + ? (try_inc_mod_count((fops)->owner) ? (fops) : NULL) \ : (fops)) #define fops_put(fops) \ do { \ if ((fops) && (fops)->owner) \ - __MOD_DEC_USE_COUNT((fops)->owner); \ + module_put((fops)->owner); \ } while(0) extern int register_filesystem(struct file_system_type *); diff --git a/include/linux/personality.h b/include/linux/personality.h index ca5d403e49ff..33802c8eeedb 100644 --- a/include/linux/personality.h +++ b/include/linux/personality.h @@ -107,22 +107,4 @@ struct exec_domain { #define set_personality(pers) \ ((current->personality == pers) ? 0 : __set_personality(pers)) -/* - * Load an execution domain. - */ -#define get_exec_domain(ep) \ -do { \ - if (ep != NULL && ep->module != NULL) \ - __MOD_INC_USE_COUNT(ep->module); \ -} while (0) - -/* - * Unload an execution domain. - */ -#define put_exec_domain(ep) \ -do { \ - if (ep != NULL && ep->module != NULL) \ - __MOD_DEC_USE_COUNT(ep->module); \ -} while (0) - #endif /* _LINUX_PERSONALITY_H */ diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index e0b31f7f5243..162a5c23e606 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -172,7 +172,7 @@ __set_personality(u_long personality) fsp = copy_fs_struct(current->fs); if (fsp == NULL) { - put_exec_domain(ep); + module_put(ep->module); return -ENOMEM;; } @@ -194,10 +194,7 @@ __set_personality(u_long personality) current_thread_info()->exec_domain = ep; set_fs_altroot(); - put_exec_domain(oep); - - printk(KERN_DEBUG "[%s:%d]: set personality to %lx\n", - current->comm, current->pid, personality); + module_put(oep->module); return 0; } diff --git a/kernel/exit.c b/kernel/exit.c index 5e7fcdaa6221..6adea537242a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -664,9 +664,9 @@ fake_volatile: if (current->leader) disassociate_ctty(1); - put_exec_domain(tsk->thread_info->exec_domain); - if (tsk->binfmt && tsk->binfmt->module) - __MOD_DEC_USE_COUNT(tsk->binfmt->module); + module_put(tsk->thread_info->exec_domain->module); + if (tsk->binfmt) + module_put(tsk->binfmt->module); tsk->exit_code = code; exit_notify(); diff --git a/kernel/fork.c b/kernel/fork.c index b8771509f285..6f7298827344 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -743,10 +743,11 @@ static struct task_struct *copy_process(unsigned long clone_flags, if (nr_threads >= max_threads) goto bad_fork_cleanup_count; - get_exec_domain(p->thread_info->exec_domain); + if (!try_module_get(p->thread_info->exec_domain->module)) + goto bad_fork_cleanup_count; - if (p->binfmt && p->binfmt->module) - __MOD_INC_USE_COUNT(p->binfmt->module); + if (p->binfmt && !try_module_get(p->binfmt->module)) + goto bad_fork_cleanup_put_domain; #ifdef CONFIG_PREEMPT /* @@ -958,9 +959,10 @@ bad_fork_cleanup_security: bad_fork_cleanup: if (p->pid > 0) free_pidmap(p->pid); - put_exec_domain(p->thread_info->exec_domain); - if (p->binfmt && p->binfmt->module) - __MOD_DEC_USE_COUNT(p->binfmt->module); + if (p->binfmt) + module_put(p->binfmt->module); +bad_fork_cleanup_put_domain: + module_put(p->thread_info->exec_domain->module); bad_fork_cleanup_count: atomic_dec(&p->user->processes); free_uid(p->user); diff --git a/kernel/intermodule.c b/kernel/intermodule.c index a6cd1d08afa4..9228ca4fe035 100644 --- a/kernel/intermodule.c +++ b/kernel/intermodule.c @@ -166,7 +166,7 @@ void inter_module_put(const char *im_name) ime = list_entry(tmp, struct inter_module_entry, list); if (strcmp(ime->im_name, im_name) == 0) { if (ime->owner) - __MOD_DEC_USE_COUNT(ime->owner); + module_put(ime->owner); spin_unlock(&ime_lock); return; } -- cgit v1.2.3 From 35bc6f3f8db6a6412fcb6fb9a251a1083094ca47 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 29 Dec 2002 01:47:53 -0800 Subject: [PATCH] Embed __this_module in module itself. Rather than have the module loader the module structure and resolve the symbols __this_module to it, make __this_module a real structure inside the module, using the linkonce trick we used for module names. This saves us an allocation (saving a page per module on archs which need the module structure close by), and means we don't have to fill in a few module fields. --- include/linux/init.h | 5 +-- include/linux/module.h | 34 ++++++++-------- kernel/module.c | 103 ++++++++++++++++++++++--------------------------- 3 files changed, 66 insertions(+), 76 deletions(-) (limited to 'include/linux') diff --git a/include/linux/init.h b/include/linux/init.h index 46b1ef190c52..b7c6363478aa 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -147,14 +147,13 @@ struct obs_kernel_param { #define module_init(initfn) \ static inline initcall_t __inittest(void) \ { return initfn; } \ - int __initfn(void) __attribute__((alias(#initfn))); + int init_module(void) __attribute__((alias(#initfn))); /* This is only required if you want to be unloadable. */ #define module_exit(exitfn) \ static inline exitcall_t __exittest(void) \ { return exitfn; } \ - void __exitfn(void) __attribute__((alias(#exitfn))); - + void cleanup_module(void) __attribute__((alias(#exitfn))); #define __setup(str,func) /* nothing */ #endif diff --git a/include/linux/module.h b/include/linux/module.h index c033488d6eeb..3a411c8c6575 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -40,12 +40,11 @@ struct kernel_symbol char name[MODULE_NAME_LEN]; }; -#ifdef MODULE +/* These are either module local, or the kernel's dummy ones. */ +extern int init_module(void); +extern void cleanup_module(void); -#ifdef KBUILD_MODNAME -static const char __module_name[MODULE_NAME_LEN] __attribute__((section(".gnu.linkonce.modname"))) = \ - __stringify(KBUILD_MODNAME); -#endif +#ifdef MODULE /* For replacement modutils, use an alias not a pointer. */ #define MODULE_GENERIC_TABLE(gtype,name) \ @@ -56,9 +55,6 @@ static const struct gtype##_id * __module_##gtype##_table \ extern const struct gtype##_id __mod_##gtype##_table \ __attribute__ ((unused, alias(__stringify(name)))) -/* This is magically filled in by the linker, but THIS_MODULE must be - a constant so it works in initializers. */ -extern struct module __this_module; #define THIS_MODULE (&__this_module) #else /* !MODULE */ @@ -176,7 +172,7 @@ struct module /* The command line arguments (may be mangled). People like keeping pointers to this stuff */ - char args[0]; + char *args; }; /* FIXME: It'd be nice to isolate modules during init, too, so they @@ -289,6 +285,19 @@ static inline const char *module_address_lookup(unsigned long addr, } #endif /* CONFIG_MODULES */ +#if defined(MODULE) && defined(KBUILD_MODNAME) +/* We make the linker do some of the work. */ +struct module __this_module +__attribute__((section(".gnu.linkonce.this_module"))) = { + .name = __stringify(KBUILD_MODNAME), + .symbols = { .owner = &__this_module }, + .init = init_module, +#ifdef CONFIG_MODULE_UNLOAD + .exit = cleanup_module, +#endif +}; +#endif /* MODULE && KBUILD_MODNAME */ + /* For archs to search exception tables */ extern struct list_head extables; extern spinlock_t modlist_lock; @@ -360,13 +369,6 @@ extern int module_dummy_usage; && __mod_between((p),(n),(m)->module_init,(m)->init_size)) \ || __mod_between((p),(n),(m)->module_core,(m)->core_size)) -/* Old-style "I'll just call it init_module and it'll be run at - insert". Use module_init(myroutine) instead. */ -#ifdef MODULE -#define init_module(voidarg) __initfn(void) -#define cleanup_module(voidarg) __exitfn(void) -#endif - /* * The exception and symbol tables, and the lock * to protect them. diff --git a/kernel/module.c b/kernel/module.c index 2209ab07e733..fe995b8d8ea9 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -60,6 +60,13 @@ struct sizes unsigned long core_size; }; +/* Stub function for modules which don't have an initfn */ +int init_module(void) +{ + return 0; +} +EXPORT_SYMBOL(init_module); + /* Find a symbol, return value and the symbol group */ static unsigned long __find_symbol(const char *name, struct kernel_symbol_group **group) @@ -357,6 +364,12 @@ static inline int try_force(unsigned int flags) } #endif /* CONFIG_MODULE_FORCE_UNLOAD */ +/* Stub function for modules which don't have an exitfn */ +void cleanup_module(void) +{ +} +EXPORT_SYMBOL(cleanup_module); + asmlinkage long sys_delete_module(const char *name_user, unsigned int flags) { @@ -406,7 +419,8 @@ sys_delete_module(const char *name_user, unsigned int flags) } /* If it has an init func, it must have an exit func to unload */ - if ((mod->init && !mod->exit) || mod->unsafe) { + if ((mod->init != init_module && mod->exit == cleanup_module) + || mod->unsafe) { forced = try_force(flags); if (!forced) { /* This module can't be removed */ @@ -453,8 +467,7 @@ sys_delete_module(const char *name_user, unsigned int flags) destroy: /* Final destruction now noone is using it. */ - if (mod->exit) - mod->exit(); + mod->exit(); free_module(mod); out: @@ -474,7 +487,7 @@ static void print_unload_info(struct seq_file *m, struct module *mod) if (mod->unsafe) seq_printf(m, " [unsafe]"); - if (mod->init && !mod->exit) + if (mod->init != init_module && mod->exit == cleanup_module) seq_printf(m, " [permanent]"); seq_printf(m, "\n"); @@ -708,15 +721,15 @@ static void free_module(struct module *mod) list_del(&mod->extable.list); spin_unlock_irq(&modlist_lock); - /* These may be NULL, but that's OK */ - module_free(mod, mod->module_init); - module_free(mod, mod->module_core); - /* Module unload stuff */ module_unload_free(mod); - /* Finally, free the module structure */ - module_free(mod, mod); + /* This may be NULL, but that's OK */ + module_free(mod, mod->module_init); + kfree(mod->args); + + /* Finally, free the core (containing the module structure) */ + module_free(mod, mod->module_core); } void *__symbol_get(const char *symbol) @@ -771,27 +784,6 @@ static void *copy_section(const char *name, return dest; } -/* Look for the special symbols */ -static int grab_private_symbols(Elf_Shdr *sechdrs, - unsigned int symbolsec, - const char *strtab, - struct module *mod) -{ - Elf_Sym *sym = (void *)sechdrs[symbolsec].sh_offset; - unsigned int i; - - for (i = 1; i < sechdrs[symbolsec].sh_size/sizeof(*sym); i++) { - if (symbol_is("__initfn", strtab + sym[i].st_name)) - mod->init = (void *)sym[i].st_value; -#ifdef CONFIG_MODULE_UNLOAD - if (symbol_is("__exitfn", strtab + sym[i].st_name)) - mod->exit = (void *)sym[i].st_value; -#endif - } - - return 0; -} - /* Deal with the given section */ static int handle_section(const char *name, Elf_Shdr *sechdrs, @@ -810,9 +802,6 @@ static int handle_section(const char *name, case SHT_RELA: ret = apply_relocate_add(sechdrs, strtab, symindex, i, mod); break; - case SHT_SYMTAB: - ret = grab_private_symbols(sechdrs, i, strtab, mod); - break; default: DEBUGP("Ignoring section %u: %s\n", i, sechdrs[i].sh_type==SHT_NULL ? "NULL": @@ -920,9 +909,6 @@ static void simplify_symbols(Elf_Shdr *sechdrs, strtab + sym[i].st_name, mod, &ksg); - /* We fake up "__this_module" */ - if (symbol_is("__this_module", strtab+sym[i].st_name)) - sym[i].st_value = (unsigned long)mod; } } } @@ -964,9 +950,9 @@ static struct module *load_module(void *umod, { Elf_Ehdr *hdr; Elf_Shdr *sechdrs; - char *secstrings; + char *secstrings, *args; unsigned int i, symindex, exportindex, strindex, setupindex, exindex, - modnameindex, obsparmindex; + modindex, obsparmindex; long arglen; unsigned long common_length; struct sizes sizes, used; @@ -1007,7 +993,7 @@ static struct module *load_module(void *umod, exportindex = setupindex = obsparmindex = 0; /* And these should exist, but gcc whinges if we don't init them */ - symindex = strindex = exindex = modnameindex = 0; + symindex = strindex = exindex = modindex = 0; /* Find where important sections are */ for (i = 1; i < hdr->e_shnum; i++) { @@ -1016,10 +1002,10 @@ static struct module *load_module(void *umod, DEBUGP("Symbol table in section %u\n", i); symindex = i; } else if (strcmp(secstrings+sechdrs[i].sh_name, - ".gnu.linkonce.modname") == 0) { - /* This module's name */ - DEBUGP("Module name in section %u\n", i); - modnameindex = i; + ".gnu.linkonce.this_module") == 0) { + /* The module struct */ + DEBUGP("Module in section %u\n", i); + modindex = i; } else if (strcmp(secstrings+sechdrs[i].sh_name, "__ksymtab") == 0) { /* Exported symbols. */ @@ -1058,39 +1044,35 @@ static struct module *load_module(void *umod, #endif } - if (!modnameindex) { - DEBUGP("Module has no name!\n"); + if (!modindex) { + printk(KERN_WARNING "No module found in object\n"); err = -ENOEXEC; goto free_hdr; } + mod = (void *)hdr + sechdrs[modindex].sh_offset; - /* Now allocate space for the module proper, and copy name and args. */ + /* Now copy in args */ err = strlen_user(uargs); if (err < 0) goto free_hdr; arglen = err; - mod = module_alloc(sizeof(*mod) + arglen+1); - if (!mod) { + args = kmalloc(arglen+1, GFP_KERNEL); + if (!args) { err = -ENOMEM; goto free_hdr; } - memset(mod, 0, sizeof(*mod) + arglen+1); - if (copy_from_user(mod->args, uargs, arglen) != 0) { + if (copy_from_user(args, uargs, arglen+1) != 0) { err = -EFAULT; goto free_mod; } - strncpy(mod->name, (char *)hdr + sechdrs[modnameindex].sh_offset, - sizeof(mod->name)-1); if (find_module(mod->name)) { err = -EEXIST; goto free_mod; } - mod->symbols.owner = mod; mod->state = MODULE_STATE_COMING; - module_unload_init(mod); /* How much space will we need? (Common area in first) */ common_length = read_commons(hdr, &sechdrs[symindex]); @@ -1139,6 +1121,9 @@ static struct module *load_module(void *umod, if (IS_ERR(ptr)) goto cleanup; sechdrs[i].sh_offset = (unsigned long)ptr; + /* Have we just copied __this_module across? */ + if (i == modindex) + mod = ptr; } else { sechdrs[i].sh_offset += (unsigned long)hdr; } @@ -1147,6 +1132,9 @@ static struct module *load_module(void *umod, if (used.init_size > mod->init_size || used.core_size > mod->core_size) BUG(); + /* Now we've moved module, initialize linked lists, etc. */ + module_unload_init(mod); + /* Fix up syms, so that st_value is a pointer to location. */ simplify_symbols(sechdrs, symindex, strindex, mod->module_core, mod); @@ -1183,6 +1171,7 @@ static struct module *load_module(void *umod, if (err < 0) goto cleanup; + mod->args = args; if (obsparmindex) { err = obsolete_params(mod->name, mod->args, (struct obsolete_modparm *) @@ -1215,7 +1204,7 @@ static struct module *load_module(void *umod, free_core: module_free(mod, mod->module_core); free_mod: - module_free(mod, mod); + kfree(args); free_hdr: vfree(hdr); if (err < 0) return ERR_PTR(err); @@ -1266,7 +1255,7 @@ sys_init_module(void *umod, up(&module_mutex); /* Start the module */ - ret = mod->init ? mod->init() : 0; + ret = mod->init(); if (ret < 0) { /* Init routine failed: abort. Try to protect us from buggy refcounters. */ -- cgit v1.2.3 From bfafc871ca1ea430dd7422fdfdfe0fa2e959c566 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Sun, 29 Dec 2002 01:48:01 -0800 Subject: [PATCH] Trivial patch for param.h: make it const. Add a const declaration to the __module_param_call so __param section gets more correct attributes. --- include/linux/moduleparam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 92a1bc154e8e..e52553263640 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -39,7 +39,7 @@ struct kparam_string { writable. */ #define __module_param_call(prefix, name, set, get, arg, perm) \ static char __param_str_##name[] __initdata = prefix #name; \ - static struct kernel_param __param_##name \ + static struct kernel_param const __param_##name \ __attribute__ ((unused,__section__ ("__param"))) \ = { __param_str_##name, perm, set, get, arg } -- cgit v1.2.3 From bec7aa00ffe5b1270837b965fdfe80be3e8e6e2e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 03:26:34 -0800 Subject: [PATCH] more module warning fixes this is only for the module-related warning introduced by my __deprecated patch. --- drivers/block/paride/paride.c | 15 ++++------ drivers/char/busmouse.c | 7 ++--- drivers/hotplug/pci_hotplug_core.c | 52 ++++++++++++++++------------------- drivers/ide/ide.c | 6 ++-- drivers/ieee1394/ieee1394_core.c | 23 +++++----------- drivers/isdn/capi/kcapi.c | 3 +- drivers/md/dm-target.c | 14 +++++----- drivers/media/dvb/dvb-core/dvb_i2c.c | 23 +++++----------- drivers/media/video/cpia.c | 3 +- drivers/mtd/chips/chipreg.c | 6 ++-- drivers/net/irda/sir_dev.c | 9 ++---- drivers/net/irda/sir_dongle.c | 7 ++--- drivers/s390/block/dasd.c | 3 +- drivers/s390/block/dasd_ioctl.c | 2 +- drivers/s390/char/tape_core.c | 3 +- drivers/scsi/fcal.c | 10 +++++-- drivers/scsi/pluto.c | 8 ++++-- drivers/serial/core.c | 6 ++-- drivers/usb/media/ov511.c | 32 +++++++++++---------- drivers/usb/media/usbvideo.c | 8 ++++-- include/linux/mtd/map.h | 5 +--- include/linux/mtd/mtd.h | 3 +- net/core/dev.c | 9 ++---- net/ipv4/xfrm_policy.c | 3 +- net/rxrpc/call.c | 2 +- sound/core/control.c | 10 ++----- sound/core/info.c | 10 ++----- sound/core/oss/mixer_oss.c | 8 +----- sound/core/oss/pcm_oss.c | 10 ++----- sound/core/pcm_native.c | 12 ++------ sound/core/rawmidi.c | 10 ++----- sound/core/seq/oss/seq_oss_synth.c | 10 ++----- sound/core/seq/seq_ports.c | 10 ++----- sound/core/seq/seq_virmidi.c | 10 ++----- sound/core/timer.c | 8 +----- sound/drivers/opl3/opl3_seq.c | 8 +----- sound/isa/gus/gus_main.c | 8 +----- sound/isa/wavefront/wavefront_fx.c | 9 +----- sound/isa/wavefront/wavefront_synth.c | 9 +----- sound/oss/audio.c | 26 ++++++++---------- sound/oss/midibuf.c | 6 ++-- sound/oss/mpu401.c | 18 ++++++------ sound/oss/sequencer.c | 22 ++++++--------- sound/oss/soundcard.c | 10 +++---- sound/synth/emux/emux_seq.c | 12 ++------ 45 files changed, 172 insertions(+), 316 deletions(-) (limited to 'include/linux') diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c index 3c1161767acf..0b19343f6969 100644 --- a/drivers/block/paride/paride.c +++ b/drivers/block/paride/paride.c @@ -175,8 +175,7 @@ void pi_release(PIA * pi) #endif /* !CONFIG_PARPORT */ if (pi->proto->release_proto) pi->proto->release_proto(pi); - if (pi->proto->owner) - __MOD_DEC_USE_COUNT(pi->proto->owner); + module_put(pi->proto->owner); } EXPORT_SYMBOL(pi_release); @@ -238,7 +237,6 @@ int pi_register(PIP * pr) printk("paride: protocol table full\n"); return 0; } - MOD_INC_USE_COUNT; protocols[k] = pr; pr->index = k; printk("paride: %s registered as protocol %d\n", pr->name, k); @@ -256,7 +254,6 @@ void pi_unregister(PIP * pr) return; } protocols[pr->index] = 0; - MOD_DEC_USE_COUNT; } EXPORT_SYMBOL(pi_unregister); @@ -392,14 +389,13 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode, if (!proto) continue; /* still racy */ - if (proto->owner) - __MOD_INC_USE_COUNT(proto->owner); + if (!try_module_get(proto->owner)) + continue; pi->proto = proto; pi->private = 0; if (proto->init_proto && proto->init_proto(pi) < 0) { pi->proto = NULL; - if (proto->owner) - __MOD_DEC_USE_COUNT(proto->owner); + module_put(proto->owner); continue; } if (delay == -1) @@ -432,8 +428,7 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode, } if (pi->proto->release_proto) pi->proto->release_proto(pi); - if (proto->owner) - __MOD_DEC_USE_COUNT(proto->owner); + module_put(proto->owner); } if (!pi->port) { diff --git a/drivers/char/busmouse.c b/drivers/char/busmouse.c index 29362e24aa4c..85baa0cdf51b 100644 --- a/drivers/char/busmouse.c +++ b/drivers/char/busmouse.c @@ -175,8 +175,7 @@ static int busmouse_release(struct inode *inode, struct file *file) if (--mse->active == 0) { if (mse->ops->release) ret = mse->ops->release(inode, file); - if (mse->ops->owner) - __MOD_DEC_USE_COUNT(mse->ops->owner); + module_put(mse->ops->owner); mse->ready = 0; } unlock_kernel(); @@ -207,8 +206,8 @@ static int busmouse_open(struct inode *inode, struct file *file) ret = 0; if (mse->ops->open) { ret = mse->ops->open(inode, file); - if (ret && mse->ops->owner) - __MOD_DEC_USE_COUNT(mse->ops->owner); + if (ret) + module_put(mse->ops->owner); } if (ret) diff --git a/drivers/hotplug/pci_hotplug_core.c b/drivers/hotplug/pci_hotplug_core.c index b03104c8edd1..5e4c1748b7d1 100644 --- a/drivers/hotplug/pci_hotplug_core.c +++ b/drivers/hotplug/pci_hotplug_core.c @@ -561,19 +561,19 @@ static void fs_remove_file (struct dentry *dentry) up(&parent->d_inode->i_sem); } +/* yuck, WFT is this? */ #define GET_STATUS(name,type) \ static int get_##name (struct hotplug_slot *slot, type *value) \ { \ struct hotplug_slot_ops *ops = slot->ops; \ int retval = 0; \ - if (ops->owner) \ - __MOD_INC_USE_COUNT(ops->owner); \ - if (ops->get_##name) \ - retval = ops->get_##name (slot, value); \ - else \ - *value = slot->info->name; \ - if (ops->owner) \ - __MOD_DEC_USE_COUNT(ops->owner); \ + if (try_module_get(ops->owner)) { \ + if (ops->get_##name) \ + retval = ops->get_##name (slot, value); \ + else \ + *value = slot->info->name; \ + module_put(ops->owner); \ + } \ return retval; \ } @@ -665,21 +665,19 @@ static ssize_t power_write_file (struct file *file, const char *ubuff, size_t co case 0: if (!slot->ops->disable_slot) break; - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->disable_slot(slot); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->disable_slot(slot); + module_put(slot->ops->owner); + } break; case 1: if (!slot->ops->enable_slot) break; - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->enable_slot(slot); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->enable_slot(slot); + module_put(slot->ops->owner); + } break; default: @@ -773,11 +771,10 @@ static ssize_t attention_write_file (struct file *file, const char *ubuff, size_ dbg (" - attention = %d\n", attention); if (slot->ops->set_attention_status) { - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->set_attention_status(slot, attention); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->set_attention_status(slot, attention); + module_put(slot->ops->owner); + } } exit: @@ -1011,11 +1008,10 @@ static ssize_t test_write_file (struct file *file, const char *ubuff, size_t cou dbg ("test = %d\n", test); if (slot->ops->hardware_test) { - if (slot->ops->owner) - __MOD_INC_USE_COUNT(slot->ops->owner); - retval = slot->ops->hardware_test(slot, test); - if (slot->ops->owner) - __MOD_DEC_USE_COUNT(slot->ops->owner); + if (try_module_get(slot->ops->owner)) { + retval = slot->ops->hardware_test(slot, test); + module_put(slot->ops->owner); + } } exit: diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 3c07fbefa9bf..0ae396abfcc1 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1336,14 +1336,12 @@ int ata_attach(ide_drive_t *drive) continue; spin_unlock(&drivers_lock); if (driver->attach(drive) == 0) { - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); drive->gendev.driver = &driver->gen_driver; return 0; } spin_lock(&drivers_lock); - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); } spin_unlock(&drivers_lock); spin_lock(&drives_lock); diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index 0b251ee098c1..b5e00b4b12b5 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -1135,28 +1135,19 @@ static int ieee1394_dispatch_open(struct inode *inode, struct file *file) unloading while the file is open, and will be dropped by the VFS when the file is released. */ - - if(THIS_MODULE) - __MOD_DEC_USE_COUNT((struct module*) THIS_MODULE); - - /* note that if ieee1394 is compiled into the kernel, - THIS_MODULE will be (void*) NULL, hence the if and - the cast are necessary */ - + module_put(THIS_MODULE); } else { - - /* if the open() failed, then we need to drop the - extra reference we gave to the task-specific - driver */ - - if(module) - __MOD_DEC_USE_COUNT(module); - /* point the file's f_ops back to ieee1394. The VFS will then decrement ieee1394's reference count immediately after this function returns. */ file->f_op = &ieee1394_chardev_ops; + + /* if the open() failed, then we need to drop the + extra reference we gave to the task-specific + driver */ + module_put(module); + } return retval; diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 949a9497b0b5..337124784e9c 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -91,8 +91,7 @@ capi_ctr_get(struct capi_ctr *card) static inline void capi_ctr_put(struct capi_ctr *card) { - if (card->owner) - __MOD_DEC_USE_COUNT(card->owner); + module_put(card->owner); DBG("MOD_COUNT DEC"); } diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c index 6bf8310ac1e9..886302cbd2b1 100644 --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -44,11 +44,11 @@ static struct tt_internal *get_target_type(const char *name) read_lock(&_lock); ti = __find_target_type(name); - - if (ti) { - if (ti->use == 0 && ti->tt.module) - __MOD_INC_USE_COUNT(ti->tt.module); - ti->use++; + if (ti && ti->use == 0) { + if (try_module_get(ti->tt.module)) + ti->use++; + else + ti = NULL; } read_unlock(&_lock); @@ -86,8 +86,8 @@ void dm_put_target_type(struct target_type *t) struct tt_internal *ti = (struct tt_internal *) t; read_lock(&_lock); - if (--ti->use == 0 && ti->tt.module) - __MOD_DEC_USE_COUNT(ti->tt.module); + if (--ti->use == 0) + module_put(ti->tt.module); if (ti->use < 0) BUG(); diff --git a/drivers/media/dvb/dvb-core/dvb_i2c.c b/drivers/media/dvb/dvb-core/dvb_i2c.c index e9a48ba1af9f..9eefbf4513d1 100644 --- a/drivers/media/dvb/dvb-core/dvb_i2c.c +++ b/drivers/media/dvb/dvb-core/dvb_i2c.c @@ -63,18 +63,11 @@ int register_i2c_client (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) { - if (dev->owner) { - if (!MOD_CAN_QUERY(dev->owner)) - return; - - __MOD_INC_USE_COUNT(dev->owner); - } - - if (dev->attach (i2c) == 0) { - register_i2c_client (i2c, dev); - } else { - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + if (try_module_get(dev->owner)) { + if (dev->attach(i2c) == 0) + register_i2c_client(i2c, dev); + else + module_put(dev->owner); } } @@ -82,10 +75,8 @@ void try_attach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) static void detach_device (struct dvb_i2c_bus *i2c, struct dvb_i2c_device *dev) { - dev->detach (i2c); - - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + dev->detach(i2c); + module_put(dev->owner); } diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 1abef42a5896..bcc26db53c6a 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -3158,8 +3158,7 @@ static int reset_camera(struct cam_data *cam) static void put_cam(struct cpia_camera_ops* ops) { - if (ops->owner) - __MOD_DEC_USE_COUNT(ops->owner); + module_put(ops->owner); } /* ------------------------- V4L interface --------------------- */ diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c index da5512cd14e3..efdd7ee41d34 100644 --- a/drivers/mtd/chips/chipreg.c +++ b/drivers/mtd/chips/chipreg.c @@ -71,15 +71,13 @@ struct mtd_info *do_map_probe(char *name, struct map_info *map) return NULL; ret = drv->probe(map); -#ifdef CONFIG_MODULES + /* We decrease the use count here. It may have been a probe-only module, which is no longer required from this point, having given us a handle on (and increased the use count of) the actual driver code. */ - if(drv->module) - __MOD_DEC_USE_COUNT(drv->module); -#endif + module_put(drv->module); if (ret) return ret; diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index a73fe2c3db70..a27737026547 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c @@ -502,8 +502,7 @@ errout_stop: errout_free: sirdev_free_buffers(dev); errout_dec: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); return -EAGAIN; } @@ -533,11 +532,7 @@ static int sirdev_close(struct net_device *ndev) drv->stop_dev(dev); sirdev_free_buffers(dev); - - lock_kernel(); - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); - unlock_kernel(); + module_put(drv->owner); out: dev->speed = 0; diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c index 6384215dc27e..cf7a17a002d3 100644 --- a/drivers/net/irda/sir_dongle.c +++ b/drivers/net/irda/sir_dongle.c @@ -121,8 +121,7 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type) out_reject: dev->dongle_drv = NULL; - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); out_unlock: up(&dongle_list_lock); return err; @@ -137,9 +136,7 @@ int sirdev_put_dongle(struct sir_dev *dev) drv->close(dev); /* close this dongle instance */ dev->dongle_drv = NULL; /* unlink the dongle driver */ - - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner);/* decrement driver's module refcount */ + module_put(drv->owner);/* decrement driver's module refcount */ } return 0; diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 6f0cfa5c66bc..8eedee623a04 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1757,8 +1757,7 @@ dasd_release(struct inode *inp, struct file *filp) } if (atomic_dec_return(&device->open_count) == 0) { invalidate_buffers(inp->i_rdev); - if (device->discipline->owner) - __MOD_DEC_USE_COUNT(device->discipline->owner); + module_put(device->discipline->owner); } return 0; } diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index def999eb4334..9047d68fb20a 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -115,7 +115,7 @@ dasd_ioctl(struct inode *inp, struct file *filp, if (try_inc_mod_count(ioctl->owner) != 0) continue; rc = ioctl->handler(bdev, no, data); - __MOD_DEC_USE_COUNT(ioctl->owner); + module_put(ioctl->owner); } else rc = ioctl->handler(bdev, no, data); return rc; diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c index 23c48e2e6381..af71fadf2f52 100644 --- a/drivers/s390/char/tape_core.c +++ b/drivers/s390/char/tape_core.c @@ -857,8 +857,7 @@ tape_release(struct tape_device *device) spin_lock(get_ccwdev_lock(device->cdev)); if (device->tape_state == TS_IN_USE) tape_state_set(device, TS_UNUSED); - if (device->discipline->owner) - __MOD_DEC_USE_COUNT(device->discipline->owner); + module_put(device->discipline->owner); spin_unlock(get_ccwdev_lock(device->cdev)); return 0; } diff --git a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c index ffeacdf56718..f8d8fa5adfb6 100644 --- a/drivers/scsi/fcal.c +++ b/drivers/scsi/fcal.c @@ -138,10 +138,14 @@ int __init fcal_detect(Scsi_Host_Template *tpnt) continue; } + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + nfcals++; - if (fc->module) __MOD_INC_USE_COUNT(fc->module); - fcal = (struct fcal *)host->hostdata; fc->fcp_register(fc, TYPE_SCSI_FCP, 0); @@ -193,7 +197,7 @@ int fcal_release(struct Scsi_Host *host) struct fcal *fcal = (struct fcal *)host->hostdata; fc_channel *fc = fcal->fc; - if (fc->module) __MOD_DEC_USE_COUNT(fc->module); + module_put(fc->module); fc->fcp_register(fc, TYPE_SCSI_FCP, 1); FCALND((" releasing fcal.\n")); diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c index 84024bc0adb9..3c3452557f8b 100644 --- a/drivers/scsi/pluto.c +++ b/drivers/scsi/pluto.c @@ -232,10 +232,14 @@ int __init pluto_detect(Scsi_Host_Template *tpnt) continue; } + if (!try_module_get(fc->module)) { + kfree(ages); + scsi_unregister(host); + continue; + } + nplutos++; - if (fc->module) __MOD_INC_USE_COUNT(fc->module); - pluto = (struct pluto *)host->hostdata; host->max_id = inq->targets; diff --git a/drivers/serial/core.c b/drivers/serial/core.c index aacb4225f2e6..4e4c736318bb 100644 --- a/drivers/serial/core.c +++ b/drivers/serial/core.c @@ -1294,8 +1294,7 @@ static void uart_close(struct tty_struct *tty, struct file *filp) wake_up_interruptible(&info->open_wait); done: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); } static void uart_wait_until_sent(struct tty_struct *tty, int timeout) @@ -1665,8 +1664,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) return retval; out: - if (drv->owner) - __MOD_DEC_USE_COUNT(drv->owner); + module_put(drv->owner); fail: return retval; } diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 272b32873d7e..6d3c093afa1d 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -3278,19 +3278,23 @@ request_decompressor(struct usb_ov511 *ov) err("Unknown bridge"); } - if (ov->decomp_ops) { - if (!ov->decomp_ops->owner) { - ov->decomp_ops = NULL; - unlock_kernel(); - return -ENOSYS; - } - __MOD_INC_USE_COUNT(ov->decomp_ops->owner); - unlock_kernel(); - return 0; - } else { - unlock_kernel(); - return -ENOSYS; + if (!ov->decomp_ops) + goto nosys; + + if (!ov->decomp_ops->owner) { + ov->decomp_ops = NULL; + goto nosys; } + + if (!try_module_get(ov->decomp_ops->owner)) + goto nosys; + + unlock_kernel(); + return 0; + + nosys: + unlock_kernel(); + return -ENOSYS; } /* Unlocks decompression module and nulls ov->decomp_ops. Safe to call even @@ -3306,8 +3310,8 @@ release_decompressor(struct usb_ov511 *ov) lock_kernel(); - if (ov->decomp_ops && ov->decomp_ops->owner) { - __MOD_DEC_USE_COUNT(ov->decomp_ops->owner); + if (ov->decomp_ops) { + module_put(ov->decomp_ops->owner); released = 1; } diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index 6620d403ba9c..4c81b621ff76 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -730,6 +730,7 @@ EXPORT_SYMBOL(usbvideo_SayAndWait); /* ******************************************************************** */ +/* XXX: this piece of crap really wants some error handling.. */ static void usbvideo_ClientIncModCount(struct uvd *uvd) { if (uvd == NULL) { @@ -744,7 +745,10 @@ static void usbvideo_ClientIncModCount(struct uvd *uvd) err("%s: uvd->handle->md_module == NULL", __FUNCTION__); return; } - __MOD_INC_USE_COUNT(uvd->handle->md_module); + if (!try_module_get(uvd->handle->md_module)) { + err("%s: try_module_get() == 0", __FUNCTION__); + return; + } } static void usbvideo_ClientDecModCount(struct uvd *uvd) @@ -761,7 +765,7 @@ static void usbvideo_ClientDecModCount(struct uvd *uvd) err("%s: uvd->handle->md_module == NULL", __FUNCTION__); return; } - __MOD_DEC_USE_COUNT(uvd->handle->md_module); + module_put(uvd->handle->md_module); } int usbvideo_register( diff --git a/include/linux/mtd/map.h b/include/linux/mtd/map.h index 94ffed22315b..ad8dfcbda17d 100644 --- a/include/linux/mtd/map.h +++ b/include/linux/mtd/map.h @@ -81,10 +81,7 @@ static inline void map_destroy(struct mtd_info *mtd) if (map->fldrv->destroy) map->fldrv->destroy(mtd); -#ifdef CONFIG_MODULES - if (map->fldrv->module) - __MOD_DEC_USE_COUNT(map->fldrv->module); -#endif + module_put(map->fldrv->module); kfree(mtd); } diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index ae5bfe3e10fb..52d38241e91e 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -224,8 +224,7 @@ static inline struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) static inline void put_mtd_device(struct mtd_info *mtd) { - if (mtd->module) - __MOD_DEC_USE_COUNT(mtd->module); + module_put(mtd->module); } diff --git a/net/core/dev.c b/net/core/dev.c index e48cb774fe0f..97e772ff5f82 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -703,8 +703,7 @@ int dev_open(struct net_device *dev) ret = dev->open(dev); if (ret) { clear_bit(__LINK_STATE_START, &dev->state); - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); + module_put(dev->owner); } } } else { @@ -829,16 +828,14 @@ int dev_close(struct net_device *dev) #endif /* - * Tell people we are down + * Tell people we are down */ notifier_call_chain(&netdev_chain, NETDEV_DOWN, dev); /* * Drop the module refcount */ - if (dev->owner) - __MOD_DEC_USE_COUNT(dev->owner); - + module_put(dev->owner); return 0; } diff --git a/net/ipv4/xfrm_policy.c b/net/ipv4/xfrm_policy.c index d21d597e7be1..fe30556f78d6 100644 --- a/net/ipv4/xfrm_policy.c +++ b/net/ipv4/xfrm_policy.c @@ -200,8 +200,7 @@ struct xfrm_type *xfrm_get_type(u8 proto) void xfrm_put_type(struct xfrm_type *type) { - if (type->owner) - __MOD_DEC_USE_COUNT(type->owner); + module_put(type->owner); } static inline unsigned long make_jiffies(long secs) diff --git a/net/rxrpc/call.c b/net/rxrpc/call.c index 6bba546eece7..a0e81b58191d 100644 --- a/net/rxrpc/call.c +++ b/net/rxrpc/call.c @@ -435,7 +435,7 @@ void rxrpc_put_call(struct rxrpc_call *call) rxrpc_put_message(msg); } - if (call->owner) __MOD_DEC_USE_COUNT(call->owner); + module_put(call->owner); down_write(&rxrpc_calls_sem); list_del(&call->call_link); diff --git a/sound/core/control.c b/sound/core/control.c index 6dce340429ff..7de5256c19fc 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -40,12 +40,6 @@ typedef struct _snd_kctl_ioctl { static DECLARE_RWSEM(snd_ioctl_rwsem); static LIST_HEAD(snd_control_ioctls); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int snd_ctl_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_CARD(minor(inode->i_rdev)); @@ -88,7 +82,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) return 0; __error: - dec_mod_count(card->module); + module_put(card->module); __error2: snd_card_file_remove(card, file); __error1: @@ -135,7 +129,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file) up_write(&card->controls_rwsem); snd_ctl_empty_read_queue(ctl); snd_magic_kfree(ctl); - dec_mod_count(card->module); + module_put(card->module); snd_card_file_remove(card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/info.c b/sound/core/info.c index 808f46456976..0ae2541810a6 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -36,12 +36,6 @@ * */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_info_check_reserved_words(const char *str) { static char *reserved[] = @@ -407,7 +401,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) return 0; __error: - dec_mod_count(entry->module); + module_put(entry->module); __error1: #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; @@ -450,7 +444,7 @@ static int snd_info_entry_release(struct inode *inode, struct file *file) data->file_private_data); break; } - dec_mod_count(entry->module); + module_put(entry->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 0d6aecd9016c..088bf5ea33c1 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -34,12 +34,6 @@ MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Mixer OSS emulation for ALSA."); MODULE_LICENSE("GPL"); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int snd_mixer_oss_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_OSS_CARD(minor(inode->i_rdev)); @@ -82,7 +76,7 @@ static int snd_mixer_oss_release(struct inode *inode, struct file *file) if (file->private_data) { fmixer = (snd_mixer_oss_file_t *) file->private_data; - dec_mod_count(fmixer->card->module); + module_put(fmixer->card->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index c6e18a7e0d0a..4febec2769c2 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -71,12 +71,6 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_pcm_oss_plugin_clear(snd_pcm_substream_t *substream) { snd_pcm_runtime_t *runtime = substream->runtime; @@ -1617,7 +1611,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) return err; __error: - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); __error2: snd_card_file_remove(pcm->card, file); __error1: @@ -1644,7 +1638,7 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) snd_pcm_oss_release_file(pcm_oss_file); up(&pcm->open_mutex); wake_up(&pcm->open_wait); - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 773d3a10c567..57f2a9c0f4a2 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -76,14 +76,6 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - - - int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info) { snd_pcm_runtime_t * runtime; @@ -1833,7 +1825,7 @@ int snd_pcm_open(struct inode *inode, struct file *file) return err; __error: - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); __error2: snd_card_file_remove(pcm->card, file); __error1: @@ -1863,7 +1855,7 @@ int snd_pcm_release(struct inode *inode, struct file *file) snd_pcm_release_file(pcm_file); up(&pcm->open_mutex); wake_up(&pcm->open_wait); - dec_mod_count(pcm->card->module); + module_put(pcm->card->module); snd_card_file_remove(pcm->card, file); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 18dc962f094d..a03924780f93 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -58,12 +58,6 @@ snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; static DECLARE_MUTEX(register_mutex); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static inline unsigned short snd_rawmidi_file_flags(struct file *file) { switch (file->f_mode & (FMODE_READ | FMODE_WRITE)) { @@ -345,7 +339,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, snd_rawmidi_done_buffer(output); kfree(output); } - dec_mod_count(rmidi->card->module); + module_put(rmidi->card->module); up(&rmidi->open_mutex); __error1: #ifdef LINUX_2_2 @@ -504,7 +498,7 @@ int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substream_opened--; } up(&rmidi->open_mutex); - dec_mod_count(rmidi->card->module); + module_put(rmidi->card->module); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; #endif diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 9cc61a3cd426..837ef15abb69 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -83,12 +83,6 @@ static spinlock_t register_lock = SPIN_LOCK_UNLOCKED; static seq_oss_synth_t *get_synthdev(seq_oss_devinfo_t *dp, int dev); static void reset_channels(seq_oss_synthinfo_t *info); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * global initialization */ @@ -245,7 +239,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) continue; } if (rec->oper.open(&info->arg, rec->private_data) < 0) { - dec_mod_count(rec->oper.owner); + module_put(rec->oper.owner); snd_use_lock_free(&rec->use_lock); continue; } @@ -322,7 +316,7 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp) if (rec->opened) { debug_printk(("synth %d closed\n", i)); rec->oper.close(&info->arg); - dec_mod_count(rec->oper.owner); + module_put(rec->oper.owner); rec->opened--; } snd_use_lock_free(&rec->use_lock); diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 8f5d7ed2b4d8..14943f8fecb8 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -55,12 +55,6 @@ much elements are in array. */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* return pointer to port structure - port is locked if found */ client_port_t *snd_seq_port_use_ptr(client_t *client, int num) { @@ -413,7 +407,7 @@ static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_ if (grp->open && (port->callback_all || grp->count == 1)) { err = grp->open(port->private_data, info); if (err < 0) { - dec_mod_count(port->owner); + module_put(port->owner); grp->count--; } } @@ -438,7 +432,7 @@ static int unsubscribe_port(client_t *client, client_port_t *port, if (send_ack && client->type == USER_CLIENT) snd_seq_client_notify_subscription(port->addr.client, port->addr.port, info, SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED); - dec_mod_count(port->owner); + module_put(port->owner); return err; } diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index d4fcb6aa085c..0719b6ad0ee8 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -53,12 +53,6 @@ MODULE_AUTHOR("Takashi Iwai "); MODULE_DESCRIPTION("Virtual Raw MIDI client on Sequencer"); MODULE_LICENSE("GPL"); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * initialize an event record */ @@ -303,7 +297,7 @@ static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE; - dec_mod_count(rdev->card->module); + module_put(rdev->card->module); return 0; } @@ -331,7 +325,7 @@ static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); rdev->flags &= ~SNDRV_VIRMIDI_USE; - dec_mod_count(rdev->card->module); + module_put(rdev->card->module); return 0; } diff --git a/sound/core/timer.c b/sound/core/timer.c index e16dfdda8a95..1b571b00728d 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -80,12 +80,6 @@ static int snd_timer_dev_unregister(snd_device_t *device); static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * create a timer instance with the given owner string. * when timer is not NULL, increments the module counter @@ -325,7 +319,7 @@ int snd_timer_close(snd_timer_instance_t * timeri) kfree(timeri->owner); kfree(timeri); if (timer && timer->card) - dec_mod_count(timer->card->module); + module_put(timer->card->module); return 0; } diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 2651522d72e5..c622456c6136 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -35,12 +35,6 @@ int use_internal_drums = 0; MODULE_PARM(use_internal_drums, "i"); MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_opl3_synth_use_inc(opl3_t * opl3) { if (!try_inc_mod_count(opl3->card->module)) @@ -51,7 +45,7 @@ int snd_opl3_synth_use_inc(opl3_t * opl3) void snd_opl3_synth_use_dec(opl3_t * opl3) { - dec_mod_count(opl3->card->module); + module_put(opl3->card->module); } int snd_opl3_synth_setup(opl3_t * opl3) diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 04fa4a649ab6..a3473afd0118 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -39,12 +39,6 @@ MODULE_LICENSE("GPL"); static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - int snd_gus_use_inc(snd_gus_card_t * gus) { MOD_INC_USE_COUNT; @@ -57,7 +51,7 @@ int snd_gus_use_inc(snd_gus_card_t * gus) void snd_gus_use_dec(snd_gus_card_t * gus) { - dec_mod_count(gus->card->module); + module_put(gus->card->module); MOD_DEC_USE_COUNT; } diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 75aaca8a9fb9..817b6d807a86 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -33,13 +33,6 @@ #define FX_MSB_TRANSFER 0x02 /* transfer after DSP MSB byte written */ #define FX_AUTO_INCR 0x04 /* auto-increment DSP address after transfer */ -static inline void -dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static int wavefront_fx_idle (snd_wavefront_t *dev) @@ -164,7 +157,7 @@ int snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) { - dec_mod_count(hw->card->module); + module_put(hw->card->module); MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 5f0058dc08ca..f3e26ef9473f 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -233,13 +233,6 @@ static wavefront_command wavefront_commands[] = { { 0x00 } }; -static inline void -dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - static const char * wavefront_errorstr (int errnum) @@ -1623,7 +1616,7 @@ int snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) { - dec_mod_count(hw->card->module); + module_put(hw->card->module); MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/oss/audio.c b/sound/oss/audio.c index 74e3c282c14f..91101d990e49 100644 --- a/sound/oss/audio.c +++ b/sound/oss/audio.c @@ -88,19 +88,20 @@ int audio_open(int dev, struct file *file) return -ENXIO; driver = audio_devs[dev]->d; - if (driver->owner) - __MOD_INC_USE_COUNT(driver->owner); + + if (!try_module_get(driver->owner)) + return -ENODEV; if ((ret = DMAbuf_open(dev, mode)) < 0) goto error_1; if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) + goto error_2; if ((ret = coprocessor->open(coprocessor->devc, COPR_PCM)) < 0) { printk(KERN_WARNING "Sound: Can't access coprocessor device\n"); - goto error_2; + goto error_3; } } @@ -119,14 +120,14 @@ int audio_open(int dev, struct file *file) * Clean-up stack: this is what needs (un)doing if * we can't open the audio device ... */ + error_3: + module_put(coprocessor->owner); + error_2: - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); DMAbuf_release(dev, mode); error_1: - if (driver->owner) - __MOD_DEC_USE_COUNT(driver->owner); + module_put(driver->owner); return ret; } @@ -200,14 +201,11 @@ void audio_release(int dev, struct file *file) if ( (coprocessor = audio_devs[dev]->coproc) != NULL ) { coprocessor->close(coprocessor->devc, COPR_PCM); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } DMAbuf_release(dev, mode); - if (audio_devs[dev]->d->owner) - __MOD_DEC_USE_COUNT (audio_devs[dev]->d->owner); + module_put(audio_devs[dev]->d->owner); } static void translate_bytes(const unsigned char *table, unsigned char *buff, int n) diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c index 58b330ecad1f..30f8c7f67971 100644 --- a/sound/oss/midibuf.c +++ b/sound/oss/midibuf.c @@ -170,8 +170,7 @@ int MIDIbuf_open(int dev, struct file *file) * Interrupts disabled. Be careful */ - if (midi_devs[dev]->owner) - __MOD_INC_USE_COUNT (midi_devs[dev]->owner); + module_put(midi_devs[dev]->owner); if ((err = midi_devs[dev]->open(dev, mode, midi_input_intr, midi_output_intr)) < 0) @@ -254,8 +253,7 @@ void MIDIbuf_release(int dev, struct file *file) midi_in_buf[dev] = NULL; midi_out_buf[dev] = NULL; - if (midi_devs[dev]->owner) - __MOD_DEC_USE_COUNT (midi_devs[dev]->owner); + module_put(midi_devs[dev]->owner); } int MIDIbuf_write(int dev, struct file *file, const char *buf, int count) diff --git a/sound/oss/mpu401.c b/sound/oss/mpu401.c index a8817a2d8d02..c8d9d59ef915 100644 --- a/sound/oss/mpu401.c +++ b/sound/oss/mpu401.c @@ -498,8 +498,10 @@ static int mpu401_open(int dev, int mode, if ( (coprocessor = midi_devs[dev]->coproc) != NULL ) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) { + mpu401_close(dev); + return err; + } if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) { @@ -537,9 +539,7 @@ static void mpu401_close(int dev) coprocessor = midi_devs[dev]->coproc; if (coprocessor) { coprocessor->close(coprocessor->devc, COPR_MIDI); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } devc->opened = 0; } @@ -838,8 +838,8 @@ static int mpu_synth_open(int dev, int mode) coprocessor = midi_devs[midi_dev]->coproc; if (coprocessor) { - if (coprocessor->owner) - __MOD_INC_USE_COUNT(coprocessor->owner); + if (!try_module_get(coprocessor->owner)) + return err; if ((err = coprocessor->open(coprocessor->devc, COPR_MIDI)) < 0) { @@ -876,9 +876,7 @@ static void mpu_synth_close(int dev) coprocessor = midi_devs[midi_dev]->coproc; if (coprocessor) { coprocessor->close(coprocessor->devc, COPR_MIDI); - - if (coprocessor->owner) - __MOD_DEC_USE_COUNT(coprocessor->owner); + module_put(coprocessor->owner); } devc->opened = 0; devc->mode = 0; diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c index 860e21734e9e..8a2f0055f1ac 100644 --- a/sound/oss/sequencer.c +++ b/sound/oss/sequencer.c @@ -1041,8 +1041,8 @@ int sequencer_open(int dev, struct file *file) if (synth_devs[i]==NULL) continue; - if (synth_devs[i]->owner) - __MOD_INC_USE_COUNT (synth_devs[i]->owner); + if (!try_module_get(synth_devs[i]->owner)) + continue; if ((tmp = synth_devs[i]->open(i, mode)) < 0) { @@ -1072,8 +1072,8 @@ int sequencer_open(int dev, struct file *file) for (i = 0; i < max_mididev; i++) if (!midi_opened[i] && midi_devs[i]) { - if (midi_devs[i]->owner) - __MOD_INC_USE_COUNT (midi_devs[i]->owner); + if (!try_module_get(midi_devs[i]->owner)) + continue; if ((retval = midi_devs[i]->open(i, mode, sequencer_midi_input, sequencer_midi_output)) >= 0) @@ -1084,9 +1084,8 @@ int sequencer_open(int dev, struct file *file) } if (seq_mode == SEQ_2) { - if (tmr->owner) - __MOD_INC_USE_COUNT (tmr->owner); - tmr->open(tmr_no, seq_mode); + if (try_module_get(tmr->owner)) + tmr->open(tmr_no, seq_mode); } init_waitqueue_head(&seq_sleeper); @@ -1169,8 +1168,7 @@ void sequencer_release(int dev, struct file *file) { synth_devs[i]->close(i); - if (synth_devs[i]->owner) - __MOD_DEC_USE_COUNT (synth_devs[i]->owner); + module_put(synth_devs[i]->owner); if (synth_devs[i]->midi_dev) midi_opened[synth_devs[i]->midi_dev] = 0; @@ -1181,15 +1179,13 @@ void sequencer_release(int dev, struct file *file) { if (midi_opened[i]) { midi_devs[i]->close(i); - if (midi_devs[i]->owner) - __MOD_DEC_USE_COUNT (midi_devs[i]->owner); + module_put(midi_devs[i]->owner); } } if (seq_mode == SEQ_2) { tmr->close(tmr_no); - if (tmr->owner) - __MOD_DEC_USE_COUNT (tmr->owner); + module_put(tmr->owner); } if (obsolete_api_used) diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index 4d29d0ec11a5..89988a1b3814 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c @@ -222,9 +222,9 @@ static int sound_open(struct inode *inode, struct file *file) } if (dev && (dev >= num_mixers || mixer_devs[dev] == NULL)) return -ENXIO; - - if (mixer_devs[dev]->owner) - __MOD_INC_USE_COUNT (mixer_devs[dev]->owner); + + if (!try_module_get(mixer_devs[dev]->owner)) + return -ENXIO; break; case SND_DEV_SEQ: @@ -261,9 +261,7 @@ static int sound_release(struct inode *inode, struct file *file) DEB(printk("sound_release(dev=%d)\n", dev)); switch (dev & 0x0f) { case SND_DEV_CTL: - dev >>= 4; - if (mixer_devs[dev]->owner) - __MOD_DEC_USE_COUNT (mixer_devs[dev]->owner); + module_put(mixer_devs[dev >> 4]->owner); break; case SND_DEV_SEQ: diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 3175511d87f9..0dd6ef8c376c 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -61,12 +61,6 @@ static snd_midi_op_t emux_ops = { /* */ -static inline void dec_mod_count(struct module *module) -{ - if (module) - __MOD_DEC_USE_COUNT(module); -} - /* * Initialise the EMUX Synth by creating a client and registering * a series of ports. @@ -283,7 +277,7 @@ snd_emux_inc_count(snd_emux_t *emu) if (!try_inc_mod_count(emu->ops.owner)) goto __error; if (!try_inc_mod_count(emu->card->module)) { - dec_mod_count(emu->ops.owner); + module_put(emu->ops.owner); __error: emu->used--; return 0; @@ -298,11 +292,11 @@ snd_emux_inc_count(snd_emux_t *emu) void snd_emux_dec_count(snd_emux_t *emu) { - dec_mod_count(emu->ops.owner); + module_put(emu->ops.owner); emu->used--; if (emu->used <= 0) snd_emux_terminate_all(emu); - dec_mod_count(emu->card->module); + module_put(emu->card->module); } -- cgit v1.2.3 From 9ac2ca130e03b8f7f1d104c754b8f6c7108e8429 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 29 Dec 2002 07:21:18 -0800 Subject: TTY: Change tty_*register_devfs() to tty_*register_device() Also got rid of the unused flag paramater. --- arch/mips/au1000/common/serial.c | 12 ++++++------ drivers/char/dz.c | 4 ++-- drivers/char/hvc_console.c | 2 +- drivers/char/ip2main.c | 8 ++++---- drivers/char/pty.c | 3 ++- drivers/char/tty_io.c | 26 ++++++++++++++++++-------- drivers/char/vt.c | 2 +- drivers/serial/core.c | 4 ++-- drivers/tc/zs.c | 4 ++-- drivers/usb/class/bluetty.c | 4 ++-- drivers/usb/class/cdc-acm.c | 6 +++--- drivers/usb/serial/bus.c | 4 ++-- include/linux/tty.h | 5 ++--- 13 files changed, 47 insertions(+), 37 deletions(-) (limited to 'include/linux') diff --git a/arch/mips/au1000/common/serial.c b/arch/mips/au1000/common/serial.c index c9540cb700f3..52438fc03f93 100644 --- a/arch/mips/au1000/common/serial.c +++ b/arch/mips/au1000/common/serial.c @@ -2682,9 +2682,9 @@ static int __init rs_init(void) (state->flags & ASYNC_FOURPORT) ? " FourPort" : "", state->port, state->irq, uart_config[state->type].name); - tty_register_devfs(&serial_driver, 0, + tty_register_device(&serial_driver, serial_driver.minor_start + state->line); - tty_register_devfs(&callout_driver, 0, + tty_register_device(&callout_driver, callout_driver.minor_start + state->line); } return 0; @@ -2772,9 +2772,9 @@ int register_serial(struct serial_struct *req) state->iomem_base ? "iomem" : "port", state->iomem_base ? (unsigned long)state->iomem_base : state->port, state->irq, uart_config[state->type].name); - tty_register_devfs(&serial_driver, 0, + tty_register_device(&serial_driver, serial_driver.minor_start + state->line); - tty_register_devfs(&callout_driver, 0, + tty_register_device(&callout_driver, callout_driver.minor_start + state->line); return state->line + SERIAL_DEV_OFFSET; } @@ -2801,9 +2801,9 @@ void unregister_serial(int line) /* These will be hidden, because they are devices that will no longer * be available to the system. (ie, PCMCIA modems, once ejected) */ - tty_unregister_devfs(&serial_driver, + tty_unregister_device(&serial_driver, serial_driver.minor_start + state->line); - tty_unregister_devfs(&callout_driver, + tty_unregister_device(&callout_driver, callout_driver.minor_start + state->line); restore_flags(flags); } diff --git a/drivers/char/dz.c b/drivers/char/dz.c index f67afe1e21ba..db281901522d 100644 --- a/drivers/char/dz.c +++ b/drivers/char/dz.c @@ -1425,9 +1425,9 @@ int __init dz_init(void) printk("ttyS%02d at 0x%08x (irq = %d)\n", info->line, info->port, SERIAL); - tty_register_devfs(&serial_driver, 0, + tty_register_device(&serial_driver, serial_driver.minor_start + info->line); - tty_register_devfs(&callout_driver, 0, + tty_register_device(&callout_driver, callout_driver.minor_start + info->line); } diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 7b9b42bc2729..b3fe12431691 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -279,7 +279,7 @@ int __init hvc_init(void) for (i = 0; i < hvc_driver.num; i++) { hvc_struct[i].lock = SPIN_LOCK_UNLOCKED; hvc_struct[i].index = i; - tty_register_devfs(&hvc_driver, 0, hvc_driver.minor_start + i); + tty_register_device(&hvc_driver, hvc_driver.minor_start + i); } if (tty_register_driver(&hvc_driver)) diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index c43a7f6e569b..1fbc0eb7fb79 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -899,11 +899,11 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) { if ( pB->i2eChannelMap[box] & (1 << j) ) { - tty_register_devfs(&ip2_tty_driver, - 0, j + ABS_BIGGEST_BOX * + tty_register_device(&ip2_tty_driver, + j + ABS_BIGGEST_BOX * (box+i*ABS_MAX_BOXES)); - tty_register_devfs(&ip2_callout_driver, - 0, j + ABS_BIGGEST_BOX * + tty_register_device(&ip2_callout_driver, + j + ABS_BIGGEST_BOX * (box+i*ABS_MAX_BOXES)); } } diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 9ae96fac0835..b2bf8a1338bd 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -97,7 +97,7 @@ static void pty_close(struct tty_struct * tty, struct file * filp) } } #endif - tty_unregister_devfs (&tty->link->driver, minor(tty->device)); + tty_unregister_device (&tty->link->driver, minor(tty->device)); tty_vhangup(tty->link); } } @@ -307,6 +307,7 @@ static void pty_flush_buffer(struct tty_struct *tty) } } +extern void tty_register_devfs (struct tty_driver *driver, unsigned int flags, unsigned minor); static int pty_open(struct tty_struct *tty, struct file * filp) { int retval; diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 4d94c4de5c46..0c9117be9851 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -1351,7 +1351,7 @@ retry_open: set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ minor -= driver->minor_start; devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start)); - tty_register_devfs(&pts_driver[major], DEVFS_FL_DEFAULT, + tty_register_device(&pts_driver[major], pts_driver[major].minor_start + minor); noctty = 1; goto init_dev_done; @@ -2038,9 +2038,6 @@ void tty_default_put_char(struct tty_struct *tty, unsigned char ch) tty->driver.write(tty, 0, &ch, 1); } -/* - * Register a tty device described by , with minor number . - */ void tty_register_devfs (struct tty_driver *driver, unsigned int flags, unsigned minor) { #ifdef CONFIG_DEVFS_FS @@ -2077,8 +2074,21 @@ void tty_unregister_devfs (struct tty_driver *driver, unsigned minor) devfs_remove(driver->name, minor-driver->minor_start+driver->name_base); } -EXPORT_SYMBOL(tty_register_devfs); -EXPORT_SYMBOL(tty_unregister_devfs); +/* + * Register a tty device described by , with minor number . + */ +void tty_register_device (struct tty_driver *driver, unsigned minor) +{ + tty_register_devfs(driver, 0, minor); +} + +void tty_unregister_device (struct tty_driver *driver, unsigned minor) +{ + tty_unregister_devfs(driver, minor); +} + +EXPORT_SYMBOL(tty_register_device); +EXPORT_SYMBOL(tty_unregister_device); /* * Called by a tty driver to register itself. @@ -2104,7 +2114,7 @@ int tty_register_driver(struct tty_driver *driver) if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) { for(i = 0; i < driver->num; i++) - tty_register_devfs(driver, 0, driver->minor_start + i); + tty_register_device(driver, driver->minor_start + i); } proc_tty_register_driver(driver); return error; @@ -2159,7 +2169,7 @@ int tty_unregister_driver(struct tty_driver *driver) driver->termios_locked[i] = NULL; kfree(tp); } - tty_unregister_devfs(driver, driver->minor_start + i); + tty_unregister_device(driver, driver->minor_start + i); } proc_tty_unregister_driver(driver); return 0; diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 0be0bd218bfc..0920a11c3683 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -2646,7 +2646,7 @@ static void __init con_init_devfs (void) int i; for (i = 0; i < console_driver.num; i++) - tty_register_devfs (&console_driver, DEVFS_FL_DEFAULT, + tty_register_device (&console_driver, console_driver.minor_start + i); } diff --git a/drivers/serial/core.c b/drivers/serial/core.c index 4e6c1a543e55..5e0fb6f793d7 100644 --- a/drivers/serial/core.c +++ b/drivers/serial/core.c @@ -2098,7 +2098,7 @@ __uart_register_port(struct uart_driver *drv, struct uart_state *state, * Register the port whether it's detected or not. This allows * setserial to be used to alter this ports parameters. */ - tty_register_devfs(drv->tty_driver, 0, drv->minor + port->line); + tty_register_device(drv->tty_driver, drv->minor + port->line); if (port->type != PORT_UNKNOWN) { unsigned long flags; @@ -2155,7 +2155,7 @@ __uart_unregister_port(struct uart_driver *drv, struct uart_state *state) /* * Remove the devices from devfs */ - tty_unregister_devfs(drv->tty_driver, drv->minor + port->line); + tty_unregister_device(drv->tty_driver, drv->minor + port->line); /* * Free the port IO and memory resources, if any. diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 70b494f4df48..6ffa6a963d3a 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c @@ -1971,9 +1971,9 @@ int __init zs_init(void) printk("ttyS%02d at 0x%08x (irq = %d)", info->line, info->port, info->irq); printk(" is a Z85C30 SCC\n"); - tty_register_devfs(&serial_driver, 0, + tty_register_device(&serial_driver, serial_driver.minor_start + info->line); - tty_register_devfs(&callout_driver, 0, + tty_register_device(&callout_driver, callout_driver.minor_start + info->line); } diff --git a/drivers/usb/class/bluetty.c b/drivers/usb/class/bluetty.c index 634efc509023..5572408d67e6 100644 --- a/drivers/usb/class/bluetty.c +++ b/drivers/usb/class/bluetty.c @@ -1201,7 +1201,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf, bluetooth, endpoint->bInterval); /* initialize the devfs nodes for this device and let the user know what bluetooths we are bound to */ - tty_register_devfs (&bluetooth_tty_driver, 0, minor); + tty_register_device (&bluetooth_tty_driver, minor); info("Bluetooth converter now attached to ttyUB%d (or usb/ttub/%d for devfs)", minor, minor); bluetooth_table[minor] = bluetooth; @@ -1267,7 +1267,7 @@ static void usb_bluetooth_disconnect(struct usb_interface *intf) if (bluetooth->interrupt_in_buffer) kfree (bluetooth->interrupt_in_buffer); - tty_unregister_devfs (&bluetooth_tty_driver, bluetooth->minor); + tty_unregister_device (&bluetooth_tty_driver, bluetooth->minor); for (i = 0; i < NUM_BULK_URBS; ++i) { if (bluetooth->write_urb_pool[i]) { diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 9729e3618d42..48651649cde4 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -361,7 +361,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) usb_unlink_urb(acm->writeurb); usb_unlink_urb(acm->readurb); } else { - tty_unregister_devfs(&acm_tty_driver, acm->minor); + tty_unregister_device(&acm_tty_driver, acm->minor); acm_table[acm->minor] = NULL; usb_free_urb(acm->ctrlurb); usb_free_urb(acm->readurb); @@ -649,7 +649,7 @@ static int acm_probe (struct usb_interface *intf, usb_driver_claim_interface(&acm_driver, acm->iface + 0, acm); usb_driver_claim_interface(&acm_driver, acm->iface + 1, acm); - tty_register_devfs(&acm_tty_driver, 0, minor); + tty_register_device(&acm_tty_driver, minor); acm_table[minor] = acm; dev_set_drvdata (&intf->dev, acm); @@ -681,7 +681,7 @@ static void acm_disconnect(struct usb_interface *intf) usb_driver_release_interface(&acm_driver, acm->iface + 1); if (!acm->used) { - tty_unregister_devfs(&acm_tty_driver, acm->minor); + tty_unregister_device(&acm_tty_driver, acm->minor); acm_table[acm->minor] = NULL; usb_free_urb(acm->ctrlurb); usb_free_urb(acm->readurb); diff --git a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c index 3d99da8441d5..6994566513f0 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c @@ -78,7 +78,7 @@ static int usb_serial_device_probe (struct device *dev) minor = port->number; - tty_register_devfs (&usb_serial_tty_driver, 0, minor); + tty_register_device (&usb_serial_tty_driver, minor); info("%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)", driver->name, minor, minor); @@ -110,7 +110,7 @@ static int usb_serial_device_remove (struct device *dev) } exit: minor = port->number; - tty_unregister_devfs (&usb_serial_tty_driver, minor); + tty_unregister_device (&usb_serial_tty_driver, minor); info("%s converter now disconnected from ttyUSB%d", driver->name, minor); diff --git a/include/linux/tty.h b/include/linux/tty.h index 11b82d2c98ae..ad3149de8631 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -379,9 +379,8 @@ extern void start_tty(struct tty_struct * tty); extern int tty_register_ldisc(int disc, struct tty_ldisc *new_ldisc); extern int tty_register_driver(struct tty_driver *driver); extern int tty_unregister_driver(struct tty_driver *driver); -extern void tty_register_devfs (struct tty_driver *driver, unsigned int flags, - unsigned minor); -extern void tty_unregister_devfs (struct tty_driver *driver, unsigned minor); +extern void tty_register_device(struct tty_driver *driver, unsigned minor); +extern void tty_unregister_device(struct tty_driver *driver, unsigned minor); extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, int buflen); extern void tty_write_message(struct tty_struct *tty, char *msg); -- cgit v1.2.3 From 6c95cbe9c9479627faaf5156d8c348e3ab03ae31 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 29 Dec 2002 07:34:36 -0800 Subject: TTY: add tty_devclass to the tty core. --- drivers/char/tty_io.c | 8 ++++++++ include/linux/tty_driver.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'include/linux') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 0c9117be9851..240c470a4c24 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -90,6 +90,7 @@ #include #include #include +#include #include #include @@ -2271,12 +2272,19 @@ static struct tty_driver dev_console_driver; extern int vty_init(void); #endif +struct device_class tty_devclass = { + .name = "tty", +}; +EXPORT_SYMBOL(tty_devclass); + /* * Ok, now we can initialize the rest of the tty devices and can count * on memory allocations, interrupts etc.. */ void __init tty_init(void) { + devclass_register(&tty_devclass); + /* * dev_tty_driver and dev_console_driver are actually magic * devices which get redirected at open time. Nevertheless, diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 806216e30a26..ad5638bbd4ed 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h @@ -227,4 +227,6 @@ extern struct list_head tty_drivers; #define SERIAL_TYPE_NORMAL 1 #define SERIAL_TYPE_CALLOUT 2 +extern struct device_class tty_devclass; + #endif /* #ifdef _LINUX_TTY_DRIVER_H */ -- cgit v1.2.3 From ae52cf5c50c291b5733aceffe8d1ce2e7c7a4d8d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 29 Dec 2002 18:59:13 -0800 Subject: [PATCH] Minor compile fix for some modules. Expose declaration of __this_module outside #ifdef KBUILD_MODNAME (which is not defined for objects included in two modules). --- include/linux/module.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/module.h b/include/linux/module.h index 3a411c8c6575..ebdfc27efbb8 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -285,7 +285,9 @@ static inline const char *module_address_lookup(unsigned long addr, } #endif /* CONFIG_MODULES */ -#if defined(MODULE) && defined(KBUILD_MODNAME) +#ifdef MODULE +extern struct module __this_module; +#ifdef KBUILD_MODNAME /* We make the linker do some of the work. */ struct module __this_module __attribute__((section(".gnu.linkonce.this_module"))) = { @@ -296,7 +298,8 @@ __attribute__((section(".gnu.linkonce.this_module"))) = { .exit = cleanup_module, #endif }; -#endif /* MODULE && KBUILD_MODNAME */ +#endif /* KBUILD_MODNAME */ +#endif /* MODULE */ /* For archs to search exception tables */ extern struct list_head extables; -- cgit v1.2.3 From 84fed9daa3606f2409e480e04096e856a5792649 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 19:50:56 -0800 Subject: [PATCH] fix i2c module handling Add a struct module *owner field to struct i2c_adapter and i2c_algorithm and do refcouting on them before use instead of the inc_use and dec_use callbacks. While at it convert those structures to named initializers. --- drivers/i2c/busses/i2c-amd756.c | 14 +-------- drivers/i2c/busses/i2c-amd8111.c | 13 +-------- drivers/i2c/chips/adm1021.c | 30 ++++++------------- drivers/i2c/chips/lm75.c | 45 ++++++----------------------- drivers/i2c/i2c-adap-ite.c | 41 +++----------------------- drivers/i2c/i2c-algo-bit.c | 20 ++++--------- drivers/i2c/i2c-algo-pcf.c | 14 +-------- drivers/i2c/i2c-core.c | 47 +++++++++++++++--------------- drivers/i2c/i2c-dev.c | 11 ++++--- drivers/i2c/i2c-elektor.c | 33 ++------------------- drivers/i2c/i2c-elv.c | 36 +++-------------------- drivers/i2c/i2c-frodo.c | 29 ++----------------- drivers/i2c/i2c-philips-par.c | 32 ++------------------- drivers/i2c/i2c-proc.c | 43 --------------------------- drivers/i2c/i2c-rpx.c | 37 +++--------------------- drivers/i2c/i2c-velleman.c | 48 ++++++------------------------- drivers/i2c/scx200_acb.c | 25 +--------------- drivers/i2c/scx200_i2c.c | 25 +--------------- drivers/media/video/adv7175.c | 17 ++--------- drivers/media/video/bttv-if.c | 13 +-------- drivers/media/video/saa7134/saa7134-i2c.c | 13 +-------- drivers/media/video/tvmixer.c | 8 +++--- drivers/video/matrox/i2c-matroxfb.c | 11 +------ drivers/video/matrox/matroxfb_maven.c | 28 +++++------------- include/linux/i2c.h | 24 ++-------------- 25 files changed, 102 insertions(+), 555 deletions(-) (limited to 'include/linux') diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index aba96ef80719..b2627572924e 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -296,17 +296,6 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr, return 0; } -static void amd756_inc(struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -static void amd756_dec(struct i2c_adapter *adapter) -{ - - MOD_DEC_USE_COUNT; -} - static u32 amd756_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | @@ -322,11 +311,10 @@ static struct i2c_algorithm smbus_algorithm = { }; static struct i2c_adapter amd756_adapter = { + .owner = THIS_MODULE, .name = "unset", .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756, .algo = &smbus_algorithm, - .inc_use = amd756_inc, - .dec_use = amd756_dec, }; enum chiptype { AMD756, AMD766, AMD768, NFORCE }; diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index ac2f741d3843..eff6dd081745 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c @@ -320,16 +320,6 @@ s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, return 0; } -void amd8111_inc(struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -void amd8111_dec(struct i2c_adapter *adapter) -{ - MOD_DEC_USE_COUNT; -} - u32 amd8111_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | @@ -368,12 +358,11 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ return -1; } + smbus->adapter.owner = THIS_MODULE; sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base); smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111; smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo_data = smbus; - smbus->adapter.inc_use = amd8111_inc; - smbus->adapter.dec_use = amd8111_dec; if (i2c_add_adapter(&smbus->adapter)) { printk(KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n"); diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index abab348e5b1b..e49df00519e6 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -114,8 +114,6 @@ static void adm1021_init_client(struct i2c_client *client); static int adm1021_detach_client(struct i2c_client *client); static int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg); -static void adm1021_inc_use(struct i2c_client *client); -static void adm1021_dec_use(struct i2c_client *client); static int adm1021_read_value(struct i2c_client *client, u8 reg); static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value); @@ -136,14 +134,13 @@ static int read_only = 0; /* This is the driver that will be inserted */ static struct i2c_driver adm1021_driver = { - /* name */ "ADM1021, MAX1617 sensor driver", - /* id */ I2C_DRIVERID_ADM1021, - /* flags */ I2C_DF_NOTIFY, - /* attach_adapter */ &adm1021_attach_adapter, - /* detach_client */ &adm1021_detach_client, - /* command */ &adm1021_command, - /* inc_use */ &adm1021_inc_use, - /* dec_use */ &adm1021_dec_use + .owner = THIS_MODULE, + .name = "ADM1021, MAX1617 sensor driver", + .id = I2C_DRIVERID_ADM1021, + .flags = I2C_DF_NOTIFY, + .attach_adapter = adm1021_attach_adapter, + .detach_client = adm1021_detach_client, + .command = adm1021_command, }; /* These files are created for each detected adm1021. This is just a template; @@ -375,16 +372,6 @@ int adm1021_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; } -void adm1021_inc_use(struct i2c_client *client) -{ - MOD_INC_USE_COUNT; -} - -void adm1021_dec_use(struct i2c_client *client) -{ - MOD_DEC_USE_COUNT; -} - /* All registers are byte-sized */ int adm1021_read_value(struct i2c_client *client, u8 reg) { @@ -478,8 +465,9 @@ void adm1021_temp(struct i2c_client *client, int operation, int ctl_name, void adm1021_remote_temp(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results) { -int prec=0; struct adm1021_data *data = client->data; + int prec = 0; + if (operation == SENSORS_PROC_REAL_INFO) if (data->type == adm1023) { *nrels_mag = 3; } else { *nrels_mag = 0; } diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index 83b08f63c421..d0ef8e9ec14b 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -72,8 +72,6 @@ static void lm75_init_client(struct i2c_client *client); static int lm75_detach_client(struct i2c_client *client); static int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg); -static void lm75_inc_use(struct i2c_client *client); -static void lm75_dec_use(struct i2c_client *client); static u16 swap_bytes(u16 val); static int lm75_read_value(struct i2c_client *client, u8 reg); static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); @@ -84,14 +82,12 @@ static void lm75_update_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { - /* name */ "LM75 sensor chip driver", - /* id */ I2C_DRIVERID_LM75, - /* flags */ I2C_DF_NOTIFY, - /* attach_adapter */ &lm75_attach_adapter, - /* detach_client */ &lm75_detach_client, - /* command */ &lm75_command, - /* inc_use */ &lm75_inc_use, - /* dec_use */ &lm75_dec_use + .name = "LM75 sensor chip driver", + .id = I2C_DRIVERID_LM75, + .flags = I2C_DF_NOTIFY, + .attach_adapter = lm75_attach_adapter, + .detach_client = lm75_detach_client, + .command = lm75_command, }; /* These files are created for each detected LM75. This is just a template; @@ -221,24 +217,11 @@ int lm75_detect(struct i2c_adapter *adapter, int address, int lm75_detach_client(struct i2c_client *client) { - int err; - -#ifdef MODULE - if (MOD_IN_USE) - return -EBUSY; -#endif - - i2c_deregister_entry(((struct lm75_data *) (client->data))-> - sysctl_id); - - if ((err = i2c_detach_client(client))) { - printk - ("lm75.o: Client deregistration failed, client not detached.\n"); - return err; - } + struct lm75_data *data = client->data; + i2c_deregister_entry(data->sysctl_id); + i2c_detach_client(client); kfree(client); - return 0; } @@ -247,16 +230,6 @@ int lm75_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; } -void lm75_inc_use(struct i2c_client *client) -{ - MOD_INC_USE_COUNT; -} - -void lm75_dec_use(struct i2c_client *client) -{ - MOD_DEC_USE_COUNT; -} - u16 swap_bytes(u16 val) { return (val >> 8) | (val << 8); diff --git a/drivers/i2c/i2c-adap-ite.c b/drivers/i2c/i2c-adap-ite.c index 9e2904c0f5e8..2c7b5103806c 100644 --- a/drivers/i2c/i2c-adap-ite.c +++ b/drivers/i2c/i2c-adap-ite.c @@ -184,35 +184,6 @@ static void iic_ite_release(void) release_region(gpi.iic_base , 2); } - -static int iic_ite_reg(struct i2c_client *client) -{ - return 0; -} - - -static int iic_ite_unreg(struct i2c_client *client) -{ - return 0; -} - - -static void iic_ite_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - - -static void iic_ite_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -228,14 +199,10 @@ static struct i2c_algo_iic_data iic_ite_data = { }; static struct i2c_adapter iic_ite_ops = { - "ITE IIC adapter", - I2C_HW_I_IIC, - NULL, - &iic_ite_data, - iic_ite_inc_use, - iic_ite_dec_use, - iic_ite_reg, - iic_ite_unreg, + .owner = THIS_MODULE, + .name = "ITE IIC adapter", + .id = I2C_HW_I_IIC, + .algo_data = &iic_ite_data, }; /* Called when the module is loaded. This function starts the diff --git a/drivers/i2c/i2c-algo-bit.c b/drivers/i2c/i2c-algo-bit.c index 9551f0d27e6f..73b9f304493c 100644 --- a/drivers/i2c/i2c-algo-bit.c +++ b/drivers/i2c/i2c-algo-bit.c @@ -529,14 +529,11 @@ static u32 bit_func(struct i2c_adapter *adap) /* -----exported algorithm data: ------------------------------------- */ static struct i2c_algorithm i2c_bit_algo = { - "Bit-shift algorithm", - I2C_ALGO_BIT, - bit_xfer, - NULL, - NULL, /* slave_xmit */ - NULL, /* slave_recv */ - algo_control, /* ioctl */ - bit_func, /* functionality */ + .name = "Bit-shift algorithm", + .id = I2C_ALGO_BIT, + .master_xfer = bit_xfer, + .algo_control = algo_control, + .functionality = bit_func, }; /* @@ -581,11 +578,7 @@ int i2c_bit_add_bus(struct i2c_adapter *adap) printk("\n"); } -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif i2c_add_adapter(adap); - return 0; } @@ -599,9 +592,6 @@ int i2c_bit_del_bus(struct i2c_adapter *adap) DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",adap->name)); -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif return 0; } diff --git a/drivers/i2c/i2c-algo-pcf.c b/drivers/i2c/i2c-algo-pcf.c index 000b34a84d4c..ffa237cfa2f4 100644 --- a/drivers/i2c/i2c-algo-pcf.c +++ b/drivers/i2c/i2c-algo-pcf.c @@ -474,10 +474,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) return i; } -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif - i2c_add_adapter(adap); /* scan bus */ @@ -509,15 +505,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap) int i2c_pcf_del_bus(struct i2c_adapter *adap) { - int res; - if ((res = i2c_del_adapter(adap)) < 0) - return res; - DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: adapter unregistered: %s\n",adap->name)); - -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif - return 0; + return i2c_del_adapter(adap); } EXPORT_SYMBOL(i2c_pcf_add_bus); diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4ddcb6a26401..f9e41cc508bf 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -446,24 +446,23 @@ int i2c_detach_client(struct i2c_client *client) return 0; } -void i2c_inc_use_client(struct i2c_client *client) +static int i2c_inc_use_client(struct i2c_client *client) { - if (client->driver->inc_use != NULL) - client->driver->inc_use(client); + if (!try_module_get(client->driver->owner)) + return -ENODEV; + if (!try_module_get(client->adapter->owner)) { + module_put(client->driver->owner); + return -ENODEV; + } - if (client->adapter->inc_use != NULL) - client->adapter->inc_use(client->adapter); + return 0; } -void i2c_dec_use_client(struct i2c_client *client) +static void i2c_dec_use_client(struct i2c_client *client) { - - if (client->driver->dec_use != NULL) - client->driver->dec_use(client); - - if (client->adapter->dec_use != NULL) - client->adapter->dec_use(client->adapter); + module_put(client->driver->owner); + module_put(client->adapter->owner); } struct i2c_client *i2c_get_client(int driver_id, int adapter_id, @@ -535,20 +534,22 @@ struct i2c_client *i2c_get_client(int driver_id, int adapter_id, int i2c_use_client(struct i2c_client *client) { - if(client->flags & I2C_CLIENT_ALLOW_USE) { - if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + if (!i2c_inc_use_client(client)) + return -ENODEV; + + if (client->flags & I2C_CLIENT_ALLOW_USE) { + if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) + client->usage_count++; + else if (client->usage_count > 0) + goto busy; + else client->usage_count++; - else { - if(client->usage_count > 0) - return -EBUSY; - else - client->usage_count++; - } } - i2c_inc_use_client(client); - return 0; + busy: + i2c_dec_use_client(client); + return -EBUSY; } int i2c_release_client(struct i2c_client *client) @@ -1420,8 +1421,6 @@ EXPORT_SYMBOL(i2c_add_driver); EXPORT_SYMBOL(i2c_del_driver); EXPORT_SYMBOL(i2c_attach_client); EXPORT_SYMBOL(i2c_detach_client); -EXPORT_SYMBOL(i2c_inc_use_client); -EXPORT_SYMBOL(i2c_dec_use_client); EXPORT_SYMBOL(i2c_get_client); EXPORT_SYMBOL(i2c_use_client); EXPORT_SYMBOL(i2c_release_client); diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index a702cc953dc7..c456b8a0f875 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -364,8 +364,10 @@ int i2cdev_open (struct inode *inode, struct file *file) client->adapter = i2cdev_adaps[minor]; file->private_data = client; - if (i2cdev_adaps[minor]->inc_use) - i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]); + if (!try_module_get(i2cdev_adaps[minor]->owner)) { + kfree(client); + return -ENODEV; + } #ifdef DEBUG printk(KERN_DEBUG "i2c-dev.o: opened i2c-%d\n",minor); @@ -381,10 +383,7 @@ static int i2cdev_release (struct inode *inode, struct file *file) #ifdef DEBUG printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor); #endif - lock_kernel(); - if (i2cdev_adaps[minor]->dec_use) - i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]); - unlock_kernel(); + module_put(i2cdev_adaps[minor]->owner); return 0; } diff --git a/drivers/i2c/i2c-elektor.c b/drivers/i2c/i2c-elektor.c index f142e72e9b75..37c99ee0487c 100644 --- a/drivers/i2c/i2c-elektor.c +++ b/drivers/i2c/i2c-elektor.c @@ -142,7 +142,7 @@ static void pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs *regs) { static int pcf_isa_init(void) { if (!mmapped) { - if (!request_region(base, 2, "i2c (isa bus adapter)")) + if (!request_region(base, 2, "i2c (isa bus adapter)")) { printk(KERN_ERR "i2c-elektor.o: requested I/O region (0x%X:2) " "is in use.\n", base); @@ -159,32 +159,6 @@ static int pcf_isa_init(void) return 0; } -static int pcf_isa_reg(struct i2c_client *client) -{ - return 0; -} - - -static int pcf_isa_unreg(struct i2c_client *client) -{ - return 0; -} - -static void pcf_isa_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void pcf_isa_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -201,13 +175,10 @@ static struct i2c_algo_pcf_data pcf_isa_data = { }; static struct i2c_adapter pcf_isa_ops = { + .owner = THIS_MODULE, .name = "PCF8584 ISA adapter", .id = I2C_HW_P_ELEK, .algo_data = &pcf_isa_data, - .inc_use = pcf_isa_inc_use, - .dec_use = pcf_isa_dec_use, - .client_register = pcf_isa_reg, - .client_unregister = pcf_isa_unreg, }; static int __init i2c_pcfisa_init(void) diff --git a/drivers/i2c/i2c-elv.c b/drivers/i2c/i2c-elv.c index a11ba27ffa2e..b4c74e564813 100644 --- a/drivers/i2c/i2c-elv.c +++ b/drivers/i2c/i2c-elv.c @@ -115,30 +115,6 @@ fail: return -ENODEV; } -static int bit_elv_reg(struct i2c_client *client) -{ - return 0; -} - -static int bit_elv_unreg(struct i2c_client *client) -{ - return 0; -} - -static void bit_elv_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void bit_elv_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -153,14 +129,10 @@ static struct i2c_algo_bit_data bit_elv_data = { }; static struct i2c_adapter bit_elv_ops = { - "ELV Parallel port adaptor", - I2C_HW_B_ELV, - NULL, - &bit_elv_data, - bit_elv_inc_use, - bit_elv_dec_use, - bit_elv_reg, - bit_elv_unreg, + .owner = THIS_MODULE, + .name = "ELV Parallel port adaptor", + .id = I2C_HW_B_ELV, + .algo_data = &bit_elv_data, }; static int __init i2c_bitelv_init(void) diff --git a/drivers/i2c/i2c-frodo.c b/drivers/i2c/i2c-frodo.c index 634a4ac46457..80f6cffcc13f 100644 --- a/drivers/i2c/i2c-frodo.c +++ b/drivers/i2c/i2c-frodo.c @@ -61,44 +61,21 @@ static struct i2c_algo_bit_data bit_frodo_data = { .timeout = 100 }; -static int frodo_client_register (struct i2c_client *client) -{ - return (0); -} - -static int frodo_client_unregister (struct i2c_client *client) -{ - return (0); -} - -static void frodo_inc_use (struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -static void frodo_dec_use (struct i2c_adapter *adapter) -{ - MOD_DEC_USE_COUNT; -} - static struct i2c_adapter frodo_ops = { + .owner = THIS_MODULE, .name = "Frodo adapter driver", .id = I2C_HW_B_FRODO, .algo_data = &bit_frodo_data, - .inc_use = frodo_inc_use, - .dec_use = frodo_dec_use, - .client_register = frodo_client_register, - .client_unregister = frodo_client_unregister }; static int __init i2c_frodo_init (void) { - return (i2c_bit_add_bus (&frodo_ops)); + return i2c_bit_add_bus(&frodo_ops); } static void __exit i2c_frodo_exit (void) { - i2c_bit_del_bus (&frodo_ops); + i2c_bit_del_bus(&frodo_ops); } MODULE_AUTHOR ("Abraham van der Merwe "); diff --git a/drivers/i2c/i2c-philips-par.c b/drivers/i2c/i2c-philips-par.c index be9a49f146b8..ce2258a20447 100644 --- a/drivers/i2c/i2c-philips-par.c +++ b/drivers/i2c/i2c-philips-par.c @@ -129,26 +129,6 @@ static int bit_lp_getsda2(void *data) PARPORT_STATUS_BUSY) ? 0 : 1; } -static int bit_lp_reg(struct i2c_client *client) -{ - return 0; -} - -static int bit_lp_unreg(struct i2c_client *client) -{ - return 0; -} - -static void bit_lp_inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void bit_lp_dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -173,15 +153,9 @@ static struct i2c_algo_bit_data bit_lp_data2 = { }; static struct i2c_adapter bit_lp_ops = { - "Philips Parallel port adapter", - I2C_HW_B_LP, - NULL, - NULL, - bit_lp_inc_use, - bit_lp_dec_use, - bit_lp_reg, - - bit_lp_unreg, + .owner = THIS_MODULE, + .name = "Philips Parallel port adapter", + .id = I2C_HW_B_LP, }; static void i2c_parport_attach (struct parport *port) diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index 2273dbf684f9..9ec18313fd27 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -210,49 +210,6 @@ void i2c_deregister_entry(int id) } } -/* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o - impossible if some process still uses it or some file in it */ -void i2c_fill_inode(struct inode *inode, int fill) -{ - if (fill) - MOD_INC_USE_COUNT; - else - MOD_DEC_USE_COUNT; -} - -/* Monitor access for /proc/sys/dev/sensors/ directories; make unloading - the corresponding module impossible if some process still uses it or - some file in it */ -void i2c_dir_fill_inode(struct inode *inode, int fill) -{ - int i; - struct i2c_client *client; - -#ifdef DEBUG - if (!inode) { - printk(KERN_ERR "i2c-proc.o: Warning: inode NULL in fill_inode()\n"); - return; - } -#endif /* def DEBUG */ - - for (i = 0; i < SENSORS_ENTRY_MAX; i++) - if (i2c_clients[i] - && (i2c_inodes[i] == inode->i_ino)) break; -#ifdef DEBUG - if (i == SENSORS_ENTRY_MAX) { - printk - (KERN_ERR "i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n", - inode->i_ino); - return; - } -#endif /* def DEBUG */ - client = i2c_clients[i]; - if (fill) - client->driver->inc_use(client); - else - client->driver->dec_use(client); -} - int i2c_proc_chips(ctl_table * ctl, int write, struct file *filp, void *buffer, size_t * lenp) { diff --git a/drivers/i2c/i2c-rpx.c b/drivers/i2c/i2c-rpx.c index a449ae9c8724..389b738641c8 100644 --- a/drivers/i2c/i2c-rpx.c +++ b/drivers/i2c/i2c-rpx.c @@ -66,44 +66,15 @@ static int rpx_install_isr(int irq, void (*func)(void *, void *), void *data) return 0; } -static int rpx_reg(struct i2c_client *client) -{ - return 0; -} - -static int rpx_unreg(struct i2c_client *client) -{ - return 0; -} - -static void rpx_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void rpx_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - static struct i2c_algo_8xx_data rpx_data = { .setisr = rpx_install_isr }; - static struct i2c_adapter rpx_ops = { - "m8xx", - I2C_HW_MPC8XX_EPON, - NULL, - &rpx_data, - rpx_inc_use, - rpx_dec_use, - rpx_reg, - rpx_unreg, + .owner = THIS_MODULE, + .name = "m8xx", + .id = I2C_HW_MPC8XX_EPON, + .algo_data = &rpx_data, }; int __init i2c_rpx_init(void) diff --git a/drivers/i2c/i2c-velleman.c b/drivers/i2c/i2c-velleman.c index 9ae1a20cc868..b158fc59a656 100644 --- a/drivers/i2c/i2c-velleman.c +++ b/drivers/i2c/i2c-velleman.c @@ -89,43 +89,15 @@ static int bit_velle_getsda(void *data) static int bit_velle_init(void) { - if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { - DEBE(printk(KERN_DEBUG "i2c-velleman.o: Port %#x already in use.\n", - base)); + if (!request_region(base, (base == 0x3bc) ? 3 : 8, + "i2c (Vellemann adapter)")) return -ENODEV; - } else { - request_region(base, (base == 0x3bc)? 3 : 8, - "i2c (Vellemann adapter)"); - bit_velle_setsda((void*)base,1); - bit_velle_setscl((void*)base,1); - } - return 0; -} - -static int bit_velle_reg(struct i2c_client *client) -{ - return 0; -} -static int bit_velle_unreg(struct i2c_client *client) -{ + bit_velle_setsda((void*)base,1); + bit_velle_setscl((void*)base,1); return 0; } -static void bit_velle_inc_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_INC_USE_COUNT; -#endif -} - -static void bit_velle_dec_use(struct i2c_adapter *adap) -{ -#ifdef MODULE - MOD_DEC_USE_COUNT; -#endif -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -141,14 +113,10 @@ static struct i2c_algo_bit_data bit_velle_data = { }; static struct i2c_adapter bit_velle_ops = { - "Velleman K8000", - I2C_HW_B_VELLE, - NULL, - &bit_velle_data, - bit_velle_inc_use, - bit_velle_dec_use, - bit_velle_reg, - bit_velle_unreg, + .owner = THIS_MODULE, + .name = "Velleman K8000", + .id = I2C_HW_B_VELLE, + .algo_data = &bit_velle_data, }; static int __init i2c_bitvelle_init(void) diff --git a/drivers/i2c/scx200_acb.c b/drivers/i2c/scx200_acb.c index 083df8d02030..6f0575545d5a 100644 --- a/drivers/i2c/scx200_acb.c +++ b/drivers/i2c/scx200_acb.c @@ -397,26 +397,6 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter) I2C_FUNC_SMBUS_BLOCK_DATA; } -static int scx200_acb_reg(struct i2c_client *client) -{ - return 0; -} - -static int scx200_acb_unreg(struct i2c_client *client) -{ - return 0; -} - -static void scx200_acb_inc_use(struct i2c_adapter *adapter) -{ - MOD_INC_USE_COUNT; -} - -static void scx200_acb_dec_use(struct i2c_adapter *adapter) -{ - MOD_DEC_USE_COUNT; -} - /* For now, we only handle combined mode (smbus) */ static struct i2c_algorithm scx200_acb_algorithm = { .name = "NatSemi SCx200 ACCESS.bus", @@ -479,12 +459,9 @@ static int __init scx200_acb_create(int base, int index) adapter = &iface->adapter; adapter->data = iface; sprintf(adapter->name, "SCx200 ACB%d", index); + adapter->owner = THIS_MODULE; adapter->id = I2C_ALGO_SMBUS; adapter->algo = &scx200_acb_algorithm; - adapter->inc_use = scx200_acb_inc_use; - adapter->dec_use = scx200_acb_dec_use; - adapter->client_register = scx200_acb_reg; - adapter->client_unregister = scx200_acb_unreg; init_MUTEX(&iface->sem); diff --git a/drivers/i2c/scx200_i2c.c b/drivers/i2c/scx200_i2c.c index 515e0c73d523..75d5a56cb32d 100644 --- a/drivers/i2c/scx200_i2c.c +++ b/drivers/i2c/scx200_i2c.c @@ -66,26 +66,6 @@ static int scx200_i2c_getsda(void *data) return scx200_gpio_get(sda); } -static int scx200_i2c_reg(struct i2c_client *client) -{ - return 0; -} - -static int scx200_i2c_unreg(struct i2c_client *client) -{ - return 0; -} - -static void scx200_i2c_inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void scx200_i2c_dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - /* ------------------------------------------------------------------------ * Encapsulate the above functions in the correct operations structure. * This is only done when more than one hardware adapter is supported. @@ -101,13 +81,10 @@ static struct i2c_algo_bit_data scx200_i2c_data = { }; static struct i2c_adapter scx200_i2c_ops = { + .owner = THIS_MODULE, .name = "NatSemi SCx200 I2C", .id = I2C_HW_B_VELLE, .algo_data = &scx200_i2c_data, - .inc_use = scx200_i2c_inc_use, - .dec_use = scx200_i2c_dec_use, - .client_register = scx200_i2c_reg, - .client_unregister = scx200_i2c_unreg, }; int scx200_i2c_init(void) diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 0936646dbc8d..bbe615f727be 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -396,39 +396,26 @@ static int adv717x_command(struct i2c_client *client, unsigned int cmd, return 0; } -static void adv717x_inc_use(struct i2c_client *client) -{ - MOD_INC_USE_COUNT; -} - -static void adv717x_dec_use(struct i2c_client *client) -{ - MOD_DEC_USE_COUNT; -} - - /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_adv7175 = { + .owner = THIS_MODULE, .name = "adv7175", /* name */ .id = I2C_DRIVERID_ADV717x, /* ID */ .flags = I2C_DF_NOTIFY, //I2C_ADV7175, I2C_ADV7175 + 3, .attach_adapter = adv717x_probe, .detach_client = adv717x_detach, .command = adv717x_command, - .inc_use = &adv717x_inc_use, - .dec_use = &adv717x_dec_use }; static struct i2c_driver i2c_driver_adv7176 = { + .owner = THIS_MODULE, .name = "adv7176", /* name */ .id = I2C_DRIVERID_ADV717x, /* ID */ .flags = I2C_DF_NOTIFY, //I2C_ADV7176, I2C_ADV7176 + 3, .attach_adapter = adv717x_probe, .detach_client = adv717x_detach, .command = adv717x_command, - .inc_use = &adv717x_inc_use, - .dec_use = &adv717x_dec_use }; static struct i2c_client client_template = { diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c index 08eff8c66cfa..5603d9ce59c2 100644 --- a/drivers/media/video/bttv-if.c +++ b/drivers/media/video/bttv-if.c @@ -194,16 +194,6 @@ static int bttv_bit_getsda(void *data) return state; } -static void bttv_inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void bttv_dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - static int attach_inform(struct i2c_client *client) { struct bttv *btv = (struct bttv*)client->adapter->data; @@ -272,10 +262,9 @@ static struct i2c_algo_bit_data bttv_i2c_algo_template = { }; static struct i2c_adapter bttv_i2c_adap_template = { + .owner = THIS_MODULE, .name = "bt848", .id = I2C_HW_B_BT848, - .inc_use = bttv_inc_use, - .dec_use = bttv_dec_use, .client_register = attach_inform, .client_unregister = detach_inform, }; diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index fbbe02a10faf..0e4d9b8d4b86 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -318,16 +318,6 @@ static u32 functionality(struct i2c_adapter *adap) return I2C_FUNC_SMBUS_EMUL; } -static void inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} - static int attach_inform(struct i2c_client *client) { struct saa7134_dev *dev = client->adapter->algo_data; @@ -346,11 +336,10 @@ static struct i2c_algorithm saa7134_algo = { }; static struct i2c_adapter saa7134_adap_template = { + .owner = THIS_MODULE, .name = "saa7134", .id = I2C_ALGO_SAA7134, .algo = &saa7134_algo, - .inc_use = inc_use, - .dec_use = dec_use, .client_register = attach_inform, }; diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 62f1b96b0e78..e3ab127a6d3b 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -195,8 +195,9 @@ static int tvmixer_open(struct inode *inode, struct file *file) /* lock bttv in memory while the mixer is in use */ file->private_data = mix; - if (client->adapter->inc_use) - client->adapter->inc_use(client->adapter); + + if (!try_module_get(client->adapter->owner)) + return -ENODEV; return 0; } @@ -210,8 +211,7 @@ static int tvmixer_release(struct inode *inode, struct file *file) return -ENODEV; } - if (client->adapter->dec_use) - client->adapter->dec_use(client->adapter); + module_put(client->adapter->owner); return 0; } diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index f984722caa89..116c4e3fbefb 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c @@ -87,19 +87,10 @@ static int matroxfb_gpio_getscl(void* data) { return (matroxfb_read_gpio(b->minfo) & b->mask.clock) ? 1 : 0; } -static void matroxfb_dh_inc_use(struct i2c_adapter* dummy) { - MOD_INC_USE_COUNT; -} - -static void matroxfb_dh_dec_use(struct i2c_adapter* dummy) { - MOD_DEC_USE_COUNT; -} - static struct i2c_adapter matrox_i2c_adapter_template = { + .owner = THIS_MODULE, .id = I2C_HW_B_G400, - .inc_use = matroxfb_dh_inc_use, - .dec_use = matroxfb_dh_dec_use, }; static struct i2c_algo_bit_data matrox_i2c_algo_template = diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 02bc8d68378f..4f2c23038bf4 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -945,14 +945,6 @@ static unsigned short normal_i2c[] = { MAVEN_I2CID, I2C_CLIENT_END }; static unsigned short normal_i2c_range[] = { MAVEN_I2CID, MAVEN_I2CID, I2C_CLIENT_END }; I2C_CLIENT_INSMOD; -static void maven_inc_use(struct i2c_client* clnt) { - MOD_INC_USE_COUNT; -} - -static void maven_dec_use(struct i2c_client* clnt) { - MOD_DEC_USE_COUNT; -} - static struct i2c_driver maven_driver; static int maven_detect_client(struct i2c_adapter* adapter, int address, unsigned short flags, @@ -1016,17 +1008,13 @@ static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) return -ENOIOCTLCMD; /* or -EINVAL, depends on who will call this */ } -static int maven_driver_registered = 0; - static struct i2c_driver maven_driver={ - "maven", - I2C_DRIVERID_MGATVO, - I2C_DF_NOTIFY, - maven_attach_adapter, - maven_detach_client, - maven_command, - maven_inc_use, - maven_dec_use + .owner = THIS_MODULE, + .name = "maven", + .id = I2C_DRIVERID_MGATVO, + .flags = I2C_DF_NOTIFY, + .attach_adapter = maven_attach_adapter, + .detach_client = maven_detach_client, }; /* ************************** */ @@ -1039,13 +1027,11 @@ static int matroxfb_maven_init(void) { printk(KERN_ERR "maven: Maven driver failed to register (%d).\n", err); return err; } - maven_driver_registered = 1; return 0; } static void matroxfb_maven_exit(void) { - if (maven_driver_registered) - i2c_del_driver(&maven_driver); + i2c_del_driver(&maven_driver); } MODULE_AUTHOR("(c) 1999-2002 Petr Vandrovec "); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index ab69e01bc8c3..d343349836e2 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -132,6 +132,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, */ struct i2c_driver { + struct module *owner; char name[32]; int id; unsigned int flags; /* div., see below */ @@ -155,18 +156,6 @@ struct i2c_driver { * with the device. */ int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); - - /* These two are mainly used for bookkeeping & dynamic unloading of - * kernel modules. inc_use tells the driver that a client is being - * used by another module & that it should increase its ref. counter. - * dec_use is the inverse operation. - * NB: Make sure you have no circular dependencies, or else you get a - * deadlock when trying to unload the modules. - * You should use the i2c_{inc,dec}_use_client functions instead of - * calling this function directly. - */ - void (*inc_use)(struct i2c_client *client); - void (*dec_use)(struct i2c_client *client); }; /* @@ -232,16 +221,13 @@ struct proc_dir_entry; * with the access algorithms necessary to access it. */ struct i2c_adapter { + struct module *owner; char name[32]; /* some useful name to identify the adapter */ unsigned int id;/* == is algo->id | hwdep.struct->id, */ /* for registered values see below */ struct i2c_algorithm *algo;/* the algorithm to access the bus */ void *algo_data; - /* --- These may be NULL, but should increase the module use count */ - void (*inc_use)(struct i2c_adapter *); - void (*dec_use)(struct i2c_adapter *); - /* --- administration stuff. */ int (*client_register)(struct i2c_client *); int (*client_unregister)(struct i2c_client *); @@ -319,12 +305,6 @@ extern int i2c_del_driver(struct i2c_driver *); extern int i2c_attach_client(struct i2c_client *); extern int i2c_detach_client(struct i2c_client *); -/* Only call these if you grab a resource that makes unloading the - client and the adapter it is on completely impossible. Like when a - /proc directory is entered. */ -extern void i2c_inc_use_client(struct i2c_client *); -extern void i2c_dec_use_client(struct i2c_client *); - /* New function: This is to get an i2c_client-struct for controlling the client either by using i2c_control-function or having the client-module export functions that can be used with the i2c_client -- cgit v1.2.3 From 700b988cebc10f3d3faa22d440995da7b05b6d6c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 19:51:03 -0800 Subject: [PATCH] i2c updates a few new ids, a name change and 10 lines of new code, ported over from the external i2c package. --- drivers/i2c/i2c-algo-ibm_ocp.c | 8 ++++---- drivers/i2c/i2c-algo-ibm_ocp.h | 4 ++-- drivers/i2c/i2c-dev.c | 4 ++-- drivers/i2c/i2c-proc.c | 15 +++++++++++++-- include/linux/i2c-algo-bit.h | 7 ++++--- include/linux/i2c-id.h | 12 ++++++++++++ include/linux/i2c.h | 4 +++- 7 files changed, 40 insertions(+), 14 deletions(-) (limited to 'include/linux') diff --git a/drivers/i2c/i2c-algo-ibm_ocp.c b/drivers/i2c/i2c-algo-ibm_ocp.c index 77380200a2ef..3b345d2e9d78 100644 --- a/drivers/i2c/i2c-algo-ibm_ocp.c +++ b/drivers/i2c/i2c-algo-ibm_ocp.c @@ -877,7 +877,7 @@ static struct i2c_algorithm iic_algo = { // // Description: Register bus structure // -int i2c_iic_add_bus(struct i2c_adapter *adap) +int i2c_ocp_add_bus(struct i2c_adapter *adap) { struct i2c_algo_iic_data *iic_adap = adap->algo_data; @@ -912,7 +912,7 @@ int i2c_iic_add_bus(struct i2c_adapter *adap) // // Done // -int i2c_iic_del_bus(struct i2c_adapter *adap) +int i2c_ocp_del_bus(struct i2c_adapter *adap) { int res; if ((res = i2c_del_adapter(adap)) < 0) @@ -942,8 +942,8 @@ void i2c_algo_iic_exit(void) } -EXPORT_SYMBOL(i2c_iic_add_bus); -EXPORT_SYMBOL(i2c_iic_del_bus); +EXPORT_SYMBOL(i2c_ocp_add_bus); +EXPORT_SYMBOL(i2c_ocp_del_bus); // // The MODULE_* macros resolve to nothing if MODULES is not defined diff --git a/drivers/i2c/i2c-algo-ibm_ocp.h b/drivers/i2c/i2c-algo-ibm_ocp.h index e32e5af81b38..5a4e588f19ae 100644 --- a/drivers/i2c/i2c-algo-ibm_ocp.h +++ b/drivers/i2c/i2c-algo-ibm_ocp.h @@ -49,7 +49,7 @@ struct i2c_algo_iic_data { #define I2C_IIC_ADAP_MAX 16 -int i2c_iic_add_bus(struct i2c_adapter *); -int i2c_iic_del_bus(struct i2c_adapter *); +int i2c_ocp_add_bus(struct i2c_adapter *); +int i2c_ocp_del_bus(struct i2c_adapter *); #endif /* I2C_ALGO_IIC_H */ diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index c456b8a0f875..14d0081b98fe 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -138,9 +138,9 @@ static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count, struct inode *inode = file->f_dentry->d_inode; #endif /* DEBUG */ - if(count > 8192) + if (count > 8192) count = 8192; - + /* copy user space data to kernel space. */ tmp = kmalloc(count,GFP_KERNEL); if (tmp==NULL) diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index 9ec18313fd27..785e9c5f3716 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -97,10 +97,21 @@ int i2c_create_name(char **name, const char *prefix, struct i2c_adapter *adapter, int addr) { char name_buffer[50]; - int id; + int id, i, end; if (i2c_is_isa_adapter(adapter)) sprintf(name_buffer, "%s-isa-%04x", prefix, addr); - else { + else if (!adapter->algo->smbus_xfer && !adapter->algo->master_xfer) { + /* dummy adapter, generate prefix */ + sprintf(name_buffer, "%s-", prefix); + end = strlen(name_buffer); + for(i = 0; i < 32; i++) { + if(adapter->algo->name[i] == ' ') + break; + name_buffer[end++] = tolower(adapter->algo->name[i]); + } + name_buffer[end] = 0; + sprintf(name_buffer + end, "-%04x", addr); + } else { if ((id = i2c_adapter_id(adapter)) < 0) return -ENOENT; sprintf(name_buffer, "%s-i2c-%d-%02x", prefix, id, addr); diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h index 9598d2cbf718..fea550f163d9 100644 --- a/include/linux/i2c-algo-bit.h +++ b/include/linux/i2c-algo-bit.h @@ -42,9 +42,10 @@ struct i2c_algo_bit_data { int (*getscl) (void *data); /* local settings */ - int udelay; - int mdelay; - int timeout; + int udelay; /* half-clock-cycle time in microsecs */ + /* i.e. clock is (500 / udelay) KHz */ + int mdelay; /* in millisecs, unused */ + int timeout; /* in jiffies */ }; #define I2C_BIT_ADAP_MAX 16 diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 2b6394004ea1..0061776f0402 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -145,6 +145,8 @@ #define I2C_DRIVERID_LM92 1033 #define I2C_DRIVERID_VT8231 1034 #define I2C_DRIVERID_SMARTBATT 1035 +#define I2C_DRIVERID_BMCSENSORS 1036 +#define I2C_DRIVERID_FS451 1037 /* * ---- Adapter types ---------------------------------------------------- @@ -164,6 +166,8 @@ #define I2C_ALGO_IIC 0x080000 /* ITE IIC bus */ #define I2C_ALGO_SAA7134 0x090000 #define I2C_ALGO_MPC824X 0x0a0000 /* Motorola 8240 / 8245 */ +#define I2C_ALGO_IPMI 0x0b0000 /* IPMI dummy adapter */ +#define I2C_ALGO_IPMB 0x0c0000 /* IPMB adapter */ #define I2C_ALGO_EC 0x100000 /* ACPI embedded controller */ #define I2C_ALGO_MPC8XX 0x110000 /* MPC8xx PowerPC I2C algorithm */ @@ -196,6 +200,7 @@ #define I2C_HW_B_VOO 0x0b /* 3dfx Voodoo 3 / Banshee */ #define I2C_HW_B_PPORT 0x0c /* Primitive parallel port adapter */ #define I2C_HW_B_SAVG 0x0d /* Savage 4 */ +#define I2C_HW_B_SCX200 0x0e /* Nat'l Semi SCx200 I2C */ #define I2C_HW_B_RIVA 0x10 /* Riva based graphics cards */ #define I2C_HW_B_IOC 0x11 /* IOC bit-wiggling */ #define I2C_HW_B_TSUNA 0x12 /* DEC Tsunami chipset */ @@ -234,8 +239,15 @@ #define I2C_HW_SMBUS_SIS630 0x08 #define I2C_HW_SMBUS_SIS645 0x09 #define I2C_HW_SMBUS_AMD8111 0x0a +#define I2C_HW_SMBUS_SCX200 0x0b /* --- ISA pseudo-adapter */ #define I2C_HW_ISA 0x00 +/* --- IPMI pseudo-adapter */ +#define I2C_HW_IPMI 0x00 + +/* --- IPMB adapter */ +#define I2C_HW_IPMB 0x00 + #endif /* I2C_ID_H */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index d343349836e2..765a95af3a4e 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -367,6 +367,8 @@ struct i2c_msg { #define I2C_M_RD 0x01 #define I2C_M_NOSTART 0x4000 #define I2C_M_REV_DIR_ADDR 0x2000 +#define I2C_M_IGNORE_NAK 0x1000 +#define I2C_M_NO_RD_ACK 0x0800 short len; /* msg length */ char *buf; /* pointer to msg data */ }; @@ -375,7 +377,7 @@ struct i2c_msg { #define I2C_FUNC_I2C 0x00000001 #define I2C_FUNC_10BIT_ADDR 0x00000002 -#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART} */ +#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ #define I2C_FUNC_SMBUS_HWPEC_CALC 0x00000008 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_READ_WORD_DATA_PEC 0x00000800 /* SMBus 2.0 */ #define I2C_FUNC_SMBUS_WRITE_WORD_DATA_PEC 0x00001000 /* SMBus 2.0 */ -- cgit v1.2.3 From 32cce74ba349764f1bda932748500232604e960d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 19:51:09 -0800 Subject: [PATCH] remove obsolete i2c headers * i2c-elektor.h is empty except for comments * sensors.h contains register offsets for tons of hw monitoring chips, move the few we actually need into the two drivers that use it (there is _no_ overlap) --- drivers/i2c/chips/adm1021.c | 13 +- drivers/i2c/chips/lm75.c | 4 +- drivers/i2c/i2c-elektor.c | 1 - include/linux/i2c-elektor.h | 47 --- include/linux/sensors.h | 690 -------------------------------------------- 5 files changed, 15 insertions(+), 740 deletions(-) delete mode 100644 include/linux/i2c-elektor.h delete mode 100644 include/linux/sensors.h (limited to 'include/linux') diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index e49df00519e6..19c4fed60425 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -23,9 +23,20 @@ #include #include #include -#include +#include #include +/* Registers */ +#define ADM1021_SYSCTL_TEMP 1200 +#define ADM1021_SYSCTL_REMOTE_TEMP 1201 +#define ADM1021_SYSCTL_DIE_CODE 1202 +#define ADM1021_SYSCTL_ALARMS 1203 + +#define ADM1021_ALARM_TEMP_HIGH 0x40 +#define ADM1021_ALARM_TEMP_LOW 0x20 +#define ADM1021_ALARM_RTEMP_HIGH 0x10 +#define ADM1021_ALARM_RTEMP_LOW 0x08 +#define ADM1021_ALARM_RTEMP_NA 0x04 /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index d0ef8e9ec14b..e628f4418420 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -22,10 +22,12 @@ #include #include #include -#include +#include #include +#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ + /* Addresses to scan */ static unsigned short normal_i2c[] = { SENSORS_I2C_END }; static unsigned short normal_i2c_range[] = { 0x48, 0x4f, SENSORS_I2C_END }; diff --git a/drivers/i2c/i2c-elektor.c b/drivers/i2c/i2c-elektor.c index 37c99ee0487c..66ef1a818de2 100644 --- a/drivers/i2c/i2c-elektor.c +++ b/drivers/i2c/i2c-elektor.c @@ -38,7 +38,6 @@ #include #include -#include #include #include diff --git a/include/linux/i2c-elektor.h b/include/linux/i2c-elektor.h deleted file mode 100644 index 7c9213175892..000000000000 --- a/include/linux/i2c-elektor.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ------------------------------------------------------------------------- */ -/* i2c-elektor.c i2c-hw access for PCF8584 style isa bus adaptes */ -/* ------------------------------------------------------------------------- */ -/* Copyright (C) 1995-97 Simon G. Vogl - 1998-99 Hans Berglund - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* ------------------------------------------------------------------------- */ - -/* With some changes from Kyösti Mälkki and even - Frodo Looijaard */ - -/* $Id: i2c-elektor.h,v 1.5 2001/06/05 01:46:33 mds Exp $ */ - -#ifndef I2C_PCF_ELEKTOR_H -#define I2C_PCF_ELEKTOR_H 1 - -/* - * This struct contains the hw-dependent functions of PCF8584 adapters to - * manipulate the registers, and to init any hw-specific features. - * vdovikin: removed: this module in real supports only one device, - * due to missing arguments in some functions, called from the algo-pcf module. - * Sometimes it's need to be rewriten - - * but for now just remove this for simpler reading */ - -/* -struct i2c_pcf_isa { - int pi_base; - int pi_irq; - int pi_clock; - int pi_own; -}; -*/ - -#endif /* PCF_ELEKTOR_H */ diff --git a/include/linux/sensors.h b/include/linux/sensors.h deleted file mode 100644 index 31998faab1e6..000000000000 --- a/include/linux/sensors.h +++ /dev/null @@ -1,690 +0,0 @@ -/* - sensors.h - Part of lm_sensors, Linux kernel modules for hardware - monitoring - Copyright (c) 1998, 1999 Frodo Looijaard - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef SENSORS_NSENSORS_H -#define SENSORS_NSENSORS_H - -#define LM_DATE "20020915" -#define LM_VERSION "2.6.5" - -#include - -#define LM78_SYSCTL_IN0 1000 /* Volts * 100 */ -#define LM78_SYSCTL_IN1 1001 -#define LM78_SYSCTL_IN2 1002 -#define LM78_SYSCTL_IN3 1003 -#define LM78_SYSCTL_IN4 1004 -#define LM78_SYSCTL_IN5 1005 -#define LM78_SYSCTL_IN6 1006 -#define LM78_SYSCTL_FAN1 1101 /* Rotations/min */ -#define LM78_SYSCTL_FAN2 1102 -#define LM78_SYSCTL_FAN3 1103 -#define LM78_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ -#define LM78_SYSCTL_VID 1300 /* Volts * 100 */ -#define LM78_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define LM78_SYSCTL_ALARMS 2001 /* bitvector */ - -#define LM78_ALARM_IN0 0x0001 -#define LM78_ALARM_IN1 0x0002 -#define LM78_ALARM_IN2 0x0004 -#define LM78_ALARM_IN3 0x0008 -#define LM78_ALARM_IN4 0x0100 -#define LM78_ALARM_IN5 0x0200 -#define LM78_ALARM_IN6 0x0400 -#define LM78_ALARM_FAN1 0x0040 -#define LM78_ALARM_FAN2 0x0080 -#define LM78_ALARM_FAN3 0x0800 -#define LM78_ALARM_TEMP 0x0010 -#define LM78_ALARM_BTI 0x0020 -#define LM78_ALARM_CHAS 0x1000 -#define LM78_ALARM_FIFO 0x2000 -#define LM78_ALARM_SMI_IN 0x4000 - -#define W83781D_SYSCTL_IN0 1000 /* Volts * 100 */ -#define W83781D_SYSCTL_IN1 1001 -#define W83781D_SYSCTL_IN2 1002 -#define W83781D_SYSCTL_IN3 1003 -#define W83781D_SYSCTL_IN4 1004 -#define W83781D_SYSCTL_IN5 1005 -#define W83781D_SYSCTL_IN6 1006 -#define W83781D_SYSCTL_IN7 1007 -#define W83781D_SYSCTL_IN8 1008 -#define W83781D_SYSCTL_FAN1 1101 /* Rotations/min */ -#define W83781D_SYSCTL_FAN2 1102 -#define W83781D_SYSCTL_FAN3 1103 -#define W83781D_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ -#define W83781D_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ -#define W83781D_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ -#define W83781D_SYSCTL_VID 1300 /* Volts * 1000 */ -#define W83781D_SYSCTL_VRM 1301 -#define W83781D_SYSCTL_PWM1 1401 -#define W83781D_SYSCTL_PWM2 1402 -#define W83781D_SYSCTL_PWM3 1403 -#define W83781D_SYSCTL_PWM4 1404 -#define W83781D_SYSCTL_SENS1 1501 /* 1, 2, or Beta (3000-5000) */ -#define W83781D_SYSCTL_SENS2 1502 -#define W83781D_SYSCTL_SENS3 1503 -#define W83781D_SYSCTL_RT1 1601 /* 32-entry table */ -#define W83781D_SYSCTL_RT2 1602 /* 32-entry table */ -#define W83781D_SYSCTL_RT3 1603 /* 32-entry table */ -#define W83781D_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define W83781D_SYSCTL_ALARMS 2001 /* bitvector */ -#define W83781D_SYSCTL_BEEP 2002 /* bitvector */ - -#define W83781D_ALARM_IN0 0x0001 -#define W83781D_ALARM_IN1 0x0002 -#define W83781D_ALARM_IN2 0x0004 -#define W83781D_ALARM_IN3 0x0008 -#define W83781D_ALARM_IN4 0x0100 -#define W83781D_ALARM_IN5 0x0200 -#define W83781D_ALARM_IN6 0x0400 -#define W83782D_ALARM_IN7 0x10000 -#define W83782D_ALARM_IN8 0x20000 -#define W83781D_ALARM_FAN1 0x0040 -#define W83781D_ALARM_FAN2 0x0080 -#define W83781D_ALARM_FAN3 0x0800 -#define W83781D_ALARM_TEMP1 0x0010 -#define W83781D_ALARM_TEMP23 0x0020 /* 781D only */ -#define W83781D_ALARM_TEMP2 0x0020 /* 782D/783S */ -#define W83781D_ALARM_TEMP3 0x2000 /* 782D only */ -#define W83781D_ALARM_CHAS 0x1000 - -#define LM75_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ - -#define ADM1021_SYSCTL_TEMP 1200 -#define ADM1021_SYSCTL_REMOTE_TEMP 1201 -#define ADM1021_SYSCTL_DIE_CODE 1202 -#define ADM1021_SYSCTL_ALARMS 1203 - -#define ADM1021_ALARM_TEMP_HIGH 0x40 -#define ADM1021_ALARM_TEMP_LOW 0x20 -#define ADM1021_ALARM_RTEMP_HIGH 0x10 -#define ADM1021_ALARM_RTEMP_LOW 0x08 -#define ADM1021_ALARM_RTEMP_NA 0x04 - -#define GL518_SYSCTL_VDD 1000 /* Volts * 100 */ -#define GL518_SYSCTL_VIN1 1001 -#define GL518_SYSCTL_VIN2 1002 -#define GL518_SYSCTL_VIN3 1003 -#define GL518_SYSCTL_FAN1 1101 /* RPM */ -#define GL518_SYSCTL_FAN2 1102 -#define GL518_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ -#define GL518_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define GL518_SYSCTL_ALARMS 2001 /* bitvector */ -#define GL518_SYSCTL_BEEP 2002 /* bitvector */ -#define GL518_SYSCTL_FAN1OFF 2003 -#define GL518_SYSCTL_ITERATE 2004 - -#define GL518_ALARM_VDD 0x01 -#define GL518_ALARM_VIN1 0x02 -#define GL518_ALARM_VIN2 0x04 -#define GL518_ALARM_VIN3 0x08 -#define GL518_ALARM_TEMP 0x10 -#define GL518_ALARM_FAN1 0x20 -#define GL518_ALARM_FAN2 0x40 - -#define GL520_SYSCTL_VDD 1000 /* Volts * 100 */ -#define GL520_SYSCTL_VIN1 1001 -#define GL520_SYSCTL_VIN2 1002 -#define GL520_SYSCTL_VIN3 1003 -#define GL520_SYSCTL_VIN4 1004 -#define GL520_SYSCTL_FAN1 1101 /* RPM */ -#define GL520_SYSCTL_FAN2 1102 -#define GL520_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ -#define GL520_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ -#define GL520_SYSCTL_VID 1300 -#define GL520_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define GL520_SYSCTL_ALARMS 2001 /* bitvector */ -#define GL520_SYSCTL_BEEP 2002 /* bitvector */ -#define GL520_SYSCTL_FAN1OFF 2003 -#define GL520_SYSCTL_CONFIG 2004 - -#define GL520_ALARM_VDD 0x01 -#define GL520_ALARM_VIN1 0x02 -#define GL520_ALARM_VIN2 0x04 -#define GL520_ALARM_VIN3 0x08 -#define GL520_ALARM_TEMP1 0x10 -#define GL520_ALARM_FAN1 0x20 -#define GL520_ALARM_FAN2 0x40 -#define GL520_ALARM_TEMP2 0x80 -#define GL520_ALARM_VIN4 0x80 - -#define EEPROM_SYSCTL1 1000 -#define EEPROM_SYSCTL2 1001 -#define EEPROM_SYSCTL3 1002 -#define EEPROM_SYSCTL4 1003 -#define EEPROM_SYSCTL5 1004 -#define EEPROM_SYSCTL6 1005 -#define EEPROM_SYSCTL7 1006 -#define EEPROM_SYSCTL8 1007 -#define EEPROM_SYSCTL9 1008 -#define EEPROM_SYSCTL10 1009 -#define EEPROM_SYSCTL11 1010 -#define EEPROM_SYSCTL12 1011 -#define EEPROM_SYSCTL13 1012 -#define EEPROM_SYSCTL14 1013 -#define EEPROM_SYSCTL15 1014 -#define EEPROM_SYSCTL16 1015 - -#define LM80_SYSCTL_IN0 1000 /* Volts * 100 */ -#define LM80_SYSCTL_IN1 1001 -#define LM80_SYSCTL_IN2 1002 -#define LM80_SYSCTL_IN3 1003 -#define LM80_SYSCTL_IN4 1004 -#define LM80_SYSCTL_IN5 1005 -#define LM80_SYSCTL_IN6 1006 -#define LM80_SYSCTL_FAN1 1101 /* Rotations/min */ -#define LM80_SYSCTL_FAN2 1102 -#define LM80_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ -#define LM80_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define LM80_SYSCTL_ALARMS 2001 /* bitvector */ - -#define ADM9240_SYSCTL_IN0 1000 /* Volts * 100 */ -#define ADM9240_SYSCTL_IN1 1001 -#define ADM9240_SYSCTL_IN2 1002 -#define ADM9240_SYSCTL_IN3 1003 -#define ADM9240_SYSCTL_IN4 1004 -#define ADM9240_SYSCTL_IN5 1005 -#define ADM9240_SYSCTL_FAN1 1101 /* Rotations/min */ -#define ADM9240_SYSCTL_FAN2 1102 -#define ADM9240_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ -#define ADM9240_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define ADM9240_SYSCTL_ALARMS 2001 /* bitvector */ -#define ADM9240_SYSCTL_ANALOG_OUT 2002 -#define ADM9240_SYSCTL_VID 2003 - -#define ADM9240_ALARM_IN0 0x0001 -#define ADM9240_ALARM_IN1 0x0002 -#define ADM9240_ALARM_IN2 0x0004 -#define ADM9240_ALARM_IN3 0x0008 -#define ADM9240_ALARM_IN4 0x0100 -#define ADM9240_ALARM_IN5 0x0200 -#define ADM9240_ALARM_FAN1 0x0040 -#define ADM9240_ALARM_FAN2 0x0080 -#define ADM9240_ALARM_TEMP 0x0010 -#define ADM9240_ALARM_CHAS 0x1000 - -#define ADM1024_SYSCTL_IN0 1000 /* Volts * 100 */ -#define ADM1024_SYSCTL_IN1 1001 -#define ADM1024_SYSCTL_IN2 1002 -#define ADM1024_SYSCTL_IN3 1003 -#define ADM1024_SYSCTL_IN4 1004 -#define ADM1024_SYSCTL_IN5 1005 -#define ADM1024_SYSCTL_FAN1 1101 /* Rotations/min */ -#define ADM1024_SYSCTL_FAN2 1102 -#define ADM1024_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ -#define ADM1024_SYSCTL_TEMP1 1290 /* Degrees Celcius */ -#define ADM1024_SYSCTL_TEMP2 1295 /* Degrees Celcius */ -#define ADM1024_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define ADM1024_SYSCTL_ALARMS 2001 /* bitvector */ -#define ADM1024_SYSCTL_ANALOG_OUT 2002 -#define ADM1024_SYSCTL_VID 2003 - -#define ADM1024_ALARM_IN0 0x0001 -#define ADM1024_ALARM_IN1 0x0002 -#define ADM1024_ALARM_IN2 0x0004 -#define ADM1024_ALARM_IN3 0x0008 -#define ADM1024_ALARM_IN4 0x0100 -#define ADM1024_ALARM_IN5 0x0200 -#define ADM1024_ALARM_FAN1 0x0040 -#define ADM1024_ALARM_FAN2 0x0080 -#define ADM1024_ALARM_TEMP 0x0010 -#define ADM1024_ALARM_TEMP1 0x0020 -#define ADM1024_ALARM_TEMP2 0x0001 -#define ADM1024_ALARM_CHAS 0x1000 - -#define ADM1025_SYSCTL_IN0 1000 /* Volts * 100 */ -#define ADM1025_SYSCTL_IN1 1001 -#define ADM1025_SYSCTL_IN2 1002 -#define ADM1025_SYSCTL_IN3 1003 -#define ADM1025_SYSCTL_IN4 1004 -#define ADM1025_SYSCTL_IN5 1005 -#define ADM1025_SYSCTL_RTEMP 1251 -#define ADM1025_SYSCTL_TEMP 1250 /* Degrees Celcius * 100 */ -#define ADM1025_SYSCTL_ALARMS 2001 /* bitvector */ -#define ADM1025_SYSCTL_ANALOG_OUT 2002 -#define ADM1025_SYSCTL_VID 2003 -#define ADM1025_SYSCTL_VRM 2004 - -#define ADM1025_ALARM_IN0 0x0001 -#define ADM1025_ALARM_IN1 0x0002 -#define ADM1025_ALARM_IN2 0x0004 -#define ADM1025_ALARM_IN3 0x0008 -#define ADM1025_ALARM_IN4 0x0100 -#define ADM1025_ALARM_IN5 0x0200 -#define ADM1025_ALARM_RTEMP 0x0020 -#define ADM1025_ALARM_TEMP 0x0010 - -#define LTC1710_SYSCTL_SWITCH_1 1000 -#define LTC1710_SYSCTL_SWITCH_2 1001 - -#define LM80_ALARM_IN0 0x0001 -#define LM80_ALARM_IN1 0x0002 -#define LM80_ALARM_IN2 0x0004 -#define LM80_ALARM_IN3 0x0008 -#define LM80_ALARM_IN4 0x0010 -#define LM80_ALARM_IN5 0x0020 -#define LM80_ALARM_IN6 0x0040 -#define LM80_ALARM_FAN1 0x0400 -#define LM80_ALARM_FAN2 0x0800 -#define LM80_ALARM_TEMP_HOT 0x0100 -#define LM80_ALARM_TEMP_OS 0x2000 -#define LM80_ALARM_CHAS 0x1000 -#define LM80_ALARM_BTI 0x0200 -#define LM80_ALARM_INT_IN 0x0080 - -#define MAXI_SYSCTL_FAN1 1101 /* Rotations/min */ -#define MAXI_SYSCTL_FAN2 1102 /* Rotations/min */ -#define MAXI_SYSCTL_FAN3 1103 /* Rotations/min */ -#define MAXI_SYSCTL_FAN4 1104 /* Rotations/min */ -#define MAXI_SYSCTL_TEMP1 1201 /* Degrees Celcius */ -#define MAXI_SYSCTL_TEMP2 1202 /* Degrees Celcius */ -#define MAXI_SYSCTL_TEMP3 1203 /* Degrees Celcius */ -#define MAXI_SYSCTL_TEMP4 1204 /* Degrees Celcius */ -#define MAXI_SYSCTL_TEMP5 1205 /* Degrees Celcius */ -#define MAXI_SYSCTL_TEMP6 1206 /* Degrees Celcius */ -#define MAXI_SYSCTL_PLL 1301 /* MHz */ -#define MAXI_SYSCTL_VID1 1401 /* Volts / 6.337, for nba just Volts */ -#define MAXI_SYSCTL_VID2 1402 /* Volts */ -#define MAXI_SYSCTL_VID3 1403 /* Volts */ -#define MAXI_SYSCTL_VID4 1404 /* Volts */ -#define MAXI_SYSCTL_VID5 1405 /* Volts */ -#define MAXI_SYSCTL_LCD1 1501 /* Line 1 of LCD */ -#define MAXI_SYSCTL_LCD2 1502 /* Line 2 of LCD */ -#define MAXI_SYSCTL_LCD3 1503 /* Line 3 of LCD */ -#define MAXI_SYSCTL_LCD4 1504 /* Line 4 of LCD */ -#define MAXI_SYSCTL_ALARMS 2001 /* Bitvector (see below) */ - -#define MAXI_ALARM_VID4 0x0001 -#define MAXI_ALARM_TEMP2 0x0002 -#define MAXI_ALARM_VID1 0x0004 -#define MAXI_ALARM_VID2 0x0008 -#define MAXI_ALARM_VID3 0x0010 -#define MAXI_ALARM_PLL 0x0080 -#define MAXI_ALARM_TEMP4 0x0100 -#define MAXI_ALARM_TEMP5 0x0200 -#define MAXI_ALARM_FAN1 0x1000 -#define MAXI_ALARM_FAN2 0x2000 -#define MAXI_ALARM_FAN3 0x4000 - -#define MAXI_ALARM_FAN 0x0100 /* To be used with MaxiLife'99 */ -#define MAXI_ALARM_VID 0x0200 /* The MSB specifies which sensor */ -#define MAXI_ALARM_TEMP 0x0400 /* in the alarm group failed, i.e.: */ -#define MAXI_ALARM_VADD 0x0800 /* 0x0402 = TEMP2 failed = CPU2 temp */ - -#define SIS5595_SYSCTL_IN0 1000 /* Volts * 100 */ -#define SIS5595_SYSCTL_IN1 1001 -#define SIS5595_SYSCTL_IN2 1002 -#define SIS5595_SYSCTL_IN3 1003 -#define SIS5595_SYSCTL_IN4 1004 -#define SIS5595_SYSCTL_FAN1 1101 /* Rotations/min */ -#define SIS5595_SYSCTL_FAN2 1102 -#define SIS5595_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ -#define SIS5595_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define SIS5595_SYSCTL_ALARMS 2001 /* bitvector */ - -#define SIS5595_ALARM_IN0 0x01 -#define SIS5595_ALARM_IN1 0x02 -#define SIS5595_ALARM_IN2 0x04 -#define SIS5595_ALARM_IN3 0x08 -#define SIS5595_ALARM_BTI 0x20 -#define SIS5595_ALARM_FAN1 0x40 -#define SIS5595_ALARM_FAN2 0x80 -#define SIS5595_ALARM_IN4 0x8000 -#define SIS5595_ALARM_TEMP 0x8000 - -#define VIA686A_SYSCTL_IN0 1000 -#define VIA686A_SYSCTL_IN1 1001 -#define VIA686A_SYSCTL_IN2 1002 -#define VIA686A_SYSCTL_IN3 1003 -#define VIA686A_SYSCTL_IN4 1004 -#define VIA686A_SYSCTL_FAN1 1101 -#define VIA686A_SYSCTL_FAN2 1102 -#define VIA686A_SYSCTL_TEMP 1200 -#define VIA686A_SYSCTL_TEMP2 1201 -#define VIA686A_SYSCTL_TEMP3 1202 -#define VIA686A_SYSCTL_FAN_DIV 2000 -#define VIA686A_SYSCTL_ALARMS 2001 - -#define VIA686A_ALARM_IN0 0x01 -#define VIA686A_ALARM_IN1 0x02 -#define VIA686A_ALARM_IN2 0x04 -#define VIA686A_ALARM_IN3 0x08 -#define VIA686A_ALARM_TEMP 0x10 -#define VIA686A_ALARM_FAN1 0x40 -#define VIA686A_ALARM_FAN2 0x80 -#define VIA686A_ALARM_IN4 0x100 -#define VIA686A_ALARM_TEMP2 0x800 -#define VIA686A_ALARM_CHAS 0x1000 -#define VIA686A_ALARM_TEMP3 0x8000 - -#define ICSPLL_SYSCTL1 1000 - -#define BT869_SYSCTL_STATUS 1000 -#define BT869_SYSCTL_NTSC 1001 -#define BT869_SYSCTL_HALF 1002 -#define BT869_SYSCTL_RES 1003 -#define BT869_SYSCTL_COLORBARS 1004 -#define BT869_SYSCTL_DEPTH 1005 -#define BT869_SYSCTL_SVIDEO 1006 - -#define MATORB_SYSCTL_DISP 1000 - -#define THMC50_SYSCTL_TEMP 1200 /* Degrees Celcius */ -#define THMC50_SYSCTL_REMOTE_TEMP 1201 /* Degrees Celcius */ -#define THMC50_SYSCTL_INTER 1202 -#define THMC50_SYSCTL_INTER_MASK 1203 -#define THMC50_SYSCTL_DIE_CODE 1204 -#define THMC50_SYSCTL_ANALOG_OUT 1205 - -#define DDCMON_SYSCTL_ID 1010 -#define DDCMON_SYSCTL_SIZE 1011 -#define DDCMON_SYSCTL_SYNC 1012 -#define DDCMON_SYSCTL_TIMINGS 1013 -#define DDCMON_SYSCTL_SERIAL 1014 - -#define LM87_SYSCTL_IN0 1000 /* Volts * 100 */ -#define LM87_SYSCTL_IN1 1001 -#define LM87_SYSCTL_IN2 1002 -#define LM87_SYSCTL_IN3 1003 -#define LM87_SYSCTL_IN4 1004 -#define LM87_SYSCTL_IN5 1005 -#define LM87_SYSCTL_AIN1 1006 -#define LM87_SYSCTL_AIN2 1007 -#define LM87_SYSCTL_FAN1 1102 -#define LM87_SYSCTL_FAN2 1103 -#define LM87_SYSCTL_TEMP1 1250 /* Degrees Celcius * 100 */ -#define LM87_SYSCTL_TEMP2 1251 /* Degrees Celcius * 100 */ -#define LM87_SYSCTL_TEMP3 1252 /* Degrees Celcius * 100 */ -#define LM87_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define LM87_SYSCTL_ALARMS 2001 /* bitvector */ -#define LM87_SYSCTL_ANALOG_OUT 2002 -#define LM87_SYSCTL_VID 2003 -#define LM87_SYSCTL_VRM 2004 - -#define LM87_ALARM_IN0 0x0001 -#define LM87_ALARM_IN1 0x0002 -#define LM87_ALARM_IN2 0x0004 -#define LM87_ALARM_IN3 0x0008 -#define LM87_ALARM_TEMP1 0x0010 -#define LM87_ALARM_TEMP2 0x0020 -#define LM87_ALARM_TEMP3 0x0020 /* same?? */ -#define LM87_ALARM_FAN1 0x0040 -#define LM87_ALARM_FAN2 0x0080 -#define LM87_ALARM_IN4 0x0100 -#define LM87_ALARM_IN5 0x0200 -#define LM87_ALARM_RESERVED1 0x0400 -#define LM87_ALARM_RESERVED2 0x0800 -#define LM87_ALARM_CHAS 0x1000 -#define LM87_ALARM_THERM_SIG 0x2000 -#define LM87_ALARM_TEMP2_FAULT 0x4000 -#define LM87_ALARM_TEMP3_FAULT 0x08000 - -#define PCF8574_SYSCTL_READ 1000 -#define PCF8574_SYSCTL_WRITE 1001 - -#define MTP008_SYSCTL_IN0 1000 /* Volts * 100 */ -#define MTP008_SYSCTL_IN1 1001 -#define MTP008_SYSCTL_IN2 1002 -#define MTP008_SYSCTL_IN3 1003 -#define MTP008_SYSCTL_IN4 1004 -#define MTP008_SYSCTL_IN5 1005 -#define MTP008_SYSCTL_IN6 1006 -#define MTP008_SYSCTL_FAN1 1101 /* Rotations/min */ -#define MTP008_SYSCTL_FAN2 1102 -#define MTP008_SYSCTL_FAN3 1103 -#define MTP008_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ -#define MTP008_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ -#define MTP008_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ -#define MTP008_SYSCTL_VID 1300 /* Volts * 100 */ -#define MTP008_SYSCTL_PWM1 1401 -#define MTP008_SYSCTL_PWM2 1402 -#define MTP008_SYSCTL_PWM3 1403 -#define MTP008_SYSCTL_SENS1 1501 /* 1, 2, or Beta (3000-5000) */ -#define MTP008_SYSCTL_SENS2 1502 -#define MTP008_SYSCTL_SENS3 1503 -#define MTP008_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define MTP008_SYSCTL_ALARMS 2001 /* bitvector */ -#define MTP008_SYSCTL_BEEP 2002 /* bitvector */ - -#define MTP008_ALARM_IN0 0x0001 -#define MTP008_ALARM_IN1 0x0002 -#define MTP008_ALARM_IN2 0x0004 -#define MTP008_ALARM_IN3 0x0008 -#define MTP008_ALARM_IN4 0x0100 -#define MTP008_ALARM_IN5 0x0200 -#define MTP008_ALARM_IN6 0x0400 -#define MTP008_ALARM_FAN1 0x0040 -#define MTP008_ALARM_FAN2 0x0080 -#define MTP008_ALARM_FAN3 0x0800 -#define MTP008_ALARM_TEMP1 0x0010 -#define MTP008_ALARM_TEMP2 0x0100 -#define MTP008_ALARM_TEMP3 0x0200 - -#define DS1621_SYSCTL_TEMP 1200 /* Degrees Celcius * 10 */ -#define DS1621_SYSCTL_ALARMS 2001 /* bitvector */ -#define DS1621_ALARM_TEMP_HIGH 0x40 -#define DS1621_ALARM_TEMP_LOW 0x20 -#define DS1621_SYSCTL_ENABLE 2002 -#define DS1621_SYSCTL_CONTINUOUS 2003 -#define DS1621_SYSCTL_POLARITY 2004 - -#define IT87_SYSCTL_IN0 1000 /* Volts * 100 */ -#define IT87_SYSCTL_IN1 1001 -#define IT87_SYSCTL_IN2 1002 -#define IT87_SYSCTL_IN3 1003 -#define IT87_SYSCTL_IN4 1004 -#define IT87_SYSCTL_IN5 1005 -#define IT87_SYSCTL_IN6 1006 -#define IT87_SYSCTL_IN7 1007 -#define IT87_SYSCTL_IN8 1008 -#define IT87_SYSCTL_FAN1 1101 /* Rotations/min */ -#define IT87_SYSCTL_FAN2 1102 -#define IT87_SYSCTL_FAN3 1103 -#define IT87_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ -#define IT87_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ -#define IT87_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ -#define IT87_SYSCTL_VID 1300 /* Volts * 100 */ -#define IT87_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define IT87_SYSCTL_ALARMS 2004 /* bitvector */ - -#define IT87_ALARM_IN0 0x000100 -#define IT87_ALARM_IN1 0x000200 -#define IT87_ALARM_IN2 0x000400 -#define IT87_ALARM_IN3 0x000800 -#define IT87_ALARM_IN4 0x001000 -#define IT87_ALARM_IN5 0x002000 -#define IT87_ALARM_IN6 0x004000 -#define IT87_ALARM_IN7 0x008000 -#define IT87_ALARM_FAN1 0x0001 -#define IT87_ALARM_FAN2 0x0002 -#define IT87_ALARM_FAN3 0x0004 -#define IT87_ALARM_TEMP1 0x00010000 -#define IT87_ALARM_TEMP2 0x00020000 -#define IT87_ALARM_TEMP3 0x00040000 - -#define FSCPOS_SYSCTL_VOLT0 1000 /* 12 volt supply */ -#define FSCPOS_SYSCTL_VOLT1 1001 /* 5 volt supply */ -#define FSCPOS_SYSCTL_VOLT2 1002 /* batterie voltage*/ -#define FSCPOS_SYSCTL_FAN0 1101 /* state, min, ripple, actual value fan 0 */ -#define FSCPOS_SYSCTL_FAN1 1102 /* state, min, ripple, actual value fan 1 */ -#define FSCPOS_SYSCTL_FAN2 1103 /* state, min, ripple, actual value fan 2 */ -#define FSCPOS_SYSCTL_TEMP0 1201 /* state and value of sensor 0, cpu die */ -#define FSCPOS_SYSCTL_TEMP1 1202 /* state and value of sensor 1, motherboard */ -#define FSCPOS_SYSCTL_TEMP2 1203 /* state and value of sensor 2, chassis */ -#define FSCPOS_SYSCTL_REV 2000 /* Revision */ -#define FSCPOS_SYSCTL_EVENT 2001 /* global event status */ -#define FSCPOS_SYSCTL_CONTROL 2002 /* global control byte */ -#define FSCPOS_SYSCTL_WDOG 2003 /* state, min, ripple, actual value fan 2 */ - -#define FSCSCY_SYSCTL_VOLT0 1000 /* 12 volt supply */ -#define FSCSCY_SYSCTL_VOLT1 1001 /* 5 volt supply */ -#define FSCSCY_SYSCTL_VOLT2 1002 /* batterie voltage*/ -#define FSCSCY_SYSCTL_FAN0 1101 /* state, min, ripple, actual value fan 0 */ -#define FSCSCY_SYSCTL_FAN1 1102 /* state, min, ripple, actual value fan 1 */ -#define FSCSCY_SYSCTL_FAN2 1103 /* state, min, ripple, actual value fan 2 */ -#define FSCSCY_SYSCTL_FAN3 1104 /* state, min, ripple, actual value fan 3 */ -#define FSCSCY_SYSCTL_FAN4 1105 /* state, min, ripple, actual value fan 4 */ -#define FSCSCY_SYSCTL_FAN5 1106 /* state, min, ripple, actual value fan 5 */ -#define FSCSCY_SYSCTL_TEMP0 1201 /* state and value of sensor 0, cpu die */ -#define FSCSCY_SYSCTL_TEMP1 1202 /* state and value of sensor 1, motherboard */ -#define FSCSCY_SYSCTL_TEMP2 1203 /* state and value of sensor 2, chassis */ -#define FSCSCY_SYSCTL_TEMP3 1204 /* state and value of sensor 3, chassis */ -#define FSCSCY_SYSCTL_REV 2000 /* Revision */ -#define FSCSCY_SYSCTL_EVENT 2001 /* global event status */ -#define FSCSCY_SYSCTL_CONTROL 2002 /* global control byte */ -#define FSCSCY_SYSCTL_WDOG 2003 /* state, min, ripple, actual value fan 2 */ -#define FSCSCY_SYSCTL_PCILOAD 2004 /* PCILoad value */ -#define FSCSCY_SYSCTL_INTRUSION 2005 /* state, control for intrusion sensor */ - -#define PCF8591_SYSCTL_AIN_CONF 1000 /* Analog input configuration */ -#define PCF8591_SYSCTL_CH0 1001 /* Input channel 1 */ -#define PCF8591_SYSCTL_CH1 1002 /* Input channel 2 */ -#define PCF8591_SYSCTL_CH2 1003 /* Input channel 3 */ -#define PCF8591_SYSCTL_CH3 1004 /* Input channel 4 */ -#define PCF8591_SYSCTL_AOUT_ENABLE 1005 /* Analog output enable flag */ -#define PCF8591_SYSCTL_AOUT 1006 /* Analog output */ - -#define ARP_SYSCTL1 1000 -#define ARP_SYSCTL2 1001 -#define ARP_SYSCTL3 1002 -#define ARP_SYSCTL4 1003 -#define ARP_SYSCTL5 1004 -#define ARP_SYSCTL6 1005 -#define ARP_SYSCTL7 1006 -#define ARP_SYSCTL8 1007 - -#define SMSC47M1_SYSCTL_FAN1 1101 /* Rotations/min */ -#define SMSC47M1_SYSCTL_FAN2 1102 -#define SMSC47M1_SYSCTL_PWM1 1401 -#define SMSC47M1_SYSCTL_PWM2 1402 -#define SMSC47M1_SYSCTL_FAN_DIV 2000 /* 1, 2, 4 or 8 */ -#define SMSC47M1_SYSCTL_ALARMS 2004 /* bitvector */ - -#define SMSC47M1_ALARM_FAN1 0x0001 -#define SMSC47M1_ALARM_FAN2 0x0002 - -#define VT1211_SYSCTL_IN0 1000 -#define VT1211_SYSCTL_IN1 1001 -#define VT1211_SYSCTL_IN2 1002 -#define VT1211_SYSCTL_IN3 1003 -#define VT1211_SYSCTL_IN4 1004 -#define VT1211_SYSCTL_IN5 1005 -#define VT1211_SYSCTL_IN6 1006 -#define VT1211_SYSCTL_FAN1 1101 -#define VT1211_SYSCTL_FAN2 1102 -#define VT1211_SYSCTL_TEMP 1200 -#define VT1211_SYSCTL_TEMP2 1201 -#define VT1211_SYSCTL_TEMP3 1202 -#define VT1211_SYSCTL_TEMP4 1203 -#define VT1211_SYSCTL_TEMP5 1204 -#define VT1211_SYSCTL_TEMP6 1205 -#define VT1211_SYSCTL_TEMP7 1206 -#define VT1211_SYSCTL_VID 1300 -#define VT1211_SYSCTL_PWM1 1401 -#define VT1211_SYSCTL_PWM2 1402 -#define VT1211_SYSCTL_VRM 1600 -#define VT1211_SYSCTL_UCH 1700 -#define VT1211_SYSCTL_FAN_DIV 2000 -#define VT1211_SYSCTL_ALARMS 2001 - -#define VT1211_ALARM_IN1 0x01 -#define VT1211_ALARM_IN2 0x02 -#define VT1211_ALARM_IN5 0x04 -#define VT1211_ALARM_IN3 0x08 -#define VT1211_ALARM_TEMP 0x10 -#define VT1211_ALARM_FAN1 0x40 -#define VT1211_ALARM_FAN2 0x80 -#define VT1211_ALARM_IN4 0x100 -#define VT1211_ALARM_IN6 0x200 -#define VT1211_ALARM_TEMP2 0x800 -#define VT1211_ALARM_CHAS 0x1000 -#define VT1211_ALARM_TEMP3 0x8000 -/* duplicates */ -#define VT1211_ALARM_IN0 VT1211_ALARM_TEMP -#define VT1211_ALARM_TEMP4 VT1211_ALARM_IN1 -#define VT1211_ALARM_TEMP5 VT1211_ALARM_IN2 -#define VT1211_ALARM_TEMP6 VT1211_ALARM_IN3 -#define VT1211_ALARM_TEMP7 VT1211_ALARM_IN4 - -#define LM92_SYSCTL_ALARMS 2001 /* high, low, critical */ -#define LM92_SYSCTL_TEMP 1200 /* high, low, critical, hysterisis, input */ - -#define LM92_ALARM_TEMP_HIGH 0x01 -#define LM92_ALARM_TEMP_LOW 0x02 -#define LM92_ALARM_TEMP_CRIT 0x04 -#define LM92_TEMP_HIGH 0x08 -#define LM92_TEMP_LOW 0x10 -#define LM92_TEMP_CRIT 0x20 -#define LM92_TEMP_HYST 0x40 -#define LM92_TEMP_INPUT 0x80 - -#define VT8231_SYSCTL_IN0 1000 -#define VT8231_SYSCTL_IN1 1001 -#define VT8231_SYSCTL_IN2 1002 -#define VT8231_SYSCTL_IN3 1003 -#define VT8231_SYSCTL_IN4 1004 -#define VT8231_SYSCTL_IN5 1005 -#define VT8231_SYSCTL_IN6 1006 -#define VT8231_SYSCTL_FAN1 1101 -#define VT8231_SYSCTL_FAN2 1102 -#define VT8231_SYSCTL_TEMP 1200 -#define VT8231_SYSCTL_TEMP2 1201 -#define VT8231_SYSCTL_TEMP3 1202 -#define VT8231_SYSCTL_TEMP4 1203 -#define VT8231_SYSCTL_TEMP5 1204 -#define VT8231_SYSCTL_TEMP6 1205 -#define VT8231_SYSCTL_TEMP7 1206 -#define VT8231_SYSCTL_VID 1300 -#define VT8231_SYSCTL_PWM1 1401 -#define VT8231_SYSCTL_PWM2 1402 -#define VT8231_SYSCTL_VRM 1600 -#define VT8231_SYSCTL_UCH 1700 -#define VT8231_SYSCTL_FAN_DIV 2000 -#define VT8231_SYSCTL_ALARMS 2001 - -#define VT8231_ALARM_IN1 0x01 -#define VT8231_ALARM_IN2 0x02 -#define VT8231_ALARM_IN5 0x04 -#define VT8231_ALARM_IN3 0x08 -#define VT8231_ALARM_TEMP 0x10 -#define VT8231_ALARM_FAN1 0x40 -#define VT8231_ALARM_FAN2 0x80 -#define VT8231_ALARM_IN4 0x100 -#define VT8231_ALARM_IN6 0x200 -#define VT8231_ALARM_TEMP2 0x800 -#define VT8231_ALARM_CHAS 0x1000 -#define VT8231_ALARM_TEMP3 0x8000 -/* duplicates */ -#define VT8231_ALARM_IN0 VT8231_ALARM_TEMP -#define VT8231_ALARM_TEMP4 VT8231_ALARM_IN1 -#define VT8231_ALARM_TEMP5 VT8231_ALARM_IN2 -#define VT8231_ALARM_TEMP6 VT8231_ALARM_IN3 -#define VT8231_ALARM_TEMP7 VT8231_ALARM_IN4 - -#define SMARTBATT_SYSCTL_I 1001 -#define SMARTBATT_SYSCTL_V 1002 -#define SMARTBATT_SYSCTL_TEMP 1003 -#define SMARTBATT_SYSCTL_TIME 1004 -#define SMARTBATT_SYSCTL_ALARMS 1005 -#define SMARTBATT_SYSCTL_CHARGE 1006 - - -#endif /* def SENSORS_SENSORS_H */ -- cgit v1.2.3 From 2cea9523ee55d8bda0b14287d5761c956868572c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 29 Dec 2002 19:52:11 -0800 Subject: [PATCH] more obsolete module API fixes completly remove the old try_inc_mod_count() --- drivers/block/genhd.c | 4 ++-- drivers/char/busmouse.c | 2 +- drivers/ide/ide.c | 2 +- drivers/ieee1394/ieee1394_core.c | 3 +-- drivers/isdn/capi/capi.c | 11 ++--------- drivers/isdn/capi/kcapi.c | 12 +++--------- drivers/isdn/eicon/eicon_mod.c | 10 ---------- drivers/isdn/hardware/eicon/i4lididrv.c | 10 ---------- drivers/isdn/hisax/callc.c | 3 --- drivers/media/video/cpia.c | 2 +- drivers/mtd/chips/chipreg.c | 2 +- drivers/net/irda/sir_dev.c | 6 +----- drivers/net/irda/sir_dongle.c | 6 +++--- drivers/s390/block/dasd.c | 2 +- drivers/s390/block/dasd_ioctl.c | 11 ++++------- drivers/s390/char/tape_core.c | 2 +- drivers/serial/core.c | 2 +- fs/devfs/base.c | 2 +- fs/dquot.c | 2 +- fs/exec.c | 4 ++-- fs/filesystems.c | 10 +++++----- fs/nls/nls_base.c | 4 ++-- include/linux/fs.h | 10 ++-------- include/linux/module.h | 1 - include/linux/mtd/mtd.h | 5 +---- kernel/exec_domain.c | 4 ++-- kernel/intermodule.c | 2 +- net/core/dev.c | 2 +- net/ipv4/xfrm_policy.c | 2 +- net/rxrpc/krxsecd.c | 2 +- sound/core/control.c | 2 +- sound/core/info.c | 2 +- sound/core/init.c | 7 ++----- sound/core/oss/mixer_oss.c | 2 +- sound/core/oss/pcm_oss.c | 2 +- sound/core/pcm_native.c | 2 +- sound/core/rawmidi.c | 2 +- sound/core/seq/oss/seq_oss_synth.c | 2 +- sound/core/seq/seq_ports.c | 2 +- sound/core/seq/seq_virmidi.c | 4 ++-- sound/core/timer.c | 2 +- sound/drivers/opl3/opl3_seq.c | 2 +- sound/isa/gus/gus_main.c | 2 +- sound/isa/wavefront/wavefront_fx.c | 2 +- sound/isa/wavefront/wavefront_synth.c | 2 +- sound/synth/emux/emux_seq.c | 4 ++-- 46 files changed, 62 insertions(+), 119 deletions(-) (limited to 'include/linux') diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index c133b454b2fb..c7541b2fe264 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -160,7 +160,7 @@ retry: read_unlock(&gendisk_lock); return NULL; } - if (!try_inc_mod_count(p->owner)) + if (!try_module_get(p->owner)) continue; owner = p->owner; data = p->data; @@ -422,7 +422,7 @@ struct gendisk *get_disk(struct gendisk *disk) if (!disk->fops) return NULL; owner = disk->fops->owner; - if (owner && !try_inc_mod_count(owner)) + if (owner && !try_module_get(owner)) return NULL; return to_disk(kobject_get(&disk->kobj)); } diff --git a/drivers/char/busmouse.c b/drivers/char/busmouse.c index 85baa0cdf51b..c574177b5418 100644 --- a/drivers/char/busmouse.c +++ b/drivers/char/busmouse.c @@ -200,7 +200,7 @@ static int busmouse_open(struct inode *inode, struct file *file) if (!mse || !mse->ops) /* shouldn't happen, but... */ goto end; - if (mse->ops->owner && !try_inc_mod_count(mse->ops->owner)) + if (!try_module_get(mse->ops->owner)) goto end; ret = 0; diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 0ae396abfcc1..a138e13d6b44 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1332,7 +1332,7 @@ int ata_attach(ide_drive_t *drive) spin_lock(&drivers_lock); list_for_each(p, &drivers) { ide_driver_t *driver = list_entry(p, ide_driver_t, drivers); - if (!try_inc_mod_count(driver->owner)) + if (!try_module_get(driver->owner)) continue; spin_unlock(&drivers_lock); if (driver->attach(drive) == 0) { diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index b5e00b4b12b5..5433a0466ce9 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -1066,8 +1066,7 @@ static int ieee1394_get_chardev(int blocknum, if(*file_ops == NULL) goto out; - /* don't need try_inc_mod_count if the driver is non-modular */ - if(*module && (try_inc_mod_count(*module) == 0)) + if(!try_module_get(*module)) goto out; /* success! */ diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index ad595be2a0a6..4e01b76e1fcb 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -207,9 +207,7 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci) printk(KERN_ERR "capi: can't alloc capiminor\n"); return 0; } -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capiminor_alloc %d\n", GET_USE_COUNT(THIS_MODULE)); -#endif + memset(mp, 0, sizeof(struct capiminor)); mp->ap = ap; mp->ncci = ncci; @@ -252,9 +250,6 @@ static void capiminor_free(struct capiminor *mp) capiminor_del_all_ack(mp); kfree(mp); MOD_DEC_USE_COUNT; -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capiminor_free %d\n", GET_USE_COUNT(THIS_MODULE)); -#endif } struct capiminor *capiminor_find(unsigned int minor) @@ -980,9 +975,7 @@ static int capinc_tty_open(struct tty_struct * tty, struct file * file) return -ENXIO; tty->driver_data = (void *)mp; -#ifdef _DEBUG_REFCOUNT - printk(KERN_DEBUG "capi_tty_open %d\n", GET_USE_COUNT(THIS_MODULE)); -#endif + if (atomic_read(&mp->ttyopencount) == 0) mp->tty = tty; atomic_inc(&mp->ttyopencount); diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 337124784e9c..0e07e706a576 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -77,15 +77,9 @@ static struct work_struct tq_recv_notify; static inline struct capi_ctr * capi_ctr_get(struct capi_ctr *card) { - if (card->owner) { - if (try_inc_mod_count(card->owner)) { - DBG("MOD_COUNT INC"); - return card; - } else - return NULL; - } - DBG("MOD_COUNT INC"); - return card; + if (try_module_get(card->owner)) + return card; + return NULL; } static inline void diff --git a/drivers/isdn/eicon/eicon_mod.c b/drivers/isdn/eicon/eicon_mod.c index 54edc7d3f470..4fd7dbcb6968 100644 --- a/drivers/isdn/eicon/eicon_mod.c +++ b/drivers/isdn/eicon/eicon_mod.c @@ -54,10 +54,6 @@ extern int do_ioctl(struct inode *pDivasInode, struct file *pDivasFile, unsigned int command, unsigned long arg); extern void eicon_pci_init_conf(eicon_card *card); -#ifdef MODULE -#define MOD_USE_COUNT (GET_USE_COUNT (&__this_module)) -#endif - #define EICON_CTRL_VERSION 2 ulong DebugVar; @@ -370,12 +366,6 @@ eicon_command(eicon_card * card, isdn_ctrl * c) DebugVar = a; eicon_log(card, 1, "Eicon: Debug Value set to %ld\n", DebugVar); return 0; -#ifdef MODULE - case EICON_IOCTL_FREEIT: - while (MOD_USE_COUNT > 0) MOD_DEC_USE_COUNT; - MOD_INC_USE_COUNT; - return 0; -#endif case EICON_IOCTL_LOADPCI: eicon_log(card, 1, "Eicon: Wrong version of load-utility,\n"); eicon_log(card, 1, "Eicon: re-compile eiconctrl !\n"); diff --git a/drivers/isdn/hardware/eicon/i4lididrv.c b/drivers/isdn/hardware/eicon/i4lididrv.c index d086cdd17d00..38cf7c984607 100644 --- a/drivers/isdn/hardware/eicon/i4lididrv.c +++ b/drivers/isdn/hardware/eicon/i4lididrv.c @@ -40,10 +40,6 @@ static char *DRIVERRELEASE = "2.0"; static char *eicon_revision = "$Revision: 1.1.2.2 $"; extern char *eicon_idi_revision; -#ifdef MODULE -#define MOD_USE_COUNT (GET_USE_COUNT (&__this_module)) -#endif - #define EICON_CTRL_VERSION 2 ulong DebugVar; @@ -507,12 +503,6 @@ eicon_command(eicon_card * card, isdn_ctrl * c) DebugVar = a; eicon_log(card, 1, "%s: Debug Value set to %ld\n", DRIVERLNAME, DebugVar); return 0; -#ifdef MODULE - case EICON_IOCTL_FREEIT: - while (MOD_USE_COUNT > 0) MOD_DEC_USE_COUNT; - MOD_INC_USE_COUNT; - return 0; -#endif case EICON_IOCTL_LOADPCI: eicon_log(card, 1, "%s: Wrong version of load-utility,\n", DRIVERLNAME); eicon_log(card, 1, "%s: re-compile eiconctrl !\n", DRIVERLNAME); diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c index 4e366732644d..d2958c806c62 100644 --- a/drivers/isdn/hisax/callc.c +++ b/drivers/isdn/hisax/callc.c @@ -21,9 +21,6 @@ #include "hisax.h" #include -#ifdef MODULE -#define MOD_USE_COUNT ( GET_USE_COUNT (&__this_module)) -#endif /* MODULE */ const char *lli_revision = "$Revision: 2.51.6.6 $"; diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index bcc26db53c6a..af042ec7b2ad 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -3173,7 +3173,7 @@ static int cpia_open(struct inode *inode, struct file *file) return -ENODEV; } - if (!try_inc_mod_count(cam->ops->owner)) + if (!try_module_get(cam->ops->owner)) return -ENODEV; down(&cam->busy_lock); diff --git a/drivers/mtd/chips/chipreg.c b/drivers/mtd/chips/chipreg.c index efdd7ee41d34..b33292c88be6 100644 --- a/drivers/mtd/chips/chipreg.c +++ b/drivers/mtd/chips/chipreg.c @@ -44,7 +44,7 @@ static struct mtd_chip_driver *get_mtd_chip_driver (char *name) break; } } - if (ret && !try_inc_mod_count(ret->module)) { + if (ret && !try_module_get(ret->module)) { /* Eep. Failed. */ ret = NULL; } diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index a27737026547..09823085fa2d 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c @@ -466,13 +466,9 @@ static int sirdev_open(struct net_device *ndev) if (!drv) return -ENODEV; - lock_kernel(); /* serialize with rmmod */ /* increase the reference count of the driver module before doing serious stuff */ - if (drv->owner && !try_inc_mod_count(drv->owner)) { - unlock_kernel(); + if (!try_module_get(drv->owner)) return -ESTALE; - } - unlock_kernel(); IRDA_DEBUG(2, "%s()\n", __FUNCTION__); diff --git a/drivers/net/irda/sir_dongle.c b/drivers/net/irda/sir_dongle.c index cf7a17a002d3..b23cd3480519 100644 --- a/drivers/net/irda/sir_dongle.c +++ b/drivers/net/irda/sir_dongle.c @@ -95,13 +95,13 @@ int sirdev_get_dongle(struct sir_dev *dev, IRDA_DONGLE type) * 1) dongle driver was already unregistered - then we haven't found the * requested dongle above and are already out here * 2) the module is already marked deleted but the driver is still - * registered - then the try_inc_mod_count() below will fail - * 3) the try_inc_mod_count() below succeeds before the module is marked + * registered - then the try_module_get() below will fail + * 3) the try_module_get() below succeeds before the module is marked * deleted - then sys_delete_module() fails and prevents the removal * because the module is in use. */ - if (drv->owner && !try_inc_mod_count(drv->owner)) { + if (!try_module_get(drv->owner)) { err = -ESTALE; goto out_unlock; /* rmmod already pending */ } diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 8eedee623a04..5be431297f86 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1734,7 +1734,7 @@ dasd_open(struct inode *inp, struct file *filp) rc = 0; if (atomic_inc_return(&device->open_count) == 1) { - if (!try_inc_mod_count(device->discipline->owner)) { + if (!try_module_get(device->discipline->owner)) { /* Discipline is currently unloaded! */ atomic_dec(&device->open_count); rc = -ENODEV; diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index 9047d68fb20a..e570db2497bd 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -111,13 +111,10 @@ dasd_ioctl(struct inode *inp, struct file *filp, ioctl = list_entry(l, dasd_ioctl_list_t, list); if (ioctl->no == no) { /* Found a matching ioctl. Call it. */ - if (ioctl->owner) { - if (try_inc_mod_count(ioctl->owner) != 0) - continue; - rc = ioctl->handler(bdev, no, data); - module_put(ioctl->owner); - } else - rc = ioctl->handler(bdev, no, data); + if (try_module_get(ioctl->owner) != 0) + continue; + rc = ioctl->handler(bdev, no, data); + module_put(ioctl->owner); return rc; } } diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c index af71fadf2f52..7da7493a6a63 100644 --- a/drivers/s390/char/tape_core.c +++ b/drivers/s390/char/tape_core.c @@ -837,7 +837,7 @@ tape_open(struct tape_device *device) DBF_EVENT(6, "TAPE:dbusy\n"); rc = -EBUSY; } else if (device->discipline != NULL && - !try_inc_mod_count(device->discipline->owner)) { + !try_module_get(device->discipline->owner)) { DBF_EVENT(6, "TAPE:nodisc\n"); rc = -ENODEV; } else { diff --git a/drivers/serial/core.c b/drivers/serial/core.c index 39fe785bf275..22d42e3b18e9 100644 --- a/drivers/serial/core.c +++ b/drivers/serial/core.c @@ -1584,7 +1584,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp) * is about to be unloaded). Therefore, it is safe to set * tty->driver_data to be NULL, so uart_close() doesn't bite us. */ - if (!try_inc_mod_count(drv->owner)) { + if (!try_module_get(drv->owner)) { tty->driver_data = NULL; goto fail; } diff --git a/fs/devfs/base.c b/fs/devfs/base.c index 186dc63d327b..b4cbba51d30e 100644 --- a/fs/devfs/base.c +++ b/fs/devfs/base.c @@ -1874,7 +1874,7 @@ static struct file_operations *devfs_get_ops (devfs_handle_t de) return NULL; owner = ops->owner; read_lock (&de->parent->u.dir.lock); /* Prevent module from unloading */ - if ( (de->next == de) || !try_inc_mod_count (owner) ) + if ( (de->next == de) || !try_module_get (owner) ) { /* Entry is already unhooked or module is unloading */ read_unlock (&de->parent->u.dir.lock); return NULL; diff --git a/fs/dquot.c b/fs/dquot.c index 8781f7201a87..4d8ea00be1f9 100644 --- a/fs/dquot.c +++ b/fs/dquot.c @@ -103,7 +103,7 @@ static struct quota_format_type *find_quota_format(int id) lock_kernel(); for (actqf = quota_formats; actqf && actqf->qf_fmt_id != id; actqf = actqf->qf_next); - if (actqf && !try_inc_mod_count(actqf->qf_owner)) + if (actqf && !try_module_get:(actqf->qf_owner)) actqf = NULL; unlock_kernel(); return actqf; diff --git a/fs/exec.c b/fs/exec.c index 901b8e12388f..8f0b41fd3a28 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -142,7 +142,7 @@ asmlinkage long sys_uselib(const char * library) for (fmt = formats ; fmt ; fmt = fmt->next) { if (!fmt->load_shlib) continue; - if (!try_inc_mod_count(fmt->module)) + if (!try_module_get(fmt->module)) continue; read_unlock(&binfmt_lock); error = fmt->load_shlib(file); @@ -971,7 +971,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs) int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary; if (!fn) continue; - if (!try_inc_mod_count(fmt->module)) + if (!try_module_get(fmt->module)) continue; read_unlock(&binfmt_lock); retval = fn(bprm, regs); diff --git a/fs/filesystems.c b/fs/filesystems.c index 223305689d30..824b04137c3a 100644 --- a/fs/filesystems.c +++ b/fs/filesystems.c @@ -20,7 +20,7 @@ * We can access the fields of list element if: * 1) spinlock is held or * 2) we hold the reference to the module. - * The latter can be guaranteed by call of try_inc_mod_count(); if it + * The latter can be guaranteed by call of try_module_get(); if it * returned 0 we must skip the element, otherwise we got the reference. * Once the reference is obtained we can drop the spinlock. */ @@ -153,8 +153,8 @@ static int fs_name(unsigned int index, char * buf) read_lock(&file_systems_lock); for (tmp = file_systems; tmp; tmp = tmp->next, index--) - if (index <= 0 && try_inc_mod_count(tmp->owner)) - break; + if (index <= 0 && try_module_get(tmp->owner)) + break; read_unlock(&file_systems_lock); if (!tmp) return -EINVAL; @@ -224,13 +224,13 @@ struct file_system_type *get_fs_type(const char *name) read_lock(&file_systems_lock); fs = *(find_filesystem(name)); - if (fs && !try_inc_mod_count(fs->owner)) + if (fs && !try_module_get(fs->owner)) fs = NULL; read_unlock(&file_systems_lock); if (!fs && (request_module(name) == 0)) { read_lock(&file_systems_lock); fs = *(find_filesystem(name)); - if (fs && !try_inc_mod_count(fs->owner)) + if (fs && !try_module_get(fs->owner)) fs = NULL; read_unlock(&file_systems_lock); } diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c index 3ea711688341..99c26613525c 100644 --- a/fs/nls/nls_base.c +++ b/fs/nls/nls_base.c @@ -205,9 +205,9 @@ static struct nls_table *find_nls(char *charset) struct nls_table *nls; spin_lock(&nls_lock); for (nls = tables; nls; nls = nls->next) - if (! strcmp(nls->charset, charset)) + if (!strcmp(nls->charset, charset)) break; - if (nls && !try_inc_mod_count(nls->owner)) + if (nls && !try_module_get(nls->owner)) nls = NULL; spin_unlock(&nls_lock); return nls; diff --git a/include/linux/fs.h b/include/linux/fs.h index 6c3188b991e6..3fa13b80747d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -982,15 +982,9 @@ struct super_block *get_sb_pseudo(struct file_system_type *, char *, /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ #define fops_get(fops) \ - (((fops) && (fops)->owner) \ - ? (try_inc_mod_count((fops)->owner) ? (fops) : NULL) \ - : (fops)) - + (((fops) && try_module_get((fops)->owner) ? (fops) : NULL)) #define fops_put(fops) \ -do { \ - if ((fops) && (fops)->owner) \ - module_put((fops)->owner); \ -} while(0) + do { if (fops) module_put((fops)->owner); } while(0) extern int register_filesystem(struct file_system_type *); extern int unregister_filesystem(struct file_system_type *); diff --git a/include/linux/module.h b/include/linux/module.h index ebdfc27efbb8..8e1954a89913 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -357,7 +357,6 @@ static inline void __deprecated _MOD_INC_USE_COUNT(struct module *module) _MOD_INC_USE_COUNT(THIS_MODULE) #define MOD_DEC_USE_COUNT \ __MOD_DEC_USE_COUNT(THIS_MODULE) -#define try_inc_mod_count(mod) try_module_get(mod) #define EXPORT_NO_SYMBOLS extern int module_dummy_usage; #define GET_USE_COUNT(module) (module_dummy_usage) diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 52d38241e91e..503a715fe014 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -215,10 +215,8 @@ static inline struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num) struct mtd_info *ret; ret = __get_mtd_device(mtd, num); - - if (ret && ret->module && !try_inc_mod_count(ret->module)) + if (ret && !try_module_get(ret->module)) return NULL; - return ret; } @@ -227,7 +225,6 @@ static inline void put_mtd_device(struct mtd_info *mtd) module_put(mtd->module); } - struct mtd_notifier { void (*add)(struct mtd_info *mtd); void (*remove)(struct mtd_info *mtd); diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index 162a5c23e606..5d53353d57b0 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -82,7 +82,7 @@ lookup_exec_domain(u_long personality) read_lock(&exec_domains_lock); for (ep = exec_domains; ep; ep = ep->next) { if (pers >= ep->pers_low && pers <= ep->pers_high) - if (try_inc_mod_count(ep->module)) + if (try_module_get(ep->module)) goto out; } @@ -97,7 +97,7 @@ lookup_exec_domain(u_long personality) for (ep = exec_domains; ep; ep = ep->next) { if (pers >= ep->pers_low && pers <= ep->pers_high) - if (try_inc_mod_count(ep->module)) + if (try_module_get(ep->module)) goto out; } #endif diff --git a/kernel/intermodule.c b/kernel/intermodule.c index 9228ca4fe035..5171df7d70fb 100644 --- a/kernel/intermodule.c +++ b/kernel/intermodule.c @@ -123,7 +123,7 @@ const void *inter_module_get(const char *im_name) list_for_each(tmp, &ime_list) { ime = list_entry(tmp, struct inter_module_entry, list); if (strcmp(ime->im_name, im_name) == 0) { - if (try_inc_mod_count(ime->owner)) + if (try_module_get(ime->owner)) result = ime->userdata; break; } diff --git a/net/core/dev.c b/net/core/dev.c index 97e772ff5f82..72f606980694 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -697,7 +697,7 @@ int dev_open(struct net_device *dev) /* * Call device private open method */ - if (try_inc_mod_count(dev->owner)) { + if (try_module_get(dev->owner)) { set_bit(__LINK_STATE_START, &dev->state); if (dev->open) { ret = dev->open(dev); diff --git a/net/ipv4/xfrm_policy.c b/net/ipv4/xfrm_policy.c index fe30556f78d6..f2c15d116118 100644 --- a/net/ipv4/xfrm_policy.c +++ b/net/ipv4/xfrm_policy.c @@ -192,7 +192,7 @@ struct xfrm_type *xfrm_get_type(u8 proto) read_lock(&xfrm_type_lock); type = xfrm_type_map[proto]; - if (type && !try_inc_mod_count(type->owner)) + if (type && !try_module_get(type->owner)) type = NULL; read_unlock(&xfrm_type_lock); return type; diff --git a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c index 0e50f85416d6..4e35bd351412 100644 --- a/net/rxrpc/krxsecd.c +++ b/net/rxrpc/krxsecd.c @@ -233,7 +233,7 @@ void rxrpc_krxsecd_process_incoming_call(struct rxrpc_message *msg) spin_lock(&trans->lock); list_for_each(_p,&trans->services) { srv = list_entry(_p,struct rxrpc_service,link); - if (srv->service_id==sid && try_inc_mod_count(srv->owner)) { + if (srv->service_id==sid && try_module_get(srv->owner)) { /* found a match (made sure it won't vanish) */ _debug("found service '%s'",srv->name); call->owner = srv->owner; diff --git a/sound/core/control.c b/sound/core/control.c index 7de5256c19fc..85a0a656c5b8 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -61,7 +61,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file) err = -ENODEV; goto __error1; } - if (!try_inc_mod_count(card->module)) { + if (!try_module_get(card->module)) { err = -EFAULT; goto __error2; } diff --git a/sound/core/info.c b/sound/core/info.c index 0ae2541810a6..45bf36503596 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -296,7 +296,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) #ifdef LINUX_2_2 MOD_INC_USE_COUNT; #endif - if (entry->module && !try_inc_mod_count(entry->module)) { + if (!try_module_get(entry->module)) { err = -EFAULT; goto __error1; } diff --git a/sound/core/init.c b/sound/core/init.c index 10768c6f2898..bc320cb1d2bd 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -294,17 +294,14 @@ static void snd_card_free_thread(void * __card) snd_card_t *card = __card; struct module * module; - if (!try_inc_mod_count(module = card->module)) { + if (!try_module_get(module = card->module)) { snd_printk(KERN_ERR "unable to lock toplevel module for card %i in free thread\n", card->number); module = NULL; } wait_event(card->shutdown_sleep, card->files == NULL); - snd_card_free(card); - - if (module) - __MOD_DEC_USE_COUNT(module); + module_put(module); } /** diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 088bf5ea33c1..c4c6d4d3ff59 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -59,7 +59,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file) #ifdef LINUX_2_2 MOD_INC_USE_COUNT; #endif - if (!try_inc_mod_count(card->module)) { + if (!try_module_get(card->module)) { kfree(fmixer); #ifdef LINUX_2_2 MOD_DEC_USE_COUNT; diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 4febec2769c2..4c7d5c33f134 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1551,7 +1551,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) err = snd_card_file_add(pcm->card, file); if (err < 0) goto __error1; - if (!try_inc_mod_count(pcm->card->module)) { + if (!try_module_get(pcm->card->module)) { err = -EFAULT; goto __error2; } diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 57f2a9c0f4a2..405fe698896e 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1791,7 +1791,7 @@ int snd_pcm_open(struct inode *inode, struct file *file) err = snd_card_file_add(pcm->card, file); if (err < 0) goto __error1; - if (!try_inc_mod_count(pcm->card->module)) { + if (!try_module_get(pcm->card->module)) { err = -EFAULT; goto __error2; } diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index a03924780f93..301445309d17 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -189,7 +189,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, err = -ENODEV; goto __error1; } - if (!try_inc_mod_count(rmidi->card->module)) { + if (!try_module_get(rmidi->card->module)) { err = -EFAULT; goto __error1; } diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 837ef15abb69..af140edbdead 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -234,7 +234,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) else info->arg.event_passing = SNDRV_SEQ_OSS_PASS_EVENTS; info->opened = 0; - if (!try_inc_mod_count(rec->oper.owner)) { + if (!try_module_get(rec->oper.owner)) { snd_use_lock_free(&rec->use_lock); continue; } diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 14943f8fecb8..d6654a1ab336 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -401,7 +401,7 @@ static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_ { int err = 0; - if (!try_inc_mod_count(port->owner)) + if (!try_module_get(port->owner)) return -EFAULT; grp->count++; if (grp->open && (port->callback_all || grp->count == 1)) { diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 0719b6ad0ee8..c493a659d3f5 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -282,7 +282,7 @@ static int snd_virmidi_subscribe(void *private_data, snd_seq_port_subscribe_t *i snd_virmidi_dev_t *rdev; rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); - if (!try_inc_mod_count(rdev->card->module)) + if (!try_module_get(rdev->card->module)) return -EFAULT; rdev->flags |= SNDRV_VIRMIDI_SUBSCRIBE; return 0; @@ -310,7 +310,7 @@ static int snd_virmidi_use(void *private_data, snd_seq_port_subscribe_t *info) snd_virmidi_dev_t *rdev; rdev = snd_magic_cast(snd_virmidi_dev_t, private_data, return -EINVAL); - if (!try_inc_mod_count(rdev->card->module)) + if (!try_module_get(rdev->card->module)) return -EFAULT; rdev->flags |= SNDRV_VIRMIDI_USE; return 0; diff --git a/sound/core/timer.c b/sound/core/timer.c index 1b571b00728d..b386bdeb48c8 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -102,7 +102,7 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *ti timeri->in_use = (atomic_t)ATOMIC_INIT(0); timeri->timer = timer; - if (timer && timer->card && !try_inc_mod_count(timer->card->module)) { + if (timer && timer->card && !try_module_get(timer->card->module)) { kfree(timeri->owner); kfree(timeri); return NULL; diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index c622456c6136..c1f8429679f3 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -37,7 +37,7 @@ MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); int snd_opl3_synth_use_inc(opl3_t * opl3) { - if (!try_inc_mod_count(opl3->card->module)) + if (!try_module_get(opl3->card->module)) return -EFAULT; return 0; diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index a3473afd0118..7a9adec95248 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -42,7 +42,7 @@ static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); int snd_gus_use_inc(snd_gus_card_t * gus) { MOD_INC_USE_COUNT; - if (!try_inc_mod_count(gus->card->module)) { + if (!try_module_get(gus->card->module)) { MOD_DEC_USE_COUNT; return 0; } diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 817b6d807a86..a9de8cb5dff2 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -145,7 +145,7 @@ snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file) { MOD_INC_USE_COUNT; - if (!try_inc_mod_count(hw->card->module)) { + if (!try_module_get(hw->card->module)) { MOD_DEC_USE_COUNT; return -EFAULT; } diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index f3e26ef9473f..88b88d23c3fd 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -1604,7 +1604,7 @@ snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file) { MOD_INC_USE_COUNT; - if (!try_inc_mod_count(hw->card->module)) { + if (!try_module_get(hw->card->module)) { MOD_DEC_USE_COUNT; return -EFAULT; } diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 0dd6ef8c376c..a06961482fa5 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -274,9 +274,9 @@ int snd_emux_inc_count(snd_emux_t *emu) { emu->used++; - if (!try_inc_mod_count(emu->ops.owner)) + if (!try_module_get(emu->ops.owner)) goto __error; - if (!try_inc_mod_count(emu->card->module)) { + if (!try_module_get(emu->card->module)) { module_put(emu->ops.owner); __error: emu->used--; -- cgit v1.2.3 From 123c66ee8147175762360e06188648fa7e6a15db Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 29 Dec 2002 20:29:16 -0800 Subject: [PATCH] cpufreq: deprecated usage of CPUFREQ_ALL_CPUS The usage of CPUFREQ_ALL_CPUS is deprecated. Only exception is cpufreq_set, which needs to iterate over all CPUS now. Also, remove some unneeded code. --- arch/i386/kernel/cpu/cpufreq/elanfreq.c | 2 +- arch/i386/kernel/cpu/cpufreq/longhaul.c | 2 +- arch/i386/kernel/cpu/cpufreq/powernow-k6.c | 2 +- arch/i386/kernel/cpu/cpufreq/speedstep.c | 2 +- include/linux/cpufreq.h | 11 ------ kernel/cpufreq.c | 54 +++++++++++------------------- 6 files changed, 24 insertions(+), 49 deletions(-) (limited to 'include/linux') diff --git a/arch/i386/kernel/cpu/cpufreq/elanfreq.c b/arch/i386/kernel/cpu/cpufreq/elanfreq.c index 2c751897ce36..2623e01b2d87 100644 --- a/arch/i386/kernel/cpu/cpufreq/elanfreq.c +++ b/arch/i386/kernel/cpu/cpufreq/elanfreq.c @@ -124,7 +124,7 @@ static void elanfreq_set_cpu_state (unsigned int state) { freqs.old = elanfreq_get_cpu_frequency(); freqs.new = elan_multiplier[state].clock; - freqs.cpu = CPUFREQ_ALL_CPUS; /* elanfreq.c is UP only driver */ + freqs.cpu = 0; /* elanfreq.c is UP only driver */ cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); diff --git a/arch/i386/kernel/cpu/cpufreq/longhaul.c b/arch/i386/kernel/cpu/cpufreq/longhaul.c index 72395b13eb00..5936a37a291b 100644 --- a/arch/i386/kernel/cpu/cpufreq/longhaul.c +++ b/arch/i386/kernel/cpu/cpufreq/longhaul.c @@ -315,7 +315,7 @@ static void longhaul_setstate (unsigned int clock_ratio_index, unsigned int newf freqs.old = longhaul_get_cpu_mult() * longhaul_get_cpu_fsb() * 100; freqs.new = clock_ratio[clock_ratio_index] * newfsb * 100; - freqs.cpu = CPUFREQ_ALL_CPUS; /* longhaul.c is UP only driver */ + freqs.cpu = 0; /* longhaul.c is UP only driver */ cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k6.c b/arch/i386/kernel/cpu/cpufreq/powernow-k6.c index 8021e8a21590..8a3404123f44 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k6.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k6.c @@ -83,7 +83,7 @@ static void powernow_k6_set_state (unsigned int best_i) freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); freqs.new = busfreq * clock_ratio[best_i]; - freqs.cpu = CPUFREQ_ALL_CPUS; /* powernow-k6.c is UP only driver */ + freqs.cpu = 0; /* powernow-k6.c is UP only driver */ cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep.c b/arch/i386/kernel/cpu/cpufreq/speedstep.c index 227e726aa4bd..349f18b8d942 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep.c @@ -154,7 +154,7 @@ static void speedstep_set_state (unsigned int state, int notify) freqs.old = (oldstate == SPEEDSTEP_HIGH) ? speedstep_high_freq : speedstep_low_freq; freqs.new = (state == SPEEDSTEP_HIGH) ? speedstep_high_freq : speedstep_low_freq; - freqs.cpu = CPUFREQ_ALL_CPUS; /* speedstep.c is UP only driver */ + freqs.cpu = 0; /* speedstep.c is UP only driver */ if (notify) cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index e93501c7a0b8..542983a24130 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -103,14 +103,6 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu }; -/********************************************************************* - * DYNAMIC CPUFREQ INTERFACE * - *********************************************************************/ -#ifdef CONFIG_CPU_FREQ_DYNAMIC -/* TBD */ -#endif /* CONFIG_CPU_FREQ_DYNAMIC */ - - /********************************************************************* * CPUFREQ DRIVER INTERFACE * *********************************************************************/ @@ -122,9 +114,6 @@ struct cpufreq_driver { cpufreq_policy_t verify; cpufreq_policy_t setpolicy; struct cpufreq_policy *policy; -#ifdef CONFIG_CPU_FREQ_DYNAMIC - /* TBD */ -#endif /* 2.4. compatible API */ #ifdef CONFIG_CPU_FREQ_24_API unsigned int cpu_cur_freq[NR_CPUS]; diff --git a/kernel/cpufreq.c b/kernel/cpufreq.c index c8208fb2191a..5dff6da1a73f 100644 --- a/kernel/cpufreq.c +++ b/kernel/cpufreq.c @@ -365,7 +365,7 @@ int cpufreq_set(unsigned int freq, unsigned int cpu) { struct cpufreq_policy policy; down(&cpufreq_driver_sem); - if (!cpufreq_driver || !cpu_max_freq) { + if (!cpufreq_driver || !freq || (cpu > NR_CPUS)) { up(&cpufreq_driver_sem); return -EINVAL; } @@ -377,7 +377,20 @@ int cpufreq_set(unsigned int freq, unsigned int cpu) up(&cpufreq_driver_sem); - return cpufreq_set_policy(&policy); + if (policy.cpu == CPUFREQ_ALL_CPUS) + { + unsigned int i; + unsigned int ret = 0; + for (i=0; icpu == CPUFREQ_ALL_CPUS) { - for (i=0;ipolicy[i].min = policy->min; - cpufreq_driver->policy[i].max = policy->max; - cpufreq_driver->policy[i].policy = policy->policy; - } - } else { - cpufreq_driver->policy[policy->cpu].min = policy->min; - cpufreq_driver->policy[policy->cpu].max = policy->max; - cpufreq_driver->policy[policy->cpu].policy = policy->policy; - } + cpufreq_driver->policy[policy->cpu].min = policy->min; + cpufreq_driver->policy[policy->cpu].max = policy->max; + cpufreq_driver->policy[policy->cpu].policy = policy->policy; #ifdef CONFIG_CPU_FREQ_24_API - if (policy->cpu == CPUFREQ_ALL_CPUS) { - for (i=0;imax; - } else - cpu_cur_freq[policy->cpu] = policy->max; + cpu_cur_freq[policy->cpu] = policy->max; #endif ret = cpufreq_driver->setpolicy(policy); @@ -919,15 +919,6 @@ EXPORT_SYMBOL(cpufreq_set_policy); -/********************************************************************* - * DYNAMIC CPUFREQ SWITCHING * - *********************************************************************/ -#ifdef CONFIG_CPU_FREQ_DYNAMIC -/* TBD */ -#endif /* CONFIG_CPU_FREQ_DYNAMIC */ - - - /********************************************************************* * EXTERNALLY AFFECTING FREQUENCY CHANGES * *********************************************************************/ @@ -967,12 +958,7 @@ void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state) adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs); #ifdef CONFIG_CPU_FREQ_24_API - if (freqs->cpu == CPUFREQ_ALL_CPUS) { - int i; - for (i=0;inew; - } else - cpu_cur_freq[freqs->cpu] = freqs->new; + cpu_cur_freq[freqs->cpu] = freqs->new; #endif break; } -- cgit v1.2.3 From 6d7937c341ad655b221ccbfa9b57534e779dbdcb Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 29 Dec 2002 20:29:35 -0800 Subject: [PATCH] cpufreq: remove usage of #typedef --- include/linux/cpufreq.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include/linux') diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 542983a24130..ab2890b619d0 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -107,12 +107,10 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mu * CPUFREQ DRIVER INTERFACE * *********************************************************************/ -typedef int (*cpufreq_policy_t) (struct cpufreq_policy *policy); - struct cpufreq_driver { /* needed by all drivers */ - cpufreq_policy_t verify; - cpufreq_policy_t setpolicy; + int (*verify) (struct cpufreq_policy *policy); + int (*setpolicy) (struct cpufreq_policy *policy); struct cpufreq_policy *policy; /* 2.4. compatible API */ #ifdef CONFIG_CPU_FREQ_24_API -- cgit v1.2.3 From db8f4c7eda8a1594c165805c1717e13af8cfb4a9 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:40:19 -0800 Subject: [PATCH] BIN_TO_BCD consolidation Cleanup patch from Hollis Blanchard We have a large number of private implementations of BIN_TO_BCD and BCD_TO_BIN, which are all the same. And a lot of them are inflexible because they modify their arg: #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) - Create (in a generic BIN2BCD/BCD2BIN which does not modify its arg - Create generic BIN_TO_BCD/BCD_TO_BIN which uses the above - Update lots of callers to use the new generic version. --- arch/alpha/kernel/time.c | 1 + arch/arm/kernel/time.c | 8 -------- arch/cris/drivers/ds1302.c | 1 + arch/cris/kernel/time.c | 1 + arch/i386/kernel/time.c | 1 + arch/m68k/atari/time.c | 1 + arch/m68k/sun3x/time.c | 32 ++++++++++++++---------------- arch/mips/ddb5xxx/common/rtc_ds1386.c | 37 +++++++++++++++-------------------- arch/mips/dec/time.c | 1 + arch/mips/kernel/old-time.c | 1 + arch/mips64/sgi-ip27/ip27-rtc.c | 1 + arch/mips64/sgi-ip27/ip27-timer.c | 1 + arch/ppc/iSeries/mf.c | 1 + arch/ppc/platforms/chrp_time.c | 1 + arch/ppc/platforms/gemini_setup.c | 1 + arch/ppc/platforms/prep_time.c | 1 + arch/ppc/syslib/todc_time.c | 1 + arch/ppc64/kernel/mf.c | 1 + arch/ppc64/kernel/rtc.c | 1 + arch/sh/kernel/rtc.c | 9 +-------- arch/sparc64/kernel/time.c | 9 +-------- arch/x86_64/kernel/time.c | 1 + drivers/acorn/char/pcf8583.c | 1 + drivers/acpi/sleep.c | 1 + drivers/char/rtc.c | 1 + drivers/scsi/sr_vendor.c | 15 +++++++------- drivers/sgi/char/ds1286.c | 1 + include/asm-arm/arch-ebsa285/time.h | 1 + include/asm-cris/rtc.h | 5 ----- include/asm-generic/rtc.h | 1 + include/asm-mips/ds1286.h | 11 ----------- include/asm-mips64/ds1286.h | 11 ----------- include/asm-mips64/m48t35.h | 8 -------- include/asm-ppc/m48t35.h | 9 --------- include/asm-ppc/mk48t59.h | 8 -------- include/asm-ppc/nvram.h | 8 -------- include/asm-ppc/todc.h | 8 -------- include/asm-ppc64/nvram.h | 8 -------- include/linux/bcd.h | 20 +++++++++++++++++++ include/linux/mc146818rtc.h | 11 ----------- 40 files changed, 83 insertions(+), 157 deletions(-) create mode 100644 include/linux/bcd.h (limited to 'include/linux') diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c index 4ccda6679804..03fed82384dd 100644 --- a/arch/alpha/kernel/time.c +++ b/arch/alpha/kernel/time.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c index 2af6dbda06d5..685d59b08623 100644 --- a/arch/arm/kernel/time.c +++ b/arch/arm/kernel/time.c @@ -47,14 +47,6 @@ EXPORT_SYMBOL(rtc_lock); /* change this if you have some constant time drift */ #define USECS_PER_JIFFY (1000000/HZ) -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - static int dummy_set_rtc(void) { return 0; diff --git a/arch/cris/drivers/ds1302.c b/arch/cris/drivers/ds1302.c index 867f3c63ba0c..23814c3843d3 100644 --- a/arch/cris/drivers/ds1302.c +++ b/arch/cris/drivers/ds1302.c @@ -97,6 +97,7 @@ #include #include #include +#include #include #include diff --git a/arch/cris/kernel/time.c b/arch/cris/kernel/time.c index 1ee0bbfeab7e..0541e25a48aa 100644 --- a/arch/cris/kernel/time.c +++ b/arch/cris/kernel/time.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index 2040b6039df8..ef1cfa33b154 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c index 98e344a0111c..8a26073adb23 100644 --- a/arch/m68k/atari/time.c +++ b/arch/m68k/atari/time.c @@ -15,6 +15,7 @@ #include #include #include +#include #include diff --git a/arch/m68k/sun3x/time.c b/arch/m68k/sun3x/time.c index 683a34e815d4..b9b334e0db7f 100644 --- a/arch/m68k/sun3x/time.c +++ b/arch/m68k/sun3x/time.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -36,9 +37,6 @@ #define C_SIGN 0x20 #define C_CALIB 0x1f -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) -#define BIN_TO_BCD(val) (((val/10) << 4) | (val % 10)) - int sun3x_hwclk(int set, struct rtc_time *t) { volatile struct mostek_dt *h = @@ -49,23 +47,23 @@ int sun3x_hwclk(int set, struct rtc_time *t) if(set) { h->csr |= C_WRITE; - h->sec = BIN_TO_BCD(t->tm_sec); - h->min = BIN_TO_BCD(t->tm_min); - h->hour = BIN_TO_BCD(t->tm_hour); - h->wday = BIN_TO_BCD(t->tm_wday); - h->mday = BIN_TO_BCD(t->tm_mday); - h->month = BIN_TO_BCD(t->tm_mon); - h->year = BIN_TO_BCD(t->tm_year); + h->sec = BIN2BCD(t->tm_sec); + h->min = BIN2BCD(t->tm_min); + h->hour = BIN2BCD(t->tm_hour); + h->wday = BIN2BCD(t->tm_wday); + h->mday = BIN2BCD(t->tm_mday); + h->month = BIN2BCD(t->tm_mon); + h->year = BIN2BCD(t->tm_year); h->csr &= ~C_WRITE; } else { h->csr |= C_READ; - t->tm_sec = BCD_TO_BIN(h->sec); - t->tm_min = BCD_TO_BIN(h->min); - t->tm_hour = BCD_TO_BIN(h->hour); - t->tm_wday = BCD_TO_BIN(h->wday); - t->tm_mday = BCD_TO_BIN(h->mday); - t->tm_mon = BCD_TO_BIN(h->month); - t->tm_year = BCD_TO_BIN(h->year); + t->tm_sec = BCD2BIN(h->sec); + t->tm_min = BCD2BIN(h->min); + t->tm_hour = BCD2BIN(h->hour); + t->tm_wday = BCD2BIN(h->wday); + t->tm_mday = BCD2BIN(h->mday); + t->tm_mon = BCD2BIN(h->month); + t->tm_year = BCD2BIN(h->year); h->csr &= ~C_READ; } diff --git a/arch/mips/ddb5xxx/common/rtc_ds1386.c b/arch/mips/ddb5xxx/common/rtc_ds1386.c index 91ea9749eda0..e8b37abad543 100644 --- a/arch/mips/ddb5xxx/common/rtc_ds1386.c +++ b/arch/mips/ddb5xxx/common/rtc_ds1386.c @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -28,12 +29,6 @@ #define EPOCH 2000 -#undef BCD_TO_BIN -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) - -#undef BIN_TO_BCD -#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10) - #define READ_RTC(x) *(volatile unsigned char*)(rtc_base+x) #define WRITE_RTC(x, y) *(volatile unsigned char*)(rtc_base+x) = y @@ -52,11 +47,11 @@ rtc_ds1386_get_time(void) WRITE_RTC(0xB, byte); /* read time data */ - year = BCD_TO_BIN(READ_RTC(0xA)) + EPOCH; - month = BCD_TO_BIN(READ_RTC(0x9) & 0x1f); - day = BCD_TO_BIN(READ_RTC(0x8)); - minute = BCD_TO_BIN(READ_RTC(0x2)); - second = BCD_TO_BIN(READ_RTC(0x1)); + year = BCD2BIN(READ_RTC(0xA)) + EPOCH; + month = BCD2BIN(READ_RTC(0x9) & 0x1f); + day = BCD2BIN(READ_RTC(0x8)); + minute = BCD2BIN(READ_RTC(0x2)); + second = BCD2BIN(READ_RTC(0x1)); /* hour is special - deal with it later */ temp = READ_RTC(0x4); @@ -68,11 +63,11 @@ rtc_ds1386_get_time(void) /* calc hour */ if (temp & 0x40) { /* 12 hour format */ - hour = BCD_TO_BIN(temp & 0x1f); + hour = BCD2BIN(temp & 0x1f); if (temp & 0x20) hour += 12; /* PM */ } else { /* 24 hour format */ - hour = BCD_TO_BIN(temp & 0x3f); + hour = BCD2BIN(temp & 0x3f); } return mktime(year, month, day, hour, minute, second); @@ -95,19 +90,19 @@ rtc_ds1386_set_time(unsigned long t) to_tm(t, &tm); /* check each field one by one */ - year = BIN_TO_BCD(tm.tm_year - EPOCH); + year = BIN2BCD(tm.tm_year - EPOCH); if (year != READ_RTC(0xA)) { WRITE_RTC(0xA, year); } temp = READ_RTC(0x9); - month = BIN_TO_BCD(tm.tm_mon); + month = BIN2BCD(tm.tm_mon); if (month != (temp & 0x1f)) { WRITE_RTC( 0x9, (month & 0x1f) | (temp & ~0x1f) ); } - day = BIN_TO_BCD(tm.tm_mday); + day = BIN2BCD(tm.tm_mday); if (day != READ_RTC(0x8)) { WRITE_RTC(0x8, day); } @@ -117,22 +112,22 @@ rtc_ds1386_set_time(unsigned long t) /* 12 hour format */ hour = 0x40; if (tm.tm_hour > 12) { - hour |= 0x20 | (BIN_TO_BCD(hour-12) & 0x1f); + hour |= 0x20 | (BIN2BCD(hour-12) & 0x1f); } else { - hour |= BIN_TO_BCD(tm.tm_hour); + hour |= BIN2BCD(tm.tm_hour); } } else { /* 24 hour format */ - hour = BIN_TO_BCD(tm.tm_hour) & 0x3f; + hour = BIN2BCD(tm.tm_hour) & 0x3f; } if (hour != temp) WRITE_RTC(0x4, hour); - minute = BIN_TO_BCD(tm.tm_min); + minute = BIN2BCD(tm.tm_min); if (minute != READ_RTC(0x2)) { WRITE_RTC(0x2, minute); } - second = BIN_TO_BCD(tm.tm_sec); + second = BIN2BCD(tm.tm_sec); if (second != READ_RTC(0x1)) { WRITE_RTC(0x1, second); } diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c index 9188af33f678..c7c5640a7d61 100644 --- a/arch/mips/dec/time.c +++ b/arch/mips/dec/time.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/arch/mips/kernel/old-time.c b/arch/mips/kernel/old-time.c index a58202bfae6f..4793acd60c19 100644 --- a/arch/mips/kernel/old-time.c +++ b/arch/mips/kernel/old-time.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/arch/mips64/sgi-ip27/ip27-rtc.c b/arch/mips64/sgi-ip27/ip27-rtc.c index f7983dbb570f..3a71a4b8b2fd 100644 --- a/arch/mips64/sgi-ip27/ip27-rtc.c +++ b/arch/mips64/sgi-ip27/ip27-rtc.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/arch/mips64/sgi-ip27/ip27-timer.c b/arch/mips64/sgi-ip27/ip27-timer.c index e0251cd0d379..d4ed43d11d66 100644 --- a/arch/mips64/sgi-ip27/ip27-timer.c +++ b/arch/mips64/sgi-ip27/ip27-timer.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/arch/ppc/iSeries/mf.c b/arch/ppc/iSeries/mf.c index aa822233e43c..59b178279734 100644 --- a/arch/ppc/iSeries/mf.c +++ b/arch/ppc/iSeries/mf.c @@ -40,6 +40,7 @@ #include #include #include +#include /* diff --git a/arch/ppc/platforms/chrp_time.c b/arch/ppc/platforms/chrp_time.c index 9a5333428f2c..a7e4e5a81429 100644 --- a/arch/ppc/platforms/chrp_time.c +++ b/arch/ppc/platforms/chrp_time.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include diff --git a/arch/ppc/platforms/gemini_setup.c b/arch/ppc/platforms/gemini_setup.c index 41458519f54b..dc976899f604 100644 --- a/arch/ppc/platforms/gemini_setup.c +++ b/arch/ppc/platforms/gemini_setup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/arch/ppc/platforms/prep_time.c b/arch/ppc/platforms/prep_time.c index 49ac7d2638ed..4c75081fd178 100644 --- a/arch/ppc/platforms/prep_time.c +++ b/arch/ppc/platforms/prep_time.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/arch/ppc/syslib/todc_time.c b/arch/ppc/syslib/todc_time.c index 9591c7ee0eef..85ee80b4e581 100644 --- a/arch/ppc/syslib/todc_time.c +++ b/arch/ppc/syslib/todc_time.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/arch/ppc64/kernel/mf.c b/arch/ppc64/kernel/mf.c index 3999ea9ee813..876570387150 100644 --- a/arch/ppc64/kernel/mf.c +++ b/arch/ppc64/kernel/mf.c @@ -40,6 +40,7 @@ #include #include #include +#include extern struct pci_dev * iSeries_vio_dev; diff --git a/arch/ppc64/kernel/rtc.c b/arch/ppc64/kernel/rtc.c index 5ace02abc1bc..c0f714551a0d 100644 --- a/arch/ppc64/kernel/rtc.c +++ b/arch/ppc64/kernel/rtc.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/arch/sh/kernel/rtc.c b/arch/sh/kernel/rtc.c index 6eb2f2cb4a8a..08a029f5e3c1 100644 --- a/arch/sh/kernel/rtc.c +++ b/arch/sh/kernel/rtc.c @@ -9,18 +9,11 @@ #include #include #include +#include #include #include -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - void sh_rtc_gettimeofday(struct timeval *tv) { unsigned int sec128, sec, min, hr, wk, day, mon, yr, yr100; diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index cdb33d996328..3c48ed49ea5a 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -330,14 +331,6 @@ static int __init has_low_battery(void) return (data1 == data2); /* Was the write blocked? */ } -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10) -#endif - /* Probe for the real time clock chip. */ static void __init set_system_time(void) { diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 67d2cf41c2ed..65a2c76f0021 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index 115078c60d4c..05ed2e52c190 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "pcf8583.h" diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index e84ceeb85eeb..cdb4fe6d5b4f 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 75dffcb2b48c..1e5f4c6ec5a1 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -72,6 +72,7 @@ #include #include #include +#include #include #include diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c index 76a701bb4502..690d8feafe6e 100644 --- a/drivers/scsi/sr_vendor.c +++ b/drivers/scsi/sr_vendor.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "scsi.h" @@ -151,8 +152,6 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) /* This function gets called after a media change. Checks if the CD is multisession, asks for offset etc. */ -#define BCD_TO_BIN(x) ((((int)x & 0xf0) >> 4)*10 + ((int)x & 0x0f)) - int sr_cd_check(struct cdrom_device_info *cdi) { Scsi_CD *cd = cdi->handle; @@ -223,9 +222,9 @@ int sr_cd_check(struct cdrom_device_info *cdi) no_multi = 1; break; } - min = BCD_TO_BIN(buffer[15]); - sec = BCD_TO_BIN(buffer[16]); - frame = BCD_TO_BIN(buffer[17]); + min = BCD2BIN(buffer[15]); + sec = BCD2BIN(buffer[16]); + frame = BCD2BIN(buffer[17]); sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; break; } @@ -252,9 +251,9 @@ int sr_cd_check(struct cdrom_device_info *cdi) } if (rc != 0) break; - min = BCD_TO_BIN(buffer[1]); - sec = BCD_TO_BIN(buffer[2]); - frame = BCD_TO_BIN(buffer[3]); + min = BCD2BIN(buffer[1]); + sec = BCD2BIN(buffer[2]); + frame = BCD2BIN(buffer[3]); sector = min * CD_SECS * CD_FRAMES + sec * CD_FRAMES + frame; if (sector) sector -= CD_MSF_OFFSET; diff --git a/drivers/sgi/char/ds1286.c b/drivers/sgi/char/ds1286.c index ae11cb96484b..d98e2a63ec63 100644 --- a/drivers/sgi/char/ds1286.c +++ b/drivers/sgi/char/ds1286.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/include/asm-arm/arch-ebsa285/time.h b/include/asm-arm/arch-ebsa285/time.h index a500b9c08b8b..feb175ee806b 100644 --- a/include/asm-arm/arch-ebsa285/time.h +++ b/include/asm-arm/arch-ebsa285/time.h @@ -18,6 +18,7 @@ #define RTC_ALWAYS_BCD 0 #include +#include #include #include diff --git a/include/asm-cris/rtc.h b/include/asm-cris/rtc.h index 239b1bb22839..72ff33a48a8d 100644 --- a/include/asm-cris/rtc.h +++ b/include/asm-cris/rtc.h @@ -39,11 +39,6 @@ #define RTC_INIT() (-1) #endif -/* conversions to and from the stupid RTC internal format */ - -#define BCD_TO_BIN(x) x = (((x & 0xf0) >> 3) * 5 + (x & 0xf)) -#define BIN_TO_BCD(x) x = (x % 10) | ((x / 10) << 4) - /* * The struct used to pass data via the following ioctl. Similar to the * struct tm in , but it needs to be here so that the kernel diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h index ebdeefd49822..845641b06b0c 100644 --- a/include/asm-generic/rtc.h +++ b/include/asm-generic/rtc.h @@ -16,6 +16,7 @@ #include #include +#include #define RTC_PIE 0x40 /* periodic interrupt enable */ #define RTC_AIE 0x20 /* alarm interrupt enable */ diff --git a/include/asm-mips/ds1286.h b/include/asm-mips/ds1286.h index 2d60fb89d328..92686b110dc9 100644 --- a/include/asm-mips/ds1286.h +++ b/include/asm-mips/ds1286.h @@ -57,15 +57,4 @@ #define RTC_IPSW 0x40 #define RTC_TE 0x80 -/* - * Conversion between binary and BCD. - */ -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - #endif /* _ASM_DS1286_h */ diff --git a/include/asm-mips64/ds1286.h b/include/asm-mips64/ds1286.h index 5280850b374a..56af9b10d01b 100644 --- a/include/asm-mips64/ds1286.h +++ b/include/asm-mips64/ds1286.h @@ -56,15 +56,4 @@ #define RTC_IPSW 0x40 #define RTC_TE 0x80 -/* - * Conversion between binary and BCD. - */ -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - #endif /* _ASM_DS1286_h */ diff --git a/include/asm-mips64/m48t35.h b/include/asm-mips64/m48t35.h index 113760397957..865ec0c379e3 100644 --- a/include/asm-mips64/m48t35.h +++ b/include/asm-mips64/m48t35.h @@ -21,12 +21,4 @@ struct m48t35_rtc { #define M48T35_RTC_STOPPED 0x80 #define M48T35_RTC_READ 0x40 -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(x) ((x)=((x)&15) + ((x)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(x) ((x)=(((x)/10)<<4) + (x)%10) -#endif - #endif diff --git a/include/asm-ppc/m48t35.h b/include/asm-ppc/m48t35.h index 86b8be5987a8..97d2129f8d53 100644 --- a/include/asm-ppc/m48t35.h +++ b/include/asm-ppc/m48t35.h @@ -74,13 +74,4 @@ #define M48T35_RTC_READ 0x40 -/* read/write conversions */ -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(x) ((x)=((x)&15) + ((x)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(x) ((x)=(((x)/10)<<4) + (x)%10) -#endif - #endif diff --git a/include/asm-ppc/mk48t59.h b/include/asm-ppc/mk48t59.h index 4700fcdc824c..6a0ed6fc2d56 100644 --- a/include/asm-ppc/mk48t59.h +++ b/include/asm-ppc/mk48t59.h @@ -24,12 +24,4 @@ #define MK48T59_RTC_CONTROLB 0x1FF9 #define MK48T59_RTC_CB_STOP 0x80 -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - #endif /* _PPC_MK48T59_H */ diff --git a/include/asm-ppc/nvram.h b/include/asm-ppc/nvram.h index 7f6fc08b1868..47e4dfc74a77 100644 --- a/include/asm-ppc/nvram.h +++ b/include/asm-ppc/nvram.h @@ -23,14 +23,6 @@ #define MOTO_RTC_CONTROLA 0x1FF8 #define MOTO_RTC_CONTROLB 0x1FF9 -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - /* PowerMac specific nvram stuffs */ enum { diff --git a/include/asm-ppc/todc.h b/include/asm-ppc/todc.h index 9b4d58e9efeb..3f72c47e09bf 100644 --- a/include/asm-ppc/todc.h +++ b/include/asm-ppc/todc.h @@ -355,14 +355,6 @@ typedef struct { todc_info->flags = clock_type ##_FLAGS; \ } -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - extern todc_info_t *todc_info; unsigned char todc_direct_read_val(int addr); diff --git a/include/asm-ppc64/nvram.h b/include/asm-ppc64/nvram.h index 46ef2c3106d3..1c304357c223 100644 --- a/include/asm-ppc64/nvram.h +++ b/include/asm-ppc64/nvram.h @@ -28,12 +28,4 @@ #define MOTO_RTC_CONTROLA 0x1FF8 #define MOTO_RTC_CONTROLB 0x1FF9 -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - #endif /* _PPC64_NVRAM_H */ diff --git a/include/linux/bcd.h b/include/linux/bcd.h new file mode 100644 index 000000000000..c545308125b0 --- /dev/null +++ b/include/linux/bcd.h @@ -0,0 +1,20 @@ +/* Permission is hereby granted to copy, modify and redistribute this code + * in terms of the GNU Library General Public License, Version 2 or later, + * at your option. + */ + +/* macros to translate to/from binary and binary-coded decimal (frequently + * found in RTC chips). + */ + +#ifndef _BCD_H +#define _BCD_H + +#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10) +#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10) + +/* backwards compat */ +#define BCD_TO_BIN(val) ((val)=BCD2BIN(val)) +#define BIN_TO_BCD(val) ((val)=BIN2BCD(val)) + +#endif /* _BCD_H */ diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h index 2ec35699a8e8..cde7dbae375e 100644 --- a/include/linux/mc146818rtc.h +++ b/include/linux/mc146818rtc.h @@ -87,15 +87,4 @@ extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ # define RTC_VRT 0x80 /* valid RAM and time */ /**********************************************************************/ -/* example: !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) - * determines if the following two #defines are needed - */ -#ifndef BCD_TO_BIN -#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) -#endif - -#ifndef BIN_TO_BCD -#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) -#endif - #endif /* _MC146818RTC_H */ -- cgit v1.2.3 From 6306d4857d08b5aa6f190cdd54fe3231f3a35d9f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:40:31 -0800 Subject: [PATCH] add drain_local_pages() for CONFIG_SOFTWARE_SUSPEND swsusp gets confused when pages which it freed do not appear in the buddy lists. So provide a function which will drain the calling CPU's per-cpu-pages into the buddy. The patch has been tested by Pavel. Presence of the new code is conditional on CONFIG_SOFTWARE_SUSPEND. --- include/linux/suspend.h | 3 +++ mm/page_alloc.c | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'include/linux') diff --git a/include/linux/suspend.h b/include/linux/suspend.h index a481f80034fa..80b4a657b49c 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -46,6 +46,9 @@ struct suspend_header { /* mm/vmscan.c */ extern int shrink_mem(void); +/* mm/page_alloc.c */ +extern void drain_local_pages(void); + /* kernel/suspend.c */ extern void software_suspend(void); extern void software_resume(void); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7de787fd57d9..1c8015736d61 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -350,6 +350,31 @@ int is_head_of_free_region(struct page *page) spin_unlock_irqrestore(&zone->lock, flags); return 0; } + +/* + * Spill all of this CPU's per-cpu pages back into the buddy allocator. + */ +void drain_local_pages(void) +{ + unsigned long flags; + struct zone *zone; + int i; + + local_irq_save(flags); + for_each_zone(zone) { + struct per_cpu_pageset *pset; + + pset = &zone->pageset[smp_processor_id()]; + for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) { + struct per_cpu_pages *pcp; + + pcp = &pset->pcp[i]; + pcp->count -= free_pages_bulk(zone, pcp->count, + &pcp->list, 0); + } + } + local_irq_restore(flags); +} #endif /* CONFIG_SOFTWARE_SUSPEND */ /* -- cgit v1.2.3 From 29621f41b70cb609f46db52e2a92faca9e6186ea Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:40:37 -0800 Subject: [PATCH] kmalloc_percpu -- stripped down version Patch from Ravikiran G Thirumalai Creates a simple "kmalloc for each CPU" API. This will be used for net statistics, disk statistics, etc. (davem has acked the net patches which use this code). kmalloc_per_cpu() is available to modules, unlike the current static per-cpu infrastructure. --- include/linux/percpu.h | 61 +++++++++++++++++++++++++++++++++++++++++++ kernel/ksyms.c | 4 +++ mm/slab.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) (limited to 'include/linux') diff --git a/include/linux/percpu.h b/include/linux/percpu.h index a79d04de4fd5..74c3d9786874 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -1,10 +1,71 @@ #ifndef __LINUX_PERCPU_H #define __LINUX_PERCPU_H #include /* For preempt_disable() */ +#include /* For kmalloc_percpu() */ #include /* Must be an lvalue. */ #define get_cpu_var(var) (*({ preempt_disable(); &__get_cpu_var(var); })) #define put_cpu_var(var) preempt_enable() +#ifdef CONFIG_SMP + +struct percpu_data { + void *ptrs[NR_CPUS]; + void *blkp; +}; + +/* + * Use this to get to a cpu's version of the per-cpu object allocated using + * kmalloc_percpu. If you want to get "this cpu's version", maybe you want + * to use get_cpu_ptr... + */ +#define per_cpu_ptr(ptr, cpu) \ +({ \ + struct percpu_data *__p = (struct percpu_data *)~(unsigned long)(ptr); \ + (__typeof__(ptr))__p->ptrs[(cpu)]; \ +}) + +extern void *kmalloc_percpu(size_t size, int flags); +extern void kfree_percpu(const void *); +extern void kmalloc_percpu_init(void); + +#else /* CONFIG_SMP */ + +#define per_cpu_ptr(ptr, cpu) (ptr) + +static inline void *kmalloc_percpu(size_t size, int flags) +{ + return(kmalloc(size, flags)); +} +static inline void kfree_percpu(const void *ptr) +{ + kfree(ptr); +} +static inline void kmalloc_percpu_init(void) { } + +#endif /* CONFIG_SMP */ + +/* + * Use these with kmalloc_percpu. If + * 1. You want to operate on memory allocated by kmalloc_percpu (dereference + * and read/modify/write) AND + * 2. You want "this cpu's version" of the object AND + * 3. You want to do this safely since: + * a. On multiprocessors, you don't want to switch between cpus after + * you've read the current processor id due to preemption -- this would + * take away the implicit advantage to not have any kind of traditional + * serialization for per-cpu data + * b. On uniprocessors, you don't want another kernel thread messing + * up with the same per-cpu data due to preemption + * + * So, Use get_cpu_ptr to disable preemption and get pointer to the + * local cpu version of the per-cpu object. Use put_cpu_ptr to enable + * preemption. Operations on per-cpu data between get_ and put_ is + * then considered to be safe. And ofcourse, "Thou shalt not sleep between + * get_cpu_ptr and put_cpu_ptr" + */ +#define get_cpu_ptr(ptr) per_cpu_ptr(ptr, get_cpu()) +#define put_cpu_ptr(ptr) put_cpu() + #endif /* __LINUX_PERCPU_H */ diff --git a/kernel/ksyms.c b/kernel/ksyms.c index cd49778dd1f3..414ab402325e 100644 --- a/kernel/ksyms.c +++ b/kernel/ksyms.c @@ -98,6 +98,10 @@ EXPORT_SYMBOL(set_shrinker); EXPORT_SYMBOL(remove_shrinker); EXPORT_SYMBOL(kmalloc); EXPORT_SYMBOL(kfree); +#ifdef CONFIG_SMP +EXPORT_SYMBOL(kmalloc_percpu); +EXPORT_SYMBOL(kfree_percpu); +#endif EXPORT_SYMBOL(vfree); EXPORT_SYMBOL(__vmalloc); EXPORT_SYMBOL(vmalloc); diff --git a/mm/slab.c b/mm/slab.c index 0b30ca1afeaa..f196fcaac2cb 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1826,6 +1826,54 @@ void * kmalloc (size_t size, int flags) return NULL; } +#ifdef CONFIG_SMP +/** + * kmalloc_percpu - allocate one copy of the object for every present + * cpu in the system. + * Objects should be dereferenced using per_cpu_ptr/get_cpu_ptr + * macros only. + * + * @size: how many bytes of memory are required. + * @flags: the type of memory to allocate. + * The @flags argument may be one of: + * + * %GFP_USER - Allocate memory on behalf of user. May sleep. + * + * %GFP_KERNEL - Allocate normal kernel ram. May sleep. + * + * %GFP_ATOMIC - Allocation will not sleep. Use inside interrupt handlers. + */ +void * +kmalloc_percpu(size_t size, int flags) +{ + int i; + struct percpu_data *pdata = kmalloc(sizeof (*pdata), flags); + + if (!pdata) + return NULL; + + for (i = 0; i < NR_CPUS; i++) { + if (!cpu_possible(i)) + continue; + pdata->ptrs[i] = kmalloc(size, flags); + if (!pdata->ptrs[i]) + goto unwind_oom; + } + + /* Catch derefs w/o wrappers */ + return (void *) (~(unsigned long) pdata); + +unwind_oom: + while (--i >= 0) { + if (!cpu_possible(i)) + continue; + kfree(pdata->ptrs[i]); + } + kfree(pdata); + return NULL; +} +#endif + /** * kmem_cache_free - Deallocate an object * @cachep: The cache the allocation was from. @@ -1864,6 +1912,28 @@ void kfree (const void *objp) local_irq_restore(flags); } +#ifdef CONFIG_SMP +/** + * kfree_percpu - free previously allocated percpu memory + * @objp: pointer returned by kmalloc_percpu. + * + * Don't free memory not originally allocated by kmalloc_percpu() + * The complemented objp is to check for that. + */ +void +kfree_percpu(const void *objp) +{ + int i; + struct percpu_data *p = (struct percpu_data *) (~(unsigned long) objp); + + for (i = 0; i < NR_CPUS; i++) { + if (!cpu_possible(i)) + continue; + kfree(p->ptrs[i]); + } +} +#endif + unsigned int kmem_cache_size(kmem_cache_t *cachep) { #if DEBUG -- cgit v1.2.3 From d83f033a39a4bbe52b6c1ffd14bd994e70f9b6fe Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:40:44 -0800 Subject: [PATCH] Don't cacheline-align vm_area_struct Some workloads (Oracle...) use a huge number of VMA's. They are currently a tidy 64 bytes in size, and padding them out to 128 on P4's is not worthwhile. --- include/linux/mm.h | 3 +++ kernel/fork.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/mm.h b/include/linux/mm.h index df49cb472866..70177c796b12 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -41,6 +41,9 @@ extern int page_cluster; * per VM-area/task. A VM area is any part of the process virtual memory * space that has a special rule for the page-fault handlers (ie a shared * library, the executable area etc). + * + * This structure is exactly 64 bytes on ia32. Please think very, very hard + * before adding anything to it. */ struct vm_area_struct { struct mm_struct * vm_mm; /* The address space we belong to. */ diff --git a/kernel/fork.c b/kernel/fork.c index 6f7298827344..56f12f280dd3 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1078,7 +1078,7 @@ void __init proc_caches_init(void) vm_area_cachep = kmem_cache_create("vm_area_struct", sizeof(struct vm_area_struct), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); + 0, NULL, NULL); if(!vm_area_cachep) panic("vma_init: Cannot alloc vm_area_struct SLAB cache"); -- cgit v1.2.3 From 3e025d63795d492854c84a8ce655f4b1d4923a1a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:40:51 -0800 Subject: [PATCH] remove task_struct.swappable Remove unused task_struct.swappable. --- include/linux/sched.h | 1 - kernel/fork.c | 2 -- 2 files changed, 3 deletions(-) (limited to 'include/linux') diff --git a/include/linux/sched.h b/include/linux/sched.h index 7c3bbfc255ed..9545a1957089 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -343,7 +343,6 @@ struct task_struct { unsigned long start_time; /* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap; - int swappable:1; /* process credentials */ uid_t uid,euid,suid,fsuid; gid_t gid,egid,sgid,fsgid; diff --git a/kernel/fork.c b/kernel/fork.c index 56f12f280dd3..60d6d54142c6 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -757,7 +757,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->thread_info->preempt_count = 1; #endif p->did_exec = 0; - p->swappable = 0; p->state = TASK_UNINTERRUPTIBLE; copy_flags(clone_flags, p); @@ -841,7 +840,6 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->parent_exec_id = p->self_exec_id; /* ok, now we should be set up.. */ - p->swappable = 1; if (clone_flags & CLONE_DETACHED) p->exit_signal = -1; else -- cgit v1.2.3 From 8b0cc2d4e2705dc8793bd7c0e0f7b3504c49ecc6 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:41:09 -0800 Subject: [PATCH] promote the ALIGN() macro ALIGN() currently has global scope in . This causes a compilation error in the defxx driver. Move ALIGN() to and change the defxx driver to use the generic macro in place of its own. --- drivers/net/defxx.h | 7 ------- include/linux/cache.h | 3 +-- include/linux/kernel.h | 1 + 3 files changed, 2 insertions(+), 9 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/defxx.h b/drivers/net/defxx.h index dc88192bcd48..4fc9425dcbc8 100644 --- a/drivers/net/defxx.h +++ b/drivers/net/defxx.h @@ -1669,13 +1669,6 @@ typedef union #define XMT_BUFF_K_SA 7 /* six byte source address */ #define XMT_BUFF_K_DATA 13 /* offset to start of packet data */ -/* - * Macro evaluates to "value" aligned to "size" bytes. Make sure that - * "size" is greater than 0 bytes. - */ - -#define ALIGN(value,size) ((value + (size - 1)) & ~(size - 1)) - /* Macro for checking a "value" is within a specific range */ #define IN_RANGE(value,low,high) ((value >= low) && (value <= high)) diff --git a/include/linux/cache.h b/include/linux/cache.h index 95faa6ec3aa7..3db3832f35cb 100644 --- a/include/linux/cache.h +++ b/include/linux/cache.h @@ -1,11 +1,10 @@ #ifndef __LINUX_CACHE_H #define __LINUX_CACHE_H +#include #include #include -#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1)) - #ifndef L1_CACHE_ALIGN #define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES) #endif diff --git a/include/linux/kernel.h b/include/linux/kernel.h index f3cadd9416ad..9cb6277f5b86 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -28,6 +28,7 @@ #define STACK_MAGIC 0xdeadbeef #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1)) #define KERN_EMERG "<0>" /* system is unusable */ #define KERN_ALERT "<1>" /* action must be taken immediately */ -- cgit v1.2.3 From a93e679a7d1ca9cd662520a79830fec88a9654ca Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sun, 29 Dec 2002 21:41:16 -0800 Subject: [PATCH] don't call console drivers on non-online CPUs George Anzinger identified the following problem: when a secondary CPU is coming up, it calls printk() before it is "online". It calls the console drivers before its per-cpu storage has been prepared. And the vga console driver does a mod_timer(). This CPU's timers have not yet been initialised; it is not clear why this doesn't oops - George thinks it is because virtual address zero is still accessible at that time. I believe the right way to fix this is to change printk so that a not-online CPU will not call the console drivers. Because printk should always be callable. If the CPU is not online the message is buffered, so the next caller to printk who is online will actually display it. ia64 has been doing exactly this for ages, so we can remove the arch_consoles_callable() hook and just open-code the cpu_online() test in printk. That fixes things up for the secondary CPUs. But this change causes a problem for the boot CPU: it is being marked online very late in boot, so the printk buffer is being displayed much later than we would like. I believe that the solution to this is to mark the boot CPU online much earlier. So in this patch we call the new arch-provided function smp_prepare_boot_cpu() immediately after the boot CPU's per-cpu areas are set up. Its mandate is to (at least) mark the boot CPU "online". The change has been reviewed by davem and rth. No comments were received from the other arch maintainers. --- arch/alpha/kernel/smp.c | 6 ++++++ arch/i386/kernel/smpboot.c | 11 ++++++----- arch/i386/mach-voyager/voyager_smp.c | 6 ++++++ arch/ia64/kernel/smpboot.c | 6 ++++++ arch/parisc/kernel/smp.c | 6 ++++++ arch/ppc/kernel/smp.c | 6 ++++++ arch/ppc64/kernel/smp.c | 6 ++++++ arch/s390/kernel/smp.c | 6 ++++++ arch/s390x/kernel/smp.c | 6 ++++++ arch/sparc64/kernel/smp.c | 6 ++++++ arch/um/kernel/smp.c | 5 +++++ arch/x86_64/kernel/smpboot.c | 6 ++++++ include/asm-ia64/system.h | 3 --- include/linux/smp.h | 10 +++++++++- init/main.c | 7 +++++++ kernel/printk.c | 16 ++++++++-------- 16 files changed, 95 insertions(+), 17 deletions(-) (limited to 'include/linux') diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c index a6ab21ca5bb8..148aaaf310f3 100644 --- a/arch/alpha/kernel/smp.c +++ b/arch/alpha/kernel/smp.c @@ -607,6 +607,12 @@ smp_prepare_cpus(unsigned int max_cpus) smp_boot_cpus(); } +void __devinit +smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_present_mask); +} + int __devinit __cpu_up(unsigned int cpu) { diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 7c08f768281c..b602e889879f 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c @@ -995,11 +995,6 @@ static void __init smp_boot_cpus(unsigned int max_cpus) printk("CPU%d: ", 0); print_cpu_info(&cpu_data[0]); - /* - * We have the boot CPU online for sure. - */ - set_bit(0, &cpu_online_map); - set_bit(0, &cpu_callout_map); boot_cpu_logical_apicid = logical_smp_processor_id(); map_cpu_to_boot_apicid(0, boot_cpu_apicid); @@ -1172,6 +1167,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_boot_cpus(max_cpus); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_callout_map); +} + int __devinit __cpu_up(unsigned int cpu) { /* This only works at boot for x86. See "rewrite" above. */ diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c index 6875c8346171..a6355ae320fd 100644 --- a/arch/i386/mach-voyager/voyager_smp.c +++ b/arch/i386/mach-voyager/voyager_smp.c @@ -1942,6 +1942,12 @@ smp_prepare_cpus(unsigned int max_cpus) smp_boot_cpus(); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_callout_map); +} + int __devinit __cpu_up(unsigned int cpu) { diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index e1c9a5ead71b..6223825e0beb 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c @@ -506,6 +506,12 @@ smp_prepare_cpus (unsigned int max_cpus) } } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_callin_map); +} + void smp_cpus_done (unsigned int dummy) { diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c index 50dd06819c85..7ea4390aed85 100644 --- a/arch/parisc/kernel/smp.c +++ b/arch/parisc/kernel/smp.c @@ -706,6 +706,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_boot_cpus(); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_present_mask); +} + int __devinit __cpu_up(unsigned int cpu) { return cpu_online(cpu) ? 0 : -ENOSYS; diff --git a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c index 6a10bcbe7579..8b5270afcdba 100644 --- a/arch/ppc/kernel/smp.c +++ b/arch/ppc/kernel/smp.c @@ -351,6 +351,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_ops->space_timers(num_cpus); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_possible_map); +} + int __init setup_profiling_timer(unsigned int multiplier) { return 0; diff --git a/arch/ppc64/kernel/smp.c b/arch/ppc64/kernel/smp.c index 7db75666d205..eeae9cb81e58 100644 --- a/arch/ppc64/kernel/smp.c +++ b/arch/ppc64/kernel/smp.c @@ -604,6 +604,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_space_timers(max_cpus); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + /* FIXME: what about cpu_possible()? */ +} + int __devinit __cpu_up(unsigned int cpu) { struct pt_regs regs; diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index a9dc74a7ca5d..e02e5c8c47fe 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -572,6 +572,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) set_prefix((u32) lowcore_ptr[smp_processor_id()]); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_possible_map); +} + void smp_cpus_done(unsigned int max_cpus) { } diff --git a/arch/s390x/kernel/smp.c b/arch/s390x/kernel/smp.c index 11b0d8f1d24e..8abfde52cb9a 100644 --- a/arch/s390x/kernel/smp.c +++ b/arch/s390x/kernel/smp.c @@ -554,6 +554,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) set_prefix((u32)(u64) lowcore_ptr[smp_processor_id()]); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_possible_map); +} + void smp_cpus_done(unsigned int max_cpis) { } diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c index 64963cd4e949..52c390c34dd8 100644 --- a/arch/sparc64/kernel/smp.c +++ b/arch/sparc64/kernel/smp.c @@ -1246,6 +1246,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_store_cpu_info(boot_cpu_id); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &phys_cpu_present_map); +} + int __devinit __cpu_up(unsigned int cpu) { int ret = smp_boot_one_cpu(cpu); diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c index 3503ed13f59a..ad740a718957 100644 --- a/arch/um/kernel/smp.c +++ b/arch/um/kernel/smp.c @@ -186,6 +186,11 @@ void smp_prepare_cpus(unsigned int maxcpus) } } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); +} + int __cpu_up(unsigned int cpu) { set_bit(cpu, &smp_commenced_mask); diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c index e7acfed4bf2a..a305c3916e64 100644 --- a/arch/x86_64/kernel/smpboot.c +++ b/arch/x86_64/kernel/smpboot.c @@ -962,6 +962,12 @@ void __init smp_prepare_cpus(unsigned int max_cpus) smp_boot_cpus(max_cpus); } +void __devinit smp_prepare_boot_cpu(void) +{ + set_bit(smp_processor_id(), &cpu_online_map); + set_bit(smp_processor_id(), &cpu_callout_map); +} + int __devinit __cpu_up(unsigned int cpu) { /* This only works at boot for x86. See "rewrite" above. */ diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h index d09f11cb14ec..e621c5c08b94 100644 --- a/include/asm-ia64/system.h +++ b/include/asm-ia64/system.h @@ -234,9 +234,6 @@ extern void ia64_load_extra (struct task_struct *task); #ifdef CONFIG_SMP -/* Return true if this CPU can call the console drivers in printk() */ -#define arch_consoles_callable() (cpu_online_map & (1UL << smp_processor_id())) - /* * In the SMP case, we save the fph state when context-switching * away from a thread that modified fph. This way, when the thread diff --git a/include/linux/smp.h b/include/linux/smp.h index 7a1e22b170c2..8243c6bec130 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -78,6 +78,13 @@ extern int register_cpu_notifier(struct notifier_block *nb); extern void unregister_cpu_notifier(struct notifier_block *nb); int cpu_up(unsigned int cpu); + +/* + * Mark the boot cpu "online" so that it can call console drivers in + * printk() and can access its per-cpu storage. + */ +void smp_prepare_boot_cpu(void); + #else /* !SMP */ /* @@ -94,7 +101,8 @@ static inline void smp_send_reschedule_all(void) { } #define cpu_online(cpu) ({ BUG_ON((cpu) != 0); 1; }) #define num_online_cpus() 1 #define num_booting_cpus() 1 -#define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; }) +#define cpu_possible(cpu) ({ BUG_ON((cpu) != 0); 1; }) +#define smp_prepare_boot_cpu() do {} while (0) struct notifier_block; diff --git a/init/main.c b/init/main.c index 6770292ed29a..b07fac4e9f02 100644 --- a/init/main.c +++ b/init/main.c @@ -377,6 +377,13 @@ asmlinkage void __init start_kernel(void) printk(linux_banner); setup_arch(&command_line); setup_per_cpu_areas(); + + /* + * Mark the boot cpu "online" so that it can call console drivers in + * printk() and can access its per-cpu storage. + */ + smp_prepare_boot_cpu(); + build_all_zonelists(); page_alloc_init(); printk("Kernel command line: %s\n", saved_command_line); diff --git a/kernel/printk.c b/kernel/printk.c index bb1bcb0d723f..ffe724fabc0e 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -27,6 +27,7 @@ #include /* For in_interrupt() */ #include #include +#include #include @@ -42,10 +43,6 @@ #define LOG_BUF_MASK (LOG_BUF_LEN-1) -#ifndef arch_consoles_callable -#define arch_consoles_callable() (1) -#endif - /* printk's without a loglevel use this.. */ #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */ @@ -447,10 +444,12 @@ asmlinkage int printk(const char *fmt, ...) log_level_unknown = 1; } - if (!arch_consoles_callable()) { + if (!cpu_online(smp_processor_id())) { /* - * On some architectures, the consoles are not usable - * on secondary CPUs early in the boot process. + * Some console drivers may assume that per-cpu resources have + * been allocated. So don't allow them to be called by this + * CPU until it is officially up. We shouldn't be calling into + * random console drivers on a CPU which doesn't exist yet.. */ spin_unlock_irqrestore(&logbuf_lock, flags); goto out; @@ -638,7 +637,8 @@ void register_console(struct console * console) } if (console->flags & CON_PRINTBUFFER) { /* - * release_console_sem() will print out the buffered messages for us. + * release_console_sem() will print out the buffered messages + * for us. */ spin_lock_irqsave(&logbuf_lock, flags); con_start = log_start; -- cgit v1.2.3