From 6c6bc41e3ef895a622f2ff0b72289f507336a54c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 26 Dec 2002 18:56:19 +0100 Subject: PnP update - added configuration templates - configuration can be changed from the probe() callback - new PnP ID - NSC6001 - fixes in PnP BIOS code - no more oopses - fixed typos and thinkos in 8250_pnp.c --- include/linux/pnp.h | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'include/linux') diff --git a/include/linux/pnp.h b/include/linux/pnp.h index d666c6a92b9f..ba87a50fb02d 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -26,6 +26,7 @@ struct pnp_resource; struct pnp_protocol; struct pnp_id; +struct pnp_cfg; struct pnp_card { char name[80]; @@ -79,7 +80,6 @@ static inline void pnpc_set_protodata (struct pnp_card *pcard, void *data) struct pnp_dev { char name[80]; /* device name */ int active; /* status of the device */ - int ro; /* read only */ struct list_head global_list; /* node in global list of devices */ struct list_head protocol_list; /* node in list of device's protocol */ struct list_head card_list; /* node in card's list of devices */ @@ -93,6 +93,7 @@ struct pnp_dev { unsigned short regs; /* ISAPnP: supported registers */ struct pnp_resources *res; /* possible resource information */ + int lock_resources; /* resources are locked */ struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ struct resource dma_resource[DEVICE_COUNT_DMA]; struct resource irq_resource[DEVICE_COUNT_IRQ]; @@ -112,6 +113,13 @@ struct pnp_dev { dev != global_to_pnp_dev(&pnp_global); \ dev = global_to_pnp_dev(dev->global_list.next)) +static inline int pnp_dev_has_driver(struct pnp_dev *pdev) +{ + if (pdev->driver || (pdev->card && pdev->card->driver)) + return 1; + return 0; +} + static inline void *pnp_get_drvdata (struct pnp_dev *pdev) { return dev_get_drvdata(&pdev->dev); @@ -160,10 +168,13 @@ struct pnp_card_id { } devs[MAX_DEVICES]; /* logical devices */ }; +#define PNP_DRIVER_DO_NOT_ACTIVATE (1<<0) + struct pnp_driver { struct list_head node; char *name; const struct pnp_device_id *id_table; + unsigned int flags; int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id); void (*remove) (struct pnp_dev *dev); struct device_driver driver; @@ -171,10 +182,13 @@ struct pnp_driver { #define to_pnp_driver(drv) container_of(drv,struct pnp_driver, driver) +#define PNPC_DRIVER_DO_NOT_ACTIVATE (1<<0) + struct pnpc_driver { struct list_head node; char *name; const struct pnp_card_id *id_table; + unsigned int flags; int (*probe) (struct pnp_card *card, const struct pnp_card_id *card_id); void (*remove) (struct pnp_card *card); struct device_driver driver; @@ -279,6 +293,12 @@ struct pnp_resources { struct pnp_resources *dep; /* dependent resources */ }; +struct pnp_res_cfg { + struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ + struct resource dma_resource[DEVICE_COUNT_DMA]; + struct resource irq_resource[DEVICE_COUNT_IRQ]; +}; + #define PNP_DYNAMIC 0 /* get or set current resource */ #define PNP_STATIC 1 /* get or set resource for next boot */ @@ -287,7 +307,7 @@ struct pnp_cfg { struct pnp_irq *irq[2]; struct pnp_dma *dma[2]; struct pnp_mem *mem[4]; - struct pnp_dev request; + struct pnp_res_cfg request; }; @@ -340,9 +360,11 @@ int pnp_add_dma_resource(struct pnp_dev *dev, int depnum, struct pnp_dma *data); int pnp_add_port_resource(struct pnp_dev *dev, int depnum, struct pnp_port *data); int pnp_add_mem_resource(struct pnp_dev *dev, int depnum, struct pnp_mem *data); int pnp_add_mem32_resource(struct pnp_dev *dev, int depnum, struct pnp_mem32 *data); -int pnp_activate_dev(struct pnp_dev *dev); +int pnp_init_res_cfg(struct pnp_res_cfg *template); +int pnp_activate_dev(struct pnp_dev *dev, struct pnp_res_cfg *template); int pnp_disable_dev(struct pnp_dev *dev); -int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, int mode); +int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, struct pnp_res_cfg *template, int mode); +void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size); /* driver */ int compare_pnp_id(struct pnp_id * pos, const char * id); @@ -366,9 +388,10 @@ static inline int pnp_add_dma_resource(struct pnp_dev *dev, int depnum, struct p static inline int pnp_add_port_resource(struct pnp_dev *dev, int depnum, struct pnp_irq *data) { return -ENODEV; } static inline int pnp_add_mem_resource(struct pnp_dev *dev, int depnum, struct pnp_irq *data) { return -ENODEV; } static inline int pnp_add_mem32_resource(struct pnp_dev *dev, int depnum, struct pnp_irq *data) { return -ENODEV; } -static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_init_res_cfg(struct pnp_res_cfg *template) { return -ENODEV; } +static inline int pnp_activate_dev(struct pnp_dev *dev, struct pnp_res_cfg *template) { return -ENODEV; } static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } -static inline int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, int mode) { return -ENODEV; } +static inline int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, struct pnp_res_cfg *template, int mode) { return -ENODEV; } static inline int compare_pnp_id(struct list_head * id_list, const char * id) { return -ENODEV; } static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; } static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } -- cgit v1.2.3 From 45b9faf354d0aa5554dc2607f8168a34ce625a3a Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 26 Dec 2002 21:42:08 +0100 Subject: PnP update - removed ISAPnP members from PCI structures - isapnp.h cleanups (removal of duplicates) - added compatible functions (pnp_find_dev and pnp_find_card) - i82365 (pcmcia driver) - ported to new PnP layer --- drivers/pcmcia/i82365.c | 26 ++++----- drivers/pnp/isapnp/Makefile | 4 +- drivers/pnp/isapnp/compat.c | 25 ++++---- drivers/pnp/isapnp/core.c | 54 +++++++++-------- drivers/pnp/isapnp/proc.c | 1 + include/linux/isapnp.h | 138 +------------------------------------------- include/linux/pci.h | 19 +----- include/linux/pnp.h | 12 ++-- 8 files changed, 65 insertions(+), 214 deletions(-) (limited to 'include/linux') diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 8c2cd91ad6c3..893561738443 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -814,7 +814,7 @@ static void __init add_pcic(int ns, int type) #ifdef CONFIG_ISA -#ifdef __ISAPNP__ +#ifdef CONFIG_PNP static struct isapnp_device_id id_table[] __initdata = { { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_FUNCTION(0x0e00), (unsigned long) "Intel 82365-Compatible" }, @@ -826,32 +826,28 @@ static struct isapnp_device_id id_table[] __initdata = { }; MODULE_DEVICE_TABLE(isapnp, id_table); -static struct pci_dev *i82365_pnpdev; +static struct pnp_dev *i82365_pnpdev; #endif static void __init isa_probe(void) { int i, j, sock, k, ns, id; ioaddr_t port; -#ifdef __ISAPNP__ +#ifdef CONFIG_PNP struct isapnp_device_id *devid; - struct pci_dev *dev; + struct pnp_dev *dev; for (devid = id_table; devid->vendor; devid++) { - if ((dev = isapnp_find_dev(NULL, devid->vendor, devid->function, NULL))) { - printk("ISAPNP "); + if ((dev = pnp_find_dev(NULL, devid->vendor, devid->function, NULL))) { + printk("PNP "); - if (dev->prepare && dev->prepare(dev) < 0) { - printk("prepare failed\n"); - break; - } - - if (dev->activate && dev->activate(dev) < 0) { + if (pnp_activate_dev(dev, NULL) < 0) { printk("activate failed\n"); break; } - if ((i365_base = pci_resource_start(dev, 0))) { + i365_base = pnp_port_start(dev, 0); + if (i365_base) { printk("no resources ?\n"); break; } @@ -1644,8 +1640,8 @@ static void __exit exit_i82365(void) release_region(socket[i].ioaddr, 2); } #if defined(CONFIG_ISA) && defined(__ISAPNP__) - if (i82365_pnpdev && i82365_pnpdev->deactivate) - i82365_pnpdev->deactivate(i82365_pnpdev); + if (i82365_pnpdev) + pnp_disable_dev(i82365_pnpdev); #endif } /* exit_i82365 */ diff --git a/drivers/pnp/isapnp/Makefile b/drivers/pnp/isapnp/Makefile index 62c36dd5df7e..1539195169db 100644 --- a/drivers/pnp/isapnp/Makefile +++ b/drivers/pnp/isapnp/Makefile @@ -2,8 +2,8 @@ # Makefile for the kernel ISAPNP driver. # -export-objs := core.o +export-objs := core.o compat.o isapnp-proc-$(CONFIG_PROC_FS) = proc.o -obj-y := core.o $(isapnp-proc-y) +obj-y := core.o compat.o $(isapnp-proc-y) diff --git a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c index 862c21feba05..834a4ee8b4a9 100644 --- a/drivers/pnp/isapnp/compat.c +++ b/drivers/pnp/isapnp/compat.c @@ -26,21 +26,20 @@ static void pnp_convert_id(char *buf, unsigned short vendor, unsigned short devi } struct pnp_card *pnp_find_card(unsigned short vendor, - unsigned short device, - struct pnp_card *from) + unsigned short device, + struct pnp_card *from) { char id[7]; char any[7]; struct list_head *list; pnp_convert_id(id, vendor, device); pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID); - list = isapnp_cards.next; - if (from) - list = from->node.next; - while (list != &isapnp_cards) { - struct pnp_card *card = to_pnp_card(list); - if (compare_pnp_id(&card->ids,id) || (memcmp(id,any,7)==0)) + list = from ? from->global_list.next : pnp_cards.next; + + while (list != &pnp_cards) { + struct pnp_card *card = global_to_pnp_card(list); + if (compare_pnp_id(card->id,id) || (memcmp(id,any,7)==0)) return card; list = list->next; } @@ -48,9 +47,9 @@ struct pnp_card *pnp_find_card(unsigned short vendor, } struct pnp_dev *pnp_find_dev(struct pnp_card *card, - unsigned short vendor, - unsigned short function, - struct pnp_dev *from) + unsigned short vendor, + unsigned short function, + struct pnp_dev *from) { char id[7]; char any[7]; @@ -65,7 +64,7 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card, while (list != &pnp_global) { struct pnp_dev *dev = global_to_pnp_dev(list); - if (compare_pnp_id(&dev->ids,id) || (memcmp(id,any,7)==0)) + if (compare_pnp_id(dev->id,id) || (memcmp(id,any,7)==0)) return dev; list = list->next; } @@ -80,7 +79,7 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card, } while (list != &card->devices) { struct pnp_dev *dev = card_to_pnp_dev(list); - if (compare_pnp_id(&dev->ids,id)) + if (compare_pnp_id(dev->id,id)) return dev; list = list->next; } diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 5630e8a145ba..fa683efd00a3 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -42,12 +42,8 @@ #include #include #include -#include #include -LIST_HEAD(isapnp_cards); -LIST_HEAD(isapnp_devices); - #if 0 #define ISAPNP_REGION_OK #endif @@ -106,6 +102,8 @@ static int isapnp_detected; /* some prototypes */ static int isapnp_config_prepare(struct pnp_dev *dev); +extern struct pnp_protocol isapnp_card_protocol; +extern struct pnp_protocol isapnp_protocol; static inline void write_data(unsigned char x) { @@ -521,7 +519,7 @@ static void __init isapnp_add_port_resource(struct pnp_dev *dev, port->max = (tmp[4] << 8) | tmp[3]; port->align = tmp[5]; port->size = tmp[6]; - port->flags = tmp[0] ? ISAPNP_PORT_FLAG_16BITADDR : 0; + port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0; pnp_add_port_resource(dev,depnum,port); return; } @@ -543,7 +541,7 @@ static void __init isapnp_add_fixed_port_resource(struct pnp_dev *dev, port->min = port->max = (tmp[1] << 8) | tmp[0]; port->size = tmp[2]; port->align = 0; - port->flags = ISAPNP_PORT_FLAG_FIXED; + port->flags = PNP_PORT_FLAG_FIXED; pnp_add_port_resource(dev,depnum,port); return; } @@ -686,7 +684,7 @@ static int __init isapnp_create_device(struct pnp_card *card, case _STAG_STARTDEP: if (size > 1) goto __skip; - dependent = 0x100 | ISAPNP_RES_PRIORITY_ACCEPTABLE; + dependent = 0x100 | PNP_RES_PRIORITY_ACCEPTABLE; if (size > 0) { isapnp_peek(tmp, size); dependent = 0x100 | tmp[0]; @@ -891,7 +889,7 @@ static int __init isapnp_build_device_list(void) if (isapnp_checksum_value != 0x00) printk(KERN_ERR "isapnp: checksum for device %i is not valid (0x%x)\n", csn, isapnp_checksum_value); card->checksum = isapnp_checksum_value; - card->protocol = &isapnp_protocol; + card->protocol = &isapnp_card_protocol; pnpc_add_card(card); } return 0; @@ -903,7 +901,12 @@ static int __init isapnp_build_device_list(void) int isapnp_present(void) { - return !list_empty(&isapnp_devices); + struct pnp_card *card; + pnp_for_each_card(card) { + if (card->protocol == &isapnp_card_protocol) + return 1; + } + return 0; } int isapnp_cfg_begin(int csn, int logdev) @@ -970,24 +973,11 @@ static int isapnp_config_prepare(struct pnp_dev *dev) return 0; } -void isapnp_resource_change(struct resource *resource, - unsigned long start, - unsigned long size) -{ - if (resource == NULL) - return; - resource->flags &= ~IORESOURCE_AUTO; - resource->start = start; - resource->end = start + size - 1; -} - /* * Inititialization. */ -EXPORT_SYMBOL(isapnp_cards); -EXPORT_SYMBOL(isapnp_devices); EXPORT_SYMBOL(isapnp_present); EXPORT_SYMBOL(isapnp_cfg_begin); EXPORT_SYMBOL(isapnp_cfg_end); @@ -999,7 +989,6 @@ EXPORT_SYMBOL(isapnp_write_word); EXPORT_SYMBOL(isapnp_write_dword); EXPORT_SYMBOL(isapnp_wake); EXPORT_SYMBOL(isapnp_device); -EXPORT_SYMBOL(isapnp_resource_change); static int isapnp_get_resources(struct pnp_dev *dev) { @@ -1053,8 +1042,15 @@ static int isapnp_disable_resources(struct pnp_dev *dev) return 0; } +struct pnp_protocol isapnp_card_protocol = { + .name = "ISA Plug and Play - card", + .get = NULL, + .set = NULL, + .disable = NULL, +}; + struct pnp_protocol isapnp_protocol = { - .name = "ISA Plug and Play", + .name = "ISA Plug and Play - device", .get = isapnp_get_resources, .set = isapnp_set_resources, .disable = isapnp_disable_resources, @@ -1064,6 +1060,7 @@ int __init isapnp_init(void) { int cards; struct pnp_card *card; + struct pnp_dev *dev; if (isapnp_disable) { isapnp_detected = 0; @@ -1084,6 +1081,9 @@ int __init isapnp_init(void) return -EBUSY; } + if(pnp_register_protocol(&isapnp_card_protocol)<0) + return -EBUSY; + if(pnp_register_protocol(&isapnp_protocol)<0) return -EBUSY; @@ -1126,13 +1126,11 @@ int __init isapnp_init(void) protocol_for_each_card(&isapnp_protocol,card) { cards++; if (isapnp_verbose) { - struct list_head *devlist; printk(KERN_INFO "isapnp: Card '%s'\n", card->name[0]?card->name:"Unknown"); if (isapnp_verbose < 2) continue; - for (devlist = card->devices.next; devlist != &card->devices; devlist = devlist->next) { - struct pci_dev *dev = pci_dev_b(devlist); - printk(KERN_INFO "isapnp: Device '%s'\n", dev->dev.name[0]?card->name:"Unknown"); + pnp_card_for_each_dev(card,dev) { + printk(KERN_INFO "isapnp: Device '%s'\n", dev->name[0]?dev->name:"Unknown"); } } } diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c index f3427d078367..2330ee03f808 100644 --- a/drivers/pnp/isapnp/proc.c +++ b/drivers/pnp/isapnp/proc.c @@ -28,6 +28,7 @@ #include #include +extern struct pnp_protocol isapnp_protocol; static struct proc_dir_entry *isapnp_proc_bus_dir = NULL; diff --git a/include/linux/isapnp.h b/include/linux/isapnp.h index 7008adef1677..3e03c39fbc40 100644 --- a/include/linux/isapnp.h +++ b/include/linux/isapnp.h @@ -24,6 +24,7 @@ #include #include +#include /* * Configuration registers (TODO: change by specification) @@ -54,79 +55,7 @@ #ifdef __KERNEL__ -#include - -#define ISAPNP_PORT_FLAG_16BITADDR (1<<0) -#define ISAPNP_PORT_FLAG_FIXED (1<<1) - -struct isapnp_port { - unsigned short min; /* min base number */ - unsigned short max; /* max base number */ - unsigned char align; /* align boundary */ - unsigned char size; /* size of range */ - unsigned char flags; /* port flags */ - unsigned char pad; /* pad */ - struct isapnp_resources *res; /* parent */ - struct isapnp_port *next; /* next port */ -}; - -struct isapnp_irq { - unsigned short map; /* bitmaks for IRQ lines */ - unsigned char flags; /* IRQ flags */ - unsigned char pad; /* pad */ - struct isapnp_resources *res; /* parent */ - struct isapnp_irq *next; /* next IRQ */ -}; - -struct isapnp_dma { - unsigned char map; /* bitmask for DMA channels */ - unsigned char flags; /* DMA flags */ - struct isapnp_resources *res; /* parent */ - struct isapnp_dma *next; /* next port */ -}; - -struct isapnp_mem { - unsigned int min; /* min base number */ - unsigned int max; /* max base number */ - unsigned int align; /* align boundary */ - unsigned int size; /* size of range */ - unsigned char flags; /* memory flags */ - unsigned char pad; /* pad */ - struct isapnp_resources *res; /* parent */ - struct isapnp_mem *next; /* next memory resource */ -}; - -struct isapnp_mem32 { - /* TODO */ - unsigned char data[17]; - struct isapnp_resources *res; /* parent */ - struct isapnp_mem32 *next; /* next 32-bit memory resource */ -}; - -struct isapnp_fixup { - unsigned short vendor; /* matching vendor */ - unsigned short device; /* matching device */ - void (*quirk_function)(struct pci_dev *dev); /* fixup function */ -}; - - -#define ISAPNP_RES_PRIORITY_PREFERRED 0 -#define ISAPNP_RES_PRIORITY_ACCEPTABLE 1 -#define ISAPNP_RES_PRIORITY_FUNCTIONAL 2 -#define ISAPNP_RES_PRIORITY_INVALID 65535 - -struct isapnp_resources { - unsigned short priority; /* priority */ - unsigned short dependent; /* dependent resources */ - struct isapnp_port *port; /* first port */ - struct isapnp_irq *irq; /* first IRQ */ - struct isapnp_dma *dma; /* first DMA */ - struct isapnp_mem *mem; /* first memory resource */ - struct isapnp_mem32 *mem32; /* first 32-bit memory */ - struct pci_dev *dev; /* parent */ - struct isapnp_resources *alt; /* alternative resource (aka dependent resources) */ - struct isapnp_resources *next; /* next resource */ -}; +#define DEVICE_COUNT_COMPATIBLE 4 #define ISAPNP_ANY_ID 0xffff #define ISAPNP_CARD_DEVS 8 @@ -162,14 +91,6 @@ struct isapnp_device_id { unsigned long driver_data; /* data private to the driver */ }; -struct isapnp_driver { - struct list_head node; - char *name; - const struct isapnp_device_id *id_table; /* NULL if wants all devices */ - int (*probe) (struct pci_dev *dev, const struct isapnp_device_id *id); /* New device inserted */ - void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ -}; - #if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE)) #define __ISAPNP__ @@ -188,7 +109,6 @@ void isapnp_wake(unsigned char csn); void isapnp_device(unsigned char device); void isapnp_activate(unsigned char device); void isapnp_deactivate(unsigned char device); -void isapnp_fixup_device(struct pci_dev *dev); void *isapnp_alloc(long size); #ifdef CONFIG_PROC_FS @@ -199,40 +119,8 @@ static inline isapnp_proc_init(void) { return 0; } static inline isapnp_proc_done(void) { return 0; } #endif -/* misc */ -void isapnp_resource_change(struct resource *resource, - unsigned long start, - unsigned long size); /* init/main.c */ int isapnp_init(void); -/* manager */ -static inline struct pci_bus *isapnp_find_card(unsigned short vendor, - unsigned short device, - struct pci_bus *from) { return NULL; } -static inline struct pci_dev *isapnp_find_dev(struct pci_bus *card, - unsigned short vendor, - unsigned short function, - struct pci_dev *from) { return NULL; } -static inline int isapnp_probe_cards(const struct isapnp_card_id *ids, - int (*probe)(struct pci_bus *card, - const struct isapnp_card_id *id)) { return -ENODEV; } -static inline int isapnp_probe_devs(const struct isapnp_device_id *ids, - int (*probe)(struct pci_dev *dev, - const struct isapnp_device_id *id)) { return -ENODEV; } -static inline int isapnp_activate_dev(struct pci_dev *dev, const char *name) { return -ENODEV; } - -static inline int isapnp_register_driver(struct isapnp_driver *drv) { return 0; } - -static inline void isapnp_unregister_driver(struct isapnp_driver *drv) { } - -extern struct list_head isapnp_cards; -extern struct list_head isapnp_devices; -extern struct pnp_protocol isapnp_protocol; - -#define isapnp_for_each_card(card) \ - for(card = to_pnp_card(isapnp_cards.next); card != to_pnp_card(&isapnp_cards); card = to_pnp_card(card->node.next)) -#define isapnp_for_each_dev(dev) \ - for(dev = protocol_to_pnp_dev(isapnp_protocol.devices.next); dev != protocol_to_pnp_dev(&isapnp_protocol.devices); dev = protocol_to_pnp_dev(dev->dev_list.next)) #else /* !CONFIG_ISAPNP */ @@ -250,28 +138,6 @@ static inline void isapnp_wake(unsigned char csn) { ; } static inline void isapnp_device(unsigned char device) { ; } static inline void isapnp_activate(unsigned char device) { ; } static inline void isapnp_deactivate(unsigned char device) { ; } -/* manager */ -static inline struct pci_bus *isapnp_find_card(unsigned short vendor, - unsigned short device, - struct pci_bus *from) { return NULL; } -static inline struct pci_dev *isapnp_find_dev(struct pci_bus *card, - unsigned short vendor, - unsigned short function, - struct pci_dev *from) { return NULL; } -static inline int isapnp_probe_cards(const struct isapnp_card_id *ids, - int (*probe)(struct pci_bus *card, - const struct isapnp_card_id *id)) { return -ENODEV; } -static inline int isapnp_probe_devs(const struct isapnp_device_id *ids, - int (*probe)(struct pci_dev *dev, - const struct isapnp_device_id *id)) { return -ENODEV; } -static inline void isapnp_resource_change(struct resource *resource, - unsigned long start, - unsigned long size) { ; } -static inline int isapnp_activate_dev(struct pci_dev *dev, const char *name) { return -ENODEV; } - -static inline int isapnp_register_driver(struct isapnp_driver *drv) { return 0; } - -static inline void isapnp_unregister_driver(struct isapnp_driver *drv) { } #endif /* CONFIG_ISAPNP */ diff --git a/include/linux/pci.h b/include/linux/pci.h index 557b17d959c1..e77013ae6a60 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -362,7 +362,7 @@ enum pci_mmap_state { #define PCI_ANY_ID (~0) /* - * The pci_dev structure is used to describe both PCI and ISAPnP devices. + * The pci_dev structure is used to describe PCI devices. */ struct pci_dev { struct list_head global_list; /* node in list of all PCI devices */ @@ -410,16 +410,9 @@ struct pci_dev { struct resource irq_resource[DEVICE_COUNT_IRQ]; char slot_name[8]; /* slot name */ - int active; /* ISAPnP: device is active */ - int ro; /* ISAPnP: read only */ - unsigned short regs; /* ISAPnP: supported registers */ /* These fields are used by common fixups */ - unsigned short transparent:1; /* Transparent PCI bridge */ - - int (*prepare)(struct pci_dev *dev); /* ISAPnP hooks */ - int (*activate)(struct pci_dev *dev); - int (*deactivate)(struct pci_dev *dev); + unsigned int transparent:1; /* Transparent PCI bridge */ }; #define pci_dev_g(n) list_entry(n, struct pci_dev, global_list) @@ -463,13 +456,7 @@ struct pci_bus { unsigned char subordinate; /* max number of subordinate buses */ char name[48]; - unsigned short vendor; - unsigned short device; - unsigned int serial; /* serial number */ - unsigned char pnpver; /* Plug & Play version */ - unsigned char productver; /* product version */ - unsigned char checksum; /* if zero - checksum passed */ - unsigned char pad1; + struct device * dev; }; diff --git a/include/linux/pnp.h b/include/linux/pnp.h index ba87a50fb02d..7d4e9fd6ae0e 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -51,11 +51,15 @@ struct pnp_card { #define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list) #define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list) -#define to_pnp_card(n) list_entry(n, struct pnp_card, dev) +#define to_pnp_card(n) container_of(n, struct pnp_card, dev) #define pnp_for_each_card(card) \ - for(dev = global_to_pnp_card(pnp_cards.next); \ - dev != global_to_pnp_card(&cards); \ - dev = global_to_pnp_card(card>global_list.next)) + for((card) = global_to_pnp_card(pnp_cards.next); \ + (card) != global_to_pnp_card(&pnp_cards); \ + (card) = global_to_pnp_card((card)->global_list.next)) +#define pnp_card_for_each_dev(card,dev) \ + for((dev) = card_to_pnp_dev((card)->devices.next); \ + (dev) != card_to_pnp_dev(&(card)->devices); \ + (dev) = card_to_pnp_dev((dev)->card_list.next)) static inline void *pnpc_get_drvdata (struct pnp_card *pcard) { -- 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 From 27b3d11b51725704a8aab84dbc36258b1f53a250 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 30 Dec 2002 02:07:24 -0800 Subject: [PATCH] more i2c cruft removal * version code checks for pre-2.4 version * !__KERNEL__ stuff in headers. --- drivers/i2c/i2c-adap-ite.c | 6 -- drivers/i2c/i2c-philips-par.c | 16 ---- drivers/i2c/i2c-proc.c | 10 +-- include/linux/i2c-dev.h | 177 +----------------------------------------- include/linux/i2c.h | 37 ++------- 5 files changed, 10 insertions(+), 236 deletions(-) (limited to 'include/linux') diff --git a/drivers/i2c/i2c-adap-ite.c b/drivers/i2c/i2c-adap-ite.c index 2c7b5103806c..28352ac46df6 100644 --- a/drivers/i2c/i2c-adap-ite.c +++ b/drivers/i2c/i2c-adap-ite.c @@ -61,11 +61,7 @@ static int own = 0; static int i2c_debug=0; static struct iic_ite gpi; -#if (LINUX_VERSION_CODE < 0x020301) -static struct wait_queue *iic_wait = NULL; -#else static wait_queue_head_t iic_wait; -#endif static int iic_pending; /* ----- global defines ----------------------------------------------- */ @@ -236,9 +232,7 @@ static int __init iic_ite_init(void) piic->iic_own = own; iic_ite_data.data = (void *)piic; -#if (LINUX_VERSION_CODE >= 0x020301) init_waitqueue_head(&iic_wait); -#endif if (iic_hw_resrc_init() == 0) { if (i2c_iic_add_bus(&iic_ite_ops) < 0) return -ENODEV; diff --git a/drivers/i2c/i2c-philips-par.c b/drivers/i2c/i2c-philips-par.c index ce2258a20447..b489b5f37114 100644 --- a/drivers/i2c/i2c-philips-par.c +++ b/drivers/i2c/i2c-philips-par.c @@ -228,41 +228,25 @@ static void i2c_parport_detach (struct parport *port) } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4) static struct parport_driver i2c_driver = { "i2c-philips-par", i2c_parport_attach, i2c_parport_detach, NULL }; -#endif int __init i2c_bitlp_init(void) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,4) - struct parport *port; -#endif printk(KERN_INFO "i2c-philips-par.o: i2c Philips parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4) parport_register_driver(&i2c_driver); -#else - for (port = parport_enumerate(); port; port=port->next) - i2c_parport_attach(port); -#endif return 0; } void __exit i2c_bitlp_exit(void) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,4) parport_unregister_driver(&i2c_driver); -#else - struct parport *port; - for (port = parport_enumerate(); port; port=port->next) - i2c_parport_detach(port); -#endif } MODULE_AUTHOR("Simon G. Vogl "); diff --git a/drivers/i2c/i2c-proc.c b/drivers/i2c/i2c-proc.c index 785e9c5f3716..3b97e96de669 100644 --- a/drivers/i2c/i2c-proc.c +++ b/drivers/i2c/i2c-proc.c @@ -23,7 +23,6 @@ This driver puts entries in /proc/sys/dev/sensors for each I2C device */ -#include #include #include #include @@ -31,14 +30,10 @@ #include #include #include -#include #include #include #include - -#ifndef THIS_MODULE -#define THIS_MODULE NULL -#endif +#include static int i2c_create_name(char **name, const char *prefix, struct i2c_adapter *adapter, int addr); @@ -56,7 +51,6 @@ static int i2c_sysctl_chips(ctl_table * table, int *name, int nlen, #define SENSORS_ENTRY_MAX 20 static struct ctl_table_header *i2c_entries[SENSORS_ENTRY_MAX]; -static unsigned short i2c_inodes[SENSORS_ENTRY_MAX]; static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX]; @@ -197,8 +191,6 @@ int i2c_register_entry(struct i2c_client *client, const char *prefix, return id; } #endif /* DEBUG */ - i2c_inodes[id - 256] = - new_header->ctl_table->child->child->de->low_ino; new_header->ctl_table->child->child->de->owner = controlling_mod; return id; diff --git a/include/linux/i2c-dev.h b/include/linux/i2c-dev.h index ee6ddba913bb..84bede1ed6ac 100644 --- a/include/linux/i2c-dev.h +++ b/include/linux/i2c-dev.h @@ -21,9 +21,8 @@ /* $Id: i2c-dev.h,v 1.11 2002/07/07 15:42:47 mds Exp $ */ -#ifndef I2C_DEV_H -#define I2C_DEV_H - +#ifndef _LINUX_I2C_DEV_H +#define _LINUX_I2C_DEV_H #include #include @@ -45,174 +44,4 @@ struct i2c_rdwr_ioctl_data { int nmsgs; /* number of i2c_msgs */ }; -#ifndef __KERNEL__ - -#include - -static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, - int size, union i2c_smbus_data *data) -{ - struct i2c_smbus_ioctl_data args; - - args.read_write = read_write; - args.command = command; - args.size = size; - args.data = data; - return ioctl(file,I2C_SMBUS,&args); -} - - -static inline __s32 i2c_smbus_write_quick(int file, __u8 value) -{ - return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL); -} - -static inline __s32 i2c_smbus_read_byte(int file) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data)) - return -1; - else - return 0x0FF & data.byte; -} - -static inline __s32 i2c_smbus_write_byte(int file, __u8 value) -{ - return i2c_smbus_access(file,I2C_SMBUS_WRITE,value, - I2C_SMBUS_BYTE,NULL); -} - -static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_BYTE_DATA,&data)) - return -1; - else - return 0x0FF & data.byte; -} - -static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command, - __u8 value) -{ - union i2c_smbus_data data; - data.byte = value; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BYTE_DATA, &data); -} - -static inline __s32 i2c_smbus_read_word_data(int file, __u8 command) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_WORD_DATA,&data)) - return -1; - else - return 0x0FFFF & data.word; -} - -static inline __s32 i2c_smbus_write_word_data(int file, __u8 command, - __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_WORD_DATA, &data); -} - -static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_PROC_CALL,&data)) - return -1; - else - return 0x0FFFF & data.word; -} - - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_read_block_data(int file, __u8 command, - __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_BLOCK_DATA,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -static inline __s32 i2c_smbus_write_block_data(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_DATA, &data); -} - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, - __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (i2c_smbus_access(file,I2C_SMBUS_READ,command, - I2C_SMBUS_I2C_BLOCK_DATA,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_I2C_BLOCK_DATA, &data); -} - -/* Returns the number of read bytes */ -static inline __s32 i2c_smbus_block_process_call(int file, __u8 command, - __u8 length, __u8 *values) -{ - union i2c_smbus_data data; - int i; - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_PROC_CALL,&data)) - return -1; - else { - for (i = 1; i <= data.block[0]; i++) - values[i-1] = data.block[i]; - return data.block[0]; - } -} - -#endif /* ndef __KERNEL__ */ - -#endif +#endif /* _LINUX_I2C_DEV_H */ diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 765a95af3a4e..c176ca672cc7 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -25,31 +25,17 @@ /* $Id: i2c.h,v 1.59 2002/07/19 20:53:45 phil Exp $ */ -#ifndef I2C_H -#define I2C_H +#ifndef _LINUX_I2C_H +#define _LINUX_I2C_H #define I2C_DATE "20020719" #define I2C_VERSION "2.6.4" #include /* id values of adapters et. al. */ #include - - -struct i2c_msg; - - -#ifdef __KERNEL__ - -/* --- Includes and compatibility declarations ------------------------ */ - -#include -#ifndef KERNEL_VERSION -#define KERNEL_VERSION(a,b,c) (((a) << 16) | ((b) << 8) | (c)) -#endif - -#include /* for 2.2.xx */ -#include #include +#include + /* --- General options ------------------------------------------------ */ @@ -59,6 +45,7 @@ struct i2c_msg; #define I2C_CLIENT_MAX 32 #define I2C_DUMMY_MAX 4 +struct i2c_msg; struct i2c_algorithm; struct i2c_adapter; struct i2c_client; @@ -212,10 +199,6 @@ struct i2c_algorithm { u32 (*functionality) (struct i2c_adapter *); }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29) -struct proc_dir_entry; -#endif - /* * i2c_adapter is the structure used to identify a physical i2c bus along * with the access algorithms necessary to access it. @@ -250,9 +233,6 @@ struct i2c_adapter { #ifdef CONFIG_PROC_FS /* No need to set this when you initialize the adapter */ int inode; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29) - struct proc_dir_entry *proc_entry; -#endif #endif /* def CONFIG_PROC_FS */ }; @@ -355,8 +335,6 @@ extern u32 i2c_get_functionality (struct i2c_adapter *adap); /* Return 1 if adapter supports everything we need, 0 if not. */ extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func); -#endif /* __KERNEL__ */ - /* * I2C Message - used for pure i2c transaction, also from /dev interface */ @@ -506,8 +484,6 @@ union i2c_smbus_data { #define I2C_MAJOR 89 /* Device major number */ -#ifdef __KERNEL__ - # ifndef NULL # define NULL ( (void *) 0 ) # endif @@ -577,5 +553,4 @@ union i2c_smbus_data { #define i2c_is_isa_adapter(adapptr) \ ((adapptr)->algo->id == I2C_ALGO_ISA) -#endif /* def __KERNEL__ */ -#endif /* I2C_H */ +#endif /* _LINUX_I2C_H */ -- cgit v1.2.3