Skip to contentSkip to conversation

drivers/pnp/: possible cleanups

PATCH In review Adrian Bunk 3 participants 6 messages Mar 11, 2005 – Mar 12, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/pnp/: possible cleanups

This patch contains the following possible cleanups:
- make needlessly global code static
- #if 0 the following unused global function:
- core.c: pnp_remove_device
- remove the following unneeded EXPORT_SYMBOL's:
- card.c: pnp_add_card
- card.c: pnp_remove_card
- card.c: pnp_add_card_device
- card.c: pnp_remove_card_device
- card.c: pnp_add_card_id
- core.c: pnp_register_protocol
- core.c: pnp_unregister_protocol
- core.c: pnp_add_device
- core.c: pnp_remove_device
- pnpacpi/core.c: pnpacpi_protocol
- driver.c: pnp_add_id
- isapnp/core.c: isapnp_read_byte
- manager.c: pnp_auto_config_dev
- resource.c: pnp_register_dependent_option
- resource.c: pnp_register_independent_option
- resource.c: pnp_register_irq_resource
- resource.c: pnp_register_dma_resource
- resource.c: pnp_register_port_resource
- resource.c: pnp_register_mem_resource

---

This patch was already sent on:
- 27 Feb 2005

 drivers/pnp/card.c         |    7 +------
 drivers/pnp/core.c         |    7 ++-----
 drivers/pnp/driver.c       |    1 -
 drivers/pnp/isapnp/core.c  |    1 -
 drivers/pnp/manager.c      |    1 -
 drivers/pnp/pnpacpi/core.c |    5 ++---
 drivers/pnp/resource.c     |    8 --------
 include/linux/pnp.h        |    2 --
 8 files changed, 5 insertions(+), 27 deletions(-)
drivers/pnp/card.c renamed from drivers/pnp/card.c.old +1 -6
@@ -19,7 +19,7 @@
 #include "base.h"
 
 LIST_HEAD(pnp_cards);
-LIST_HEAD(pnp_card_drivers);
+static LIST_HEAD(pnp_card_drivers);
 
 
 static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card)
@@ -380,11 +380,6 @@
 	pnp_unregister_driver(&drv->link);
 }
 
-EXPORT_SYMBOL(pnp_add_card);
-EXPORT_SYMBOL(pnp_remove_card);
-EXPORT_SYMBOL(pnp_add_card_device);
-EXPORT_SYMBOL(pnp_remove_card_device);
-EXPORT_SYMBOL(pnp_add_card_id);
 EXPORT_SYMBOL(pnp_request_card_device);
 EXPORT_SYMBOL(pnp_release_card_device);
 EXPORT_SYMBOL(pnp_register_card_driver);
include/linux/pnp.h renamed from include/linux/pnp.h.old +0 -2
@@ -353,7 +353,6 @@
 int pnp_register_protocol(struct pnp_protocol *protocol);
 void pnp_unregister_protocol(struct pnp_protocol *protocol);
 int pnp_add_device(struct pnp_dev *dev);
-void pnp_remove_device(struct pnp_dev *dev);
 int pnp_device_attach(struct pnp_dev *pnp_dev);
 void pnp_device_detach(struct pnp_dev *pnp_dev);
 extern struct list_head pnp_global;
@@ -399,7 +398,6 @@
 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 void pnp_remove_device(struct pnp_dev *dev) { }
 static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
 static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; }
 
drivers/pnp/core.c renamed from drivers/pnp/core.c.old +2 -5
@@ -158,13 +158,14 @@
  *
  * this function will free all mem used by dev
  */
-
+#if 0
 void pnp_remove_device(struct pnp_dev *dev)
 {
 	if (!dev || dev->card)
 		return;
 	__pnp_remove_device(dev);
 }
