From: <aot...@us...> - 2004-05-24 00:59:09
|
Update of /cvsroot/gc-linux/linux/drivers/exi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3839/drivers/exi Modified Files: exi-driver.c Log Message: - Add (generic) ->probe() and ->remove() callbacks. - Fixup documentation accordingly. Index: exi-driver.c =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/exi/exi-driver.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- exi-driver.c 2 Mar 2004 23:43:24 -0000 1.3 +++ exi-driver.c 24 May 2004 00:58:58 -0000 1.4 @@ -1,18 +1,50 @@ /* * drivers/exi/exi-driver.c * + * Nintendo GameCube Expansion Interface support. Driver model routines. * Copyright (C) 2004 Arthur Othieno <a.o...@bl...> + * + * 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. */ #define DEBUG #include <linux/init.h> +#include <linux/errno.h> #include <linux/kernel.h> #include <linux/device.h> - #include <linux/exi.h> +static int exi_device_probe(struct device *dev) +{ + struct exi_dev *exi_dev = to_exi_dev(dev); + struct exi_driver *drv = to_exi_driver(dev->driver); + int err = -ENODEV; + + if (drv->probe) + err = drv->probe(exi_dev); + + return err; +} + +static int exi_device_remove(struct device *dev) +{ + struct exi_dev *exi_dev = to_exi_dev(dev); + struct exi_driver *drv = to_exi_driver(dev->driver); + + if (drv) { + if (drv->remove) + drv->remove(exi_dev); + exi_dev->dev.driver = NULL; + } + + return 0; +} + /** * exi_driver_register - register an EXI device driver. * @drv: driver structure to register. @@ -24,10 +56,14 @@ { drv->driver.name = drv->name; drv->driver.bus = &exi_bus_type; + drv->driver.probe = exi_device_probe; + drv->driver.remove = exi_device_remove; return driver_register(&drv->driver); } +EXPORT_SYMBOL(exi_driver_register); + /** * exi_driver_unregister - unregister an EXI device driver. * @drv: driver structure to unregister. @@ -40,17 +76,9 @@ driver_unregister(&drv->driver); } -/** - * exi_bus_match - attach a driver to a device. - * @dev: device structure to match. - * @drv: driver structure to match against. - * - * Attaches a driver to a device by matching the device IDs - * the driver claims to support with the actual device ID of - * a particular device. - * - * Returns 1 when driver is attached, 0 otherwise. - */ +EXPORT_SYMBOL(exi_driver_unregister); + + static int exi_bus_match(struct device *dev, struct device_driver *drv) { struct exi_dev *exi_dev = to_exi_dev(dev); @@ -69,15 +97,18 @@ return 0; } +struct bus_type exi_bus_type = { + .name = "exi", + .match = exi_bus_match, +}; + +EXPORT_SYMBOL(exi_bus_type); struct device exi_bus_dev = { .bus_id = "exi0", }; -struct bus_type exi_bus_type = { - .name = "exi", - .match = exi_bus_match, -}; +EXPORT_SYMBOL(exi_bus_dev); static int __init exi_driver_init(void) { @@ -92,8 +123,3 @@ } postcore_initcall(exi_driver_init); - -EXPORT_SYMBOL(exi_bus_dev); -EXPORT_SYMBOL(exi_bus_type); -EXPORT_SYMBOL(exi_driver_register); -EXPORT_SYMBOL(exi_driver_unregister); |