aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2006-03-25 06:07:17 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:22:53 -0500
commite51c01b08474ea454a965a937fff0407ab6714c7 (patch)
tree403e22aa86b4a24699df7cc1285ab915ec3eda1a /drivers
parent5930860296ca438071d3824bf7306ad0dfd33fc1 (diff)
[PATCH] hp300: fix driver_register() return handling, remove dio_module_init()
Remove the assumption that driver_register() returns the number of devices bound to the driver. In fact, it returns zero for success or a negative error value. dio_module_init() used the device count to automatically unregister and unload drivers that found no devices. That might have worked at one time, but has been broken for some time because dio_register_driver() returned either a negative error or a positive count (never zero). So it could only unregister on failure, when it's not needed anyway. This functionality could be resurrected in individual drivers by counting devices in their .probe() methods. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Philip Blundell <philb@gnu.org> Cc: Jochen Friedrich <jochen@scram.de> Cc: "Antonino A. Daplas" <adaplas@pol.net> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dio/dio-driver.c9
-rw-r--r--drivers/net/hplance.c2
-rw-r--r--drivers/serial/8250_hp300.c10
-rw-r--r--drivers/video/hpfb.c4
4 files changed, 11 insertions, 14 deletions
diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
index ca8e69d2f64d..e4c48e329367 100644
--- a/drivers/dio/dio-driver.c
+++ b/drivers/dio/dio-driver.c
@@ -71,22 +71,17 @@ static int dio_device_probe(struct device *dev)
71 * @drv: the driver structure to register 71 * @drv: the driver structure to register
72 * 72 *
73 * Adds the driver structure to the list of registered drivers 73 * Adds the driver structure to the list of registered drivers
74 * Returns the number of DIO devices which were claimed by the driver 74 * Returns zero or a negative error value.
75 * during registration. The driver remains registered even if the
76 * return value is zero.
77 */ 75 */
78 76
79int dio_register_driver(struct dio_driver *drv) 77int dio_register_driver(struct dio_driver *drv)
80{ 78{
81 int count = 0;
82
83 /* initialize common driver fields */ 79 /* initialize common driver fields */
84 drv->driver.name = drv->name; 80 drv->driver.name = drv->name;
85 drv->driver.bus = &dio_bus_type; 81 drv->driver.bus = &dio_bus_type;
86 82
87 /* register with core */ 83 /* register with core */
88 count = driver_register(&drv->driver); 84 return driver_register(&drv->driver);
89 return count ? count : 1;
90} 85}
91 86
92 87
diff --git a/drivers/net/hplance.c b/drivers/net/hplance.c
index d8410634bcaf..685693464605 100644
--- a/drivers/net/hplance.c
+++ b/drivers/net/hplance.c
@@ -217,7 +217,7 @@ static int hplance_close(struct net_device *dev)
217 217
218int __init hplance_init_module(void) 218int __init hplance_init_module(void)
219{ 219{
220 return dio_module_init(&hplance_driver); 220 return dio_register_driver(&hplance_driver);
221} 221}
222 222
223void __exit hplance_cleanup_module(void) 223void __exit hplance_cleanup_module(void)
diff --git a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
index 4315afe9c080..53e81a44c1a3 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/serial/8250_hp300.c
@@ -55,6 +55,8 @@ static struct dio_driver hpdca_driver = {
55 55
56#endif 56#endif
57 57
58static unsigned int num_ports;
59
58extern int hp300_uart_scode; 60extern int hp300_uart_scode;
59 61
60/* Offset to UART registers from base of DCA */ 62/* Offset to UART registers from base of DCA */
@@ -199,6 +201,8 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
199 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff); 201 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff);
200 udelay(100); 202 udelay(100);
201 203
204 num_ports++;
205
202 return 0; 206 return 0;
203} 207}
204#endif 208#endif
@@ -206,7 +210,6 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
206static int __init hp300_8250_init(void) 210static int __init hp300_8250_init(void)
207{ 211{
208 static int called = 0; 212 static int called = 0;
209 int num_ports;
210#ifdef CONFIG_HPAPCI 213#ifdef CONFIG_HPAPCI
211 int line; 214 int line;
212 unsigned long base; 215 unsigned long base;
@@ -221,11 +224,8 @@ static int __init hp300_8250_init(void)
221 if (!MACH_IS_HP300) 224 if (!MACH_IS_HP300)
222 return -ENODEV; 225 return -ENODEV;
223 226
224 num_ports = 0;
225
226#ifdef CONFIG_HPDCA 227#ifdef CONFIG_HPDCA
227 if (dio_module_init(&hpdca_driver) == 0) 228 dio_register_driver(&hpdca_driver);
228 num_ports++;
229#endif 229#endif
230#ifdef CONFIG_HPAPCI 230#ifdef CONFIG_HPAPCI
231 if (hp300_model < HP_400) { 231 if (hp300_model < HP_400) {
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c
index bebdac59d231..abd920a663a0 100644
--- a/drivers/video/hpfb.c
+++ b/drivers/video/hpfb.c
@@ -386,7 +386,9 @@ int __init hpfb_init(void)
386 if (fb_get_options("hpfb", NULL)) 386 if (fb_get_options("hpfb", NULL))
387 return -ENODEV; 387 return -ENODEV;
388 388
389 dio_module_init(&hpfb_driver); 389 err = dio_register_driver(&hpfb_driver);
390 if (err)
391 return err;
390 392
391 fs = get_fs(); 393 fs = get_fs();
392 set_fs(KERNEL_DS); 394 set_fs(KERNEL_DS);