+#endif  /*  0  */
 
 static int __init pnp_init(void)
 {
@@ -174,7 +175,3 @@
 
 subsys_initcall(pnp_init);
 
-EXPORT_SYMBOL(pnp_register_protocol);
-EXPORT_SYMBOL(pnp_unregister_protocol);
-EXPORT_SYMBOL(pnp_add_device);
-EXPORT_SYMBOL(pnp_remove_device);
drivers/pnp/pnpacpi/core.c renamed from drivers/pnp/pnpacpi/core.c.old +2 -3
@@ -124,7 +124,7 @@
 	return ACPI_FAILURE(status) ? -ENODEV : 0;
 }
 
-struct pnp_protocol pnpacpi_protocol = {
+static struct pnp_protocol pnpacpi_protocol = {
 	.name	= "Plug and Play ACPI",
 	.get	= pnpacpi_get_resources,
 	.set	= pnpacpi_set_resources,
@@ -242,7 +242,7 @@
 }
 
 int pnpacpi_disabled __initdata;
-int __init pnpacpi_init(void)
+static int __init pnpacpi_init(void)
 {
 	if (acpi_disabled || pnpacpi_disabled) {
 		pnp_info("PnP ACPI: disabled");
@@ -266,4 +266,3 @@
 }
 __setup("pnpacpi=", pnpacpi_setup);
 
-EXPORT_SYMBOL(pnpacpi_protocol);
drivers/pnp/driver.c renamed from drivers/pnp/driver.c.old +0 -1
@@ -217,6 +217,5 @@
 
 EXPORT_SYMBOL(pnp_register_driver);
 EXPORT_SYMBOL(pnp_unregister_driver);
-EXPORT_SYMBOL(pnp_add_id);
 EXPORT_SYMBOL(pnp_device_attach);
 EXPORT_SYMBOL(pnp_device_detach);
drivers/pnp/isapnp/core.c renamed from drivers/pnp/isapnp/core.c.old +0 -1
@@ -952,7 +952,6 @@
 EXPORT_SYMBOL(isapnp_present);
 EXPORT_SYMBOL(isapnp_cfg_begin);
 EXPORT_SYMBOL(isapnp_cfg_end);
-EXPORT_SYMBOL(isapnp_read_byte);
 EXPORT_SYMBOL(isapnp_write_byte);
 
 static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table *res)
drivers/pnp/manager.c renamed from drivers/pnp/manager.c.old +0 -1
@@ -563,7 +563,6 @@
 
 
 EXPORT_SYMBOL(pnp_manual_config_dev);
-EXPORT_SYMBOL(pnp_auto_config_dev);
 EXPORT_SYMBOL(pnp_activate_dev);
 EXPORT_SYMBOL(pnp_disable_dev);
 EXPORT_SYMBOL(pnp_resource_change);
drivers/pnp/resource.c renamed from drivers/pnp/resource.c.old +0 -8
@@ -478,14 +478,6 @@
 }
 
 
-EXPORT_SYMBOL(pnp_register_dependent_option);
-EXPORT_SYMBOL(pnp_register_independent_option);
-EXPORT_SYMBOL(pnp_register_irq_resource);
-EXPORT_SYMBOL(pnp_register_dma_resource);
-EXPORT_SYMBOL(pnp_register_port_resource);
-EXPORT_SYMBOL(pnp_register_mem_resource);
-
-
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 
 static int __init pnp_setup_reserve_irq(char *str)
#1 lore raw

This patch essential makes it impossible for PnP protocols to be modules. Currently, they are all in-kernel. If that is acceptable..., then this patch looks fine to me. Any comments?

Thanks,
Adam

Quoted 27 lines · Adrian Bunk

