From: Prarit Bhargava <prarit@redhat.com> Date: Wed, 13 Aug 2008 15:35:42 -0400 Subject: [misc] pnp: increase number of devices Message-id: 20080813193313.20122.38626.sendpatchset@prarit.bos.redhat.com O-Subject: [RHEL5 PATCH]: Increase number of PNP devices Bugzilla: 445590 RH-Acked-by: Doug Chapman <dchapman@redhat.com> RH-Acked-by: Neil Horman <nhorman@redhat.com> HP may have greater than 256 PNP devices in a system. The upstream fix http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=544451a1a36b06f43fc67112ede3b92e6203eb9d proposed for RHEL5 breaks kabi by modifying the pnp_dev struct. The device id number below is really only required to satisfy the kobject code, so just pass the number through. dchapman tested this patch on a large HP system and confirmed that the patch resolves the issue in RHEL5. Successfully compiled and booted by me. Sucessfully tested by dchapman. Resolves BZ 445590. diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index 227600c..2643d44 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c @@ -237,16 +237,18 @@ void pnp_remove_card(struct pnp_card * card) * pnp_add_card_device - adds a device to the specified card * @card: pointer to the card to add to * @dev: pointer to the device to add + * @number: unique number identifying the device */ -int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev) +int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev, + unsigned int number) { if (!card || !dev || !dev->protocol) return -EINVAL; dev->dev.parent = &card->dev; dev->card_link = NULL; - snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", dev->protocol->number, - card->number,dev->number); + snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", + dev->protocol->number, card->number, number); spin_lock(&pnp_lock); dev->card = card; list_add_tail(&dev->card_list, &card->devices); diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index aec83ec..99f9a7c 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c @@ -130,16 +130,17 @@ int __pnp_add_device(struct pnp_dev *dev) /* * pnp_add_device - adds a pnp device to the pnp layer * @dev: pointer to dev to add + * @number: unique number identifying device * * adds to driver model, name database, fixups, interface, etc. */ -int pnp_add_device(struct pnp_dev *dev) +int pnp_add_device(struct pnp_dev *dev, unsigned int number) { if (!dev || !dev->protocol || dev->card) return -EINVAL; dev->dev.parent = &dev->protocol->dev; - sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, dev->number); + sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, number); return __pnp_add_device(dev); } diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index f2e0179..8b62cca 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c @@ -631,7 +631,7 @@ static int __init isapnp_create_device(struct pnp_card *card, kfree(dev); return 1; } - pnp_add_card_device(card,dev); + pnp_add_card_device(card,dev, dev->number); while (1) { if (isapnp_read_tag(&type, &size)<0) @@ -650,7 +650,7 @@ static int __init isapnp_create_device(struct pnp_card *card, kfree(dev); return 1; } - pnp_add_card_device(card,dev); + pnp_add_card_device(card,dev, dev->number); } else { skip = 1; } diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 49954b4..3470a4c 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -168,7 +168,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); dev->number = num; - + /* set the initial values for the PnP device */ dev_id = kcalloc(1, sizeof(struct pnp_id), GFP_KERNEL); if (!dev_id) @@ -214,7 +214,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device) /* clear out the damaged flags */ if (!dev->active) pnp_init_resource_table(&dev->res); - pnp_add_device(dev); + pnp_add_device(dev, num); num ++; return AE_OK; diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index 551f58e..b05b1bb 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -359,7 +359,7 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) if (!dev->active) pnp_init_resource_table(&dev->res); - pnp_add_device(dev); + pnp_add_device(dev, dev->number); pnpbios_interface_attach_device(node); return 0; diff --git a/include/linux/pnp.h b/include/linux/pnp.h index ab8a8dd..96551c7 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -357,7 +357,7 @@ struct pnp_protocol { /* device management */ int pnp_register_protocol(struct pnp_protocol *protocol); void pnp_unregister_protocol(struct pnp_protocol *protocol); -int pnp_add_device(struct pnp_dev *dev); +int pnp_add_device(struct pnp_dev *dev, unsigned int number); int pnp_device_attach(struct pnp_dev *pnp_dev); void pnp_device_detach(struct pnp_dev *pnp_dev); extern struct list_head pnp_global; @@ -365,7 +365,8 @@ extern struct list_head pnp_global; /* multidevice card support */ int pnp_add_card(struct pnp_card *card); void pnp_remove_card(struct pnp_card *card); -int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); +int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev, + unsigned int number); void pnp_remove_card_device(struct pnp_dev *dev); int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card); struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from); @@ -405,14 +406,14 @@ void pnp_unregister_driver(struct pnp_driver *drv); static inline int pnp_register_protocol(struct pnp_protocol *protocol) { return -ENODEV; } static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { } static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; } -static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_add_device(struct pnp_dev *dev, unsigned int number) { return -ENODEV; } static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; } /* multidevice card support */ static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; } static inline void pnp_remove_card(struct pnp_card *card) { ; } -static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev, unsigned int number) { return -ENODEV; } static inline void pnp_remove_card_device(struct pnp_dev *dev) { ; } static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; } static inline struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) { return NULL; }