This patch contains the following possible cleanups:
- make needlessly global code static
- #if 0 the following unused global function:
- core.c: pnp_remove_device
- remove the following unneeded EXPORT_SYMBOL's:
- card.c: pnp_add_card
- card.c: pnp_remove_card
- card.c: pnp_add_card_device
- card.c: pnp_remove_card_device
- card.c: pnp_add_card_id
- core.c: pnp_register_protocol
- core.c: pnp_unregister_protocol
- core.c: pnp_add_device
- core.c: pnp_remove_device
- pnpacpi/core.c: pnpacpi_protocol
- driver.c: pnp_add_id
- isapnp/core.c: isapnp_read_byte
- manager.c: pnp_auto_config_dev
- resource.c: pnp_register_dependent_option
- resource.c: pnp_register_independent_option
- resource.c: pnp_register_irq_resource
- resource.c: pnp_register_dma_resource
- resource.c: pnp_register_port_resource
- resource.c: pnp_register_mem_resource

#2 lore raw
Quoted 4 lines · Adam Belay

This patch essential makes it impossible for PnP protocols to be modules. Currently, they are all in-kernel. If that is acceptable..., then this patch looks fine to me. Any comments?

You're the maintainer...

If someone converts a protocol to be moduar, presumably they will re-add the needed exports to support that.

Are there likely to be any out-of-tree modular protocols in existence?

#3 lore raw
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Adam Belay

This patch essential makes it impossible for PnP protocols to be modules. Currently, they are all in-kernel. If that is acceptable..., then this patch looks fine to me. Any comments?

You're the maintainer...

I've been holding off on making many changes to PnP at the moment, because I have been considering replacing it with a new (more modern and ACPI capable) ISA/LPC bridge driver. This work would likely begin after my PCI bridge driver rewrite is finished and merged (as the PCI work is in some ways a prerequisite).

http://marc.theaimsgroup.com/?l=linux-kernel&m=111023821617705&w=2

Still, if there are changes to fix actual bugs, then I'm all for them.

Also a few features could be added. Specifically PnPBIOS hotplug/docking station support. If anyone's interested, I may implement it (and it would use some functions that were removed by this patch). Furthermore, ISAPnP could be made a module. PnPBIOS probably couldn't.

Quoted 3 lines

If someone converts a protocol to be moduar, presumably they will re-add the needed exports to support that.

Correct.

Quoted 3 lines

Are there likely to be any out-of-tree modular protocols in existence?

Not that I'm aware of.

So in short, I'd rather not remove them, because they take away from the original design of the PnP layer.

Thanks,
Adam

#4 lore raw
Quoted 3 lines

So in short, I'd rather not remove them, because they take away from the original design of the PnP layer.

s/they/it would

#5 lore raw
In reply to Adam Belay
Quoted 17 lines · Adam Belay
Quoted 7 lines · Andrew Morton
Quoted 4 lines · Adam Belay

This patch essential makes it impossible for PnP protocols to be modules. Currently, they are all in-kernel. If that is acceptable..., then this patch looks fine to me. Any comments?

You're the maintainer...

I've been holding off on making many changes to PnP at the moment, because I have been considering replacing it with a new (more modern and ACPI capable) ISA/LPC bridge driver. This work would likely begin after my PCI bridge driver rewrite is finished and merged (as the PCI work is in some ways a prerequisite).

http://marc.theaimsgroup.com/?l=linux-kernel&m=111023821617705&w=2

Quoted 8 lines

Still, if there are changes to fix actual bugs, then I'm all for them.

Also a few features could be added. Specifically PnPBIOS hotplug/docking station support. If anyone's interested, I may implement it (and it would use some functions that were removed by this patch). Furthermore, ISAPnP could be made a module. PnPBIOS probably couldn't.
...

Note that my patch #if 0's exactly one functions and removes no functions. Most it does is the removal of EXPORT_SYMBOL's, so if any modular code will use any of them, re-adding will be trivial.

Modular ISAPnP might be interesting in some cases, but this is more legacy code. If someone would work on it to sort all the issues out (starting with the point that most users of __ISAPNP__ will have to be fixed) re-adding the required EXPORT_SYMBOL's won't be hard for him.

Quoted 2 lines

Thanks,
Adam

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed