From 571806a9f70fc4a4c575ab796555dfb401c2dfc1 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 25 Oct 2011 15:03:42 +0200 Subject: lib: devres: add annotations for #endif While working on devres, I found those make navigating the code a tad easier. Signed-off-by: Wolfram Sang Acked-by: Grant Likely Signed-off-by: Greg Kroah-Hartman diff --git a/lib/devres.c b/lib/devres.c index 7c0e953..78777ae 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -348,5 +348,5 @@ void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask) } } EXPORT_SYMBOL(pcim_iounmap_regions); -#endif -#endif +#endif /* CONFIG_PCI */ +#endif /* CONFIG_HAS_IOPORT */ -- cgit v0.10.2 From 72f8c0bfa0de64c68ee59f40eb9b2683bffffbb0 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 25 Oct 2011 15:16:47 +0200 Subject: lib: devres: add convenience function to remap a resource Almost every platform_driver does the three steps get_resource, request_mem_region, ioremap. This does not only lead to a lot of code duplication, but also a huge number of similar error strings and inconsistent error codes on failure. So, introduce a helper function which simplifies remapping a resource and make it hard to do something wrong and add documentation for it. Signed-off-by: Wolfram Sang Acked-by: Grant Likely Acked-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index d79aead..10c64c8 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -262,6 +262,7 @@ IOMAP devm_ioremap() devm_ioremap_nocache() devm_iounmap() + devm_request_and_ioremap() : checks resource, requests region, ioremaps pcim_iomap() pcim_iounmap() pcim_iomap_table() : array of mapped addresses indexed by BAR diff --git a/include/linux/device.h b/include/linux/device.h index ffbcf95..c633598 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -490,6 +490,9 @@ extern int devres_release_group(struct device *dev, void *id); extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp); extern void devm_kfree(struct device *dev, void *p); +void __iomem *devm_request_and_ioremap(struct device *dev, + struct resource *res); + struct device_dma_parameters { /* * a low level driver may set these to teach IOMMU code about diff --git a/lib/devres.c b/lib/devres.c index 78777ae..4fbc09e 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -85,6 +85,57 @@ void devm_iounmap(struct device *dev, void __iomem *addr) } EXPORT_SYMBOL(devm_iounmap); +/** + * devm_request_and_ioremap() - Check, request region, and ioremap resource + * @dev: Generic device to handle the resource for + * @res: resource to be handled + * + * Takes all necessary steps to ioremap a mem resource. Uses managed device, so + * everything is undone on driver detach. Checks arguments, so you can feed + * it the result from e.g. platform_get_resource() directly. Returns the + * remapped pointer or NULL on error. Usage example: + * + * res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + * base = devm_request_and_ioremap(&pdev->dev, res); + * if (!base) + * return -EADDRNOTAVAIL; + */ +void __iomem *devm_request_and_ioremap(struct device *dev, + struct resource *res) +{ + resource_size_t size; + const char *name; + void __iomem *dest_ptr; + + BUG_ON(!dev); + + if (!res || resource_type(res) != IORESOURCE_MEM) { + dev_err(dev, "invalid resource\n"); + return NULL; + } + + size = resource_size(res); + name = res->name ?: dev_name(dev); + + if (!devm_request_mem_region(dev, res->start, size, name)) { + dev_err(dev, "can't request region for resource %pR\n", res); + return NULL; + } + + if (res->flags & IORESOURCE_CACHEABLE) + dest_ptr = devm_ioremap(dev, res->start, size); + else + dest_ptr = devm_ioremap_nocache(dev, res->start, size); + + if (!dest_ptr) { + dev_err(dev, "ioremap failed for resource %pR\n", res); + devm_release_mem_region(dev, res->start, size); + } + + return dest_ptr; +} +EXPORT_SYMBOL(devm_request_and_ioremap); + #ifdef CONFIG_HAS_IOPORT /* * Generic iomap devres -- cgit v0.10.2 From 65e6757be42ddf0a9115ec0e6af268fec9727359 Mon Sep 17 00:00:00 2001 From: Kautuk Consul Date: Tue, 15 Nov 2011 14:52:34 -0800 Subject: devtmpfsd: fix task state handling - Set the state to TASK_INTERRUPTIBLE using __set_current_state() instead of set_current_state() as the spin_unlock is an implicit memory barrier. - After return from schedule(), there is no need to set the current state to TASK_RUNNING - a call to schedule() always returns in TASK_RUNNING state. Signed-off-by: Kautuk Consul Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index a4760e0..2bb4bff 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -413,10 +413,9 @@ static int devtmpfsd(void *p) } spin_lock(&req_lock); } - set_current_state(TASK_INTERRUPTIBLE); + __set_current_state(TASK_INTERRUPTIBLE); spin_unlock(&req_lock); schedule(); - __set_current_state(TASK_RUNNING); } return 0; out: -- cgit v0.10.2 From 377195c438fc5e9e4ca59e69382c10771d817d6a Mon Sep 17 00:00:00 2001 From: Maciej Szmigiero Date: Wed, 16 Nov 2011 00:43:16 +0100 Subject: W1: w1_therm: release the bus during conversion on externally powered devices w1_therm devices can either be bus powered or externally powered. When device is bus powered during temperature conversion the bus have to be left high to provide necessary power. Some masters also allow strong power-up to be enabled in this case. Naturally, no communication over bus can occur during that time. However, if device has external power then there is no such restriction, and host can talk to other devices during temperature conversion. There is command which allows us to check how device is powered, this patch uses it to release the bus on externally w1_therm powered devices during temperature conversion. Also, this changes uninterruptible sleeps there into interruptible ones to avoid long uninterruptible sleep if w1 subsystem happens to grab bus for scan during w1_therm_read(). Signed-off-by: Maciej Szmigiero Acked-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index a1ef9b5..ff29ae7 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -175,11 +175,13 @@ static ssize_t w1_therm_read(struct device *device, { struct w1_slave *sl = dev_to_w1_slave(device); struct w1_master *dev = sl->master; - u8 rom[9], crc, verdict; + u8 rom[9], crc, verdict, external_power; int i, max_trying = 10; ssize_t c = PAGE_SIZE; - mutex_lock(&dev->mutex); + i = mutex_lock_interruptible(&dev->mutex); + if (i != 0) + return i; memset(rom, 0, sizeof(rom)); @@ -190,13 +192,37 @@ static ssize_t w1_therm_read(struct device *device, if (!w1_reset_select_slave(sl)) { int count = 0; unsigned int tm = 750; + unsigned long sleep_rem; + + w1_write_8(dev, W1_READ_PSUPPLY); + external_power = w1_read_8(dev); + + if (w1_reset_select_slave(sl)) + continue; /* 750ms strong pullup (or delay) after the convert */ - if (w1_strong_pullup) + if (!external_power && w1_strong_pullup) w1_next_pullup(dev, tm); + w1_write_8(dev, W1_CONVERT_TEMP); - if (!w1_strong_pullup) - msleep(tm); + + if (external_power) { + mutex_unlock(&dev->mutex); + + sleep_rem = msleep_interruptible(tm); + if (sleep_rem != 0) + return -EINTR; + + i = mutex_lock_interruptible(&dev->mutex); + if (i != 0) + return i; + } else if (!w1_strong_pullup) { + sleep_rem = msleep_interruptible(tm); + if (sleep_rem != 0) { + mutex_unlock(&dev->mutex); + return -EINTR; + } + } if (!w1_reset_select_slave(sl)) { -- cgit v0.10.2 From 907d0ed1c84114d4e8dafd66af982515d3739c90 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 10:13:35 +0100 Subject: drivercore: Generalize module_platform_driver This patch generalizes the module_platform_driver macro and introduces a new module_driver macro. The module_driver macro takes a driver name, a register and a unregister function for this driver type. Using these it construct the module init and exit sections which register and unregister the driver. Since such init/exit sections are commonly found in drivers this macro can be used to eliminate a lot of boilerplate code. The macro is not intended to be used by driver modules directly, instead it should be used to generate bus specific macros for registering drivers like the module_platform_driver macro. Signed-off-by: Lars-Peter Clausen Acked-by: Grant Likely Acked-by: Jonathan Cameron Acked-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/device.h b/include/linux/device.h index c633598..341fb74 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -922,4 +922,25 @@ extern long sysfs_deprecated; #define sysfs_deprecated 0 #endif +/** + * module_driver() - Helper macro for drivers that don't do anything + * special in module init/exit. This eliminates a lot of boilerplate. + * Each module may only use this macro once, and calling it replaces + * module_init() and module_exit(). + * + * Use this macro to construct bus specific macros for registering + * drivers, and do not use it on its own. + */ +#define module_driver(__driver, __register, __unregister) \ +static int __init __driver##_init(void) \ +{ \ + return __register(&(__driver)); \ +} \ +module_init(__driver##_init); \ +static void __exit __driver##_exit(void) \ +{ \ + __unregister(&(__driver)); \ +} \ +module_exit(__driver##_exit); + #endif /* _DEVICE_H_ */ diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 2a23f7d..165a8d1 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -196,16 +196,8 @@ static inline void platform_set_drvdata(struct platform_device *pdev, void *data * calling it replaces module_init() and module_exit() */ #define module_platform_driver(__platform_driver) \ -static int __init __platform_driver##_init(void) \ -{ \ - return platform_driver_register(&(__platform_driver)); \ -} \ -module_init(__platform_driver##_init); \ -static void __exit __platform_driver##_exit(void) \ -{ \ - platform_driver_unregister(&(__platform_driver)); \ -} \ -module_exit(__platform_driver##_exit); + module_driver(__platform_driver, platform_driver_register, \ + platform_driver_unregister) extern struct platform_device *platform_create_bundle(struct platform_driver *driver, int (*probe)(struct platform_device *), -- cgit v0.10.2 From 7c92784a546d2945b6d6973a30f7134be78eb7a4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 10:13:36 +0100 Subject: I2C: Add helper macro for i2c_driver boilerplate This patch introduces the module_i2c_driver macro which is a convenience macro for I2C driver modules similar to module_platform_driver. It is intended to be used by drivers which init/exit section does nothing but register/unregister the I2C driver. By using this macro it is possible to eliminate a few lines of boilerplate code per I2C driver. Signed-off-by: Lars-Peter Clausen Acked-by: Grant Likely Acked-by: Jonathan Cameron Acked-by: Wolfram Sang Acked-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/i2c.h b/include/linux/i2c.h index a81bf6d..7e92854 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -485,6 +485,19 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap) { return adap->nr; } + +/** + * module_i2c_driver() - Helper macro for registering a I2C driver + * @__i2c_driver: i2c_driver struct + * + * Helper macro for I2C drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_i2c_driver(__i2c_driver) \ + module_driver(__i2c_driver, i2c_add_driver, \ + i2c_del_driver) + #endif /* I2C */ #endif /* __KERNEL__ */ -- cgit v0.10.2 From 3acbb0142d48713a8f65cde678a54f419801c189 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 10:13:37 +0100 Subject: SPI: Add helper macro for spi_driver boilerplate This patch introduces the module_spi_driver macro which is a convenience macro for SPI driver modules similar to module_platform_driver. It is intended to be used by drivers which init/exit section does nothing but register/unregister the SPI driver. By using this macro it is possible to eliminate a few lines of boilerplate code per SPI driver. Signed-off-by: Lars-Peter Clausen Acked-by: Grant Likely Acked-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index bb4f5fb..176fce9 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -200,6 +200,17 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) driver_unregister(&sdrv->driver); } +/** + * module_spi_driver() - Helper macro for registering a SPI driver + * @__spi_driver: spi_driver struct + * + * Helper macro for SPI drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_spi_driver(__spi_driver) \ + module_driver(__spi_driver, spi_register_driver, \ + spi_unregister_driver) /** * struct spi_master - interface to SPI master controller -- cgit v0.10.2 From 6e5af184f810f6150e07339bd23a09c498739c82 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 10:13:38 +0100 Subject: staging:iio: Use module_i2c_driver to register I2C drivers Use the newly introduced module_i2c_driver macro for registering I2C drivers. This allows us to remove a few lines of boilerplate code. Signed-off-by: Lars-Peter Clausen Acked-by: Jonathan Cameron Acked-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 10e79e8..aa44a52 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c @@ -700,20 +700,8 @@ static struct i2c_driver ad7291_driver = { .remove = __devexit_p(ad7291_remove), .id_table = ad7291_id, }; - -static __init int ad7291_init(void) -{ - return i2c_add_driver(&ad7291_driver); -} - -static __exit void ad7291_exit(void) -{ - i2c_del_driver(&ad7291_driver); -} +module_i2c_driver(ad7291_driver); MODULE_AUTHOR("Sonic Zhang "); MODULE_DESCRIPTION("Analog Devices AD7291 ADC driver"); MODULE_LICENSE("GPL v2"); - -module_init(ad7291_init); -module_exit(ad7291_exit); diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index ee6cd79..c0d2f88 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -929,21 +929,9 @@ static struct i2c_driver ad799x_driver = { .remove = __devexit_p(ad799x_remove), .id_table = ad799x_id, }; - -static __init int ad799x_init(void) -{ - return i2c_add_driver(&ad799x_driver); -} - -static __exit void ad799x_exit(void) -{ - i2c_del_driver(&ad799x_driver); -} +module_i2c_driver(ad799x_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD799x ADC"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("i2c:ad799x"); - -module_init(ad799x_init); -module_exit(ad799x_exit); diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index a289e42..3481cf6 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c @@ -844,21 +844,9 @@ static struct i2c_driver adt7410_driver = { .remove = __devexit_p(adt7410_remove), .id_table = adt7410_id, }; - -static __init int adt7410_init(void) -{ - return i2c_add_driver(&adt7410_driver); -} - -static __exit void adt7410_exit(void) -{ - i2c_del_driver(&adt7410_driver); -} +module_i2c_driver(adt7410_driver); MODULE_AUTHOR("Sonic Zhang "); MODULE_DESCRIPTION("Analog Devices ADT7410 digital" " temperature sensor driver"); MODULE_LICENSE("GPL v2"); - -module_init(adt7410_init); -module_exit(adt7410_exit); diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index eb699ad..3f28f1a 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -1410,20 +1410,8 @@ static struct i2c_driver max1363_driver = { .remove = max1363_remove, .id_table = max1363_id, }; - -static __init int max1363_init(void) -{ - return i2c_add_driver(&max1363_driver); -} - -static __exit void max1363_exit(void) -{ - i2c_del_driver(&max1363_driver); -} +module_i2c_driver(max1363_driver); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("Maxim 1363 ADC"); MODULE_LICENSE("GPL v2"); - -module_init(max1363_init); -module_exit(max1363_exit); diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 07d718e..2c03a39 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -151,21 +151,9 @@ static struct i2c_driver adt7316_driver = { .resume = adt7316_i2c_resume, .id_table = adt7316_i2c_id, }; - -static __init int adt7316_i2c_init(void) -{ - return i2c_add_driver(&adt7316_driver); -} - -static __exit void adt7316_i2c_exit(void) -{ - i2c_del_driver(&adt7316_driver); -} +module_i2c_driver(adt7316_driver); MODULE_AUTHOR("Sonic Zhang "); MODULE_DESCRIPTION("I2C bus driver for Analog Devices ADT7316/7/9 and" "ADT7516/7/8 digital temperature sensor, ADC and DAC"); MODULE_LICENSE("GPL v2"); - -module_init(adt7316_i2c_init); -module_exit(adt7316_i2c_exit); diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index a761ca9..4718187 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -657,20 +657,8 @@ static struct i2c_driver ad7150_driver = { .remove = __devexit_p(ad7150_remove), .id_table = ad7150_id, }; - -static __init int ad7150_init(void) -{ - return i2c_add_driver(&ad7150_driver); -} - -static __exit void ad7150_exit(void) -{ - i2c_del_driver(&ad7150_driver); -} +module_i2c_driver(ad7150_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices AD7150/1/6 capacitive sensor driver"); MODULE_LICENSE("GPL v2"); - -module_init(ad7150_init); -module_exit(ad7150_exit); diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index 662584d..152d3be 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c @@ -540,20 +540,8 @@ static struct i2c_driver ad7152_driver = { .remove = __devexit_p(ad7152_remove), .id_table = ad7152_id, }; - -static __init int ad7152_init(void) -{ - return i2c_add_driver(&ad7152_driver); -} - -static __exit void ad7152_exit(void) -{ - i2c_del_driver(&ad7152_driver); -} +module_i2c_driver(ad7152_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices AD7152/3 capacitive sensor driver"); MODULE_LICENSE("GPL v2"); - -module_init(ad7152_init); -module_exit(ad7152_exit); diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index 2867943..9df5908 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -788,20 +788,8 @@ static struct i2c_driver ad7746_driver = { .remove = __devexit_p(ad7746_remove), .id_table = ad7746_id, }; - -static __init int ad7746_init(void) -{ - return i2c_add_driver(&ad7746_driver); -} - -static __exit void ad7746_exit(void) -{ - i2c_del_driver(&ad7746_driver); -} +module_i2c_driver(ad7746_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7746/5/7 capacitive sensor driver"); MODULE_LICENSE("GPL v2"); - -module_init(ad7746_init); -module_exit(ad7746_exit); diff --git a/drivers/staging/iio/dac/max517.c b/drivers/staging/iio/dac/max517.c index adfbd20..a4df6d7 100644 --- a/drivers/staging/iio/dac/max517.c +++ b/drivers/staging/iio/dac/max517.c @@ -280,20 +280,8 @@ static struct i2c_driver max517_driver = { .resume = max517_resume, .id_table = max517_id, }; - -static int __init max517_init(void) -{ - return i2c_add_driver(&max517_driver); -} - -static void __exit max517_exit(void) -{ - i2c_del_driver(&max517_driver); -} +module_i2c_driver(max517_driver); MODULE_AUTHOR("Roland Stigge "); MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC"); MODULE_LICENSE("GPL"); - -module_init(max517_init); -module_exit(max517_exit); diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 1086e0b..454d131 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -796,18 +796,7 @@ static struct i2c_driver ad5933_driver = { .remove = __devexit_p(ad5933_remove), .id_table = ad5933_id, }; - -static __init int ad5933_init(void) -{ - return i2c_add_driver(&ad5933_driver); -} -module_init(ad5933_init); - -static __exit void ad5933_exit(void) -{ - i2c_del_driver(&ad5933_driver); -} -module_exit(ad5933_exit); +module_i2c_driver(ad5933_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD5933 Impedance Conv. Network Analyzer"); diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 9dc9e63..4763836 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -603,19 +603,7 @@ static struct i2c_driver isl29018_driver = { .remove = __devexit_p(isl29018_remove), .id_table = isl29018_id, }; - -static int __init isl29018_init(void) -{ - return i2c_add_driver(&isl29018_driver); -} - -static void __exit isl29018_exit(void) -{ - i2c_del_driver(&isl29018_driver); -} - -module_init(isl29018_init); -module_exit(isl29018_exit); +module_i2c_driver(isl29018_driver); MODULE_DESCRIPTION("ISL29018 Ambient Light Sensor driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index 7e984bc..1942db1 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c @@ -866,20 +866,8 @@ static struct i2c_driver tsl2563_i2c_driver = { .remove = __devexit_p(tsl2563_remove), .id_table = tsl2563_id, }; - -static int __init tsl2563_init(void) -{ - return i2c_add_driver(&tsl2563_i2c_driver); -} - -static void __exit tsl2563_exit(void) -{ - i2c_del_driver(&tsl2563_i2c_driver); -} +module_i2c_driver(tsl2563_i2c_driver); MODULE_AUTHOR("Nokia Corporation"); MODULE_DESCRIPTION("tsl2563 light sensor driver"); MODULE_LICENSE("GPL"); - -module_init(tsl2563_init); -module_exit(tsl2563_exit); diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 80f77cf..3836f73 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -933,19 +933,7 @@ static struct i2c_driver taos_driver = { .probe = taos_probe, .remove = __devexit_p(taos_remove), }; - -static int __init taos_init(void) -{ - return i2c_add_driver(&taos_driver); -} - -static void __exit taos_exit(void) -{ - i2c_del_driver(&taos_driver); -} - -module_init(taos_init); -module_exit(taos_exit); +module_i2c_driver(taos_driver); MODULE_AUTHOR("J. August Brenner"); MODULE_DESCRIPTION("TAOS tsl2583 ambient light sensor driver"); diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 8b01712..db31d6d 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c @@ -572,19 +572,7 @@ static struct i2c_driver ak8975_driver = { .remove = __devexit_p(ak8975_remove), .id_table = ak8975_id, }; - -static int __init ak8975_init(void) -{ - return i2c_add_driver(&ak8975_driver); -} - -static void __exit ak8975_exit(void) -{ - i2c_del_driver(&ak8975_driver); -} - -module_init(ak8975_init); -module_exit(ak8975_exit); +module_i2c_driver(ak8975_driver); MODULE_AUTHOR("Laxman Dewangan "); MODULE_DESCRIPTION("AK8975 magnetometer driver"); diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index fc9ee97..7bb1bc6 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -618,20 +618,8 @@ static struct i2c_driver hmc5843_driver = { .suspend = hmc5843_suspend, .resume = hmc5843_resume, }; - -static int __init hmc5843_init(void) -{ - return i2c_add_driver(&hmc5843_driver); -} - -static void __exit hmc5843_exit(void) -{ - i2c_del_driver(&hmc5843_driver); -} +module_i2c_driver(hmc5843_driver); MODULE_AUTHOR("Shubhrajyoti Datta "); MODULE_DESCRIPTION("Analog Devices ADE7854/58/68/78 Polyphase Multifunction Energy Metering IC I2C Driver"); -- cgit v0.10.2 From ae6ae6fec3f7d6919e0146996df37b665c75f662 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 16 Nov 2011 10:13:39 +0100 Subject: staging:iio: Use module_spi_driver to register SPI driver Use the newly introduced module_spi_driver macro for registering SPI drivers. This allows us to remove a few lines of boilerplate code. Signed-off-by: Lars-Peter Clausen Acked-by: Grant Likely Acked-by: Jonathan Cameron Acked-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 1c5dad5..97f747e 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -549,18 +549,7 @@ static struct spi_driver adis16201_driver = { .probe = adis16201_probe, .remove = __devexit_p(adis16201_remove), }; - -static __init int adis16201_init(void) -{ - return spi_register_driver(&adis16201_driver); -} -module_init(adis16201_init); - -static __exit void adis16201_exit(void) -{ - spi_unregister_driver(&adis16201_driver); -} -module_exit(adis16201_exit); +module_spi_driver(adis16201_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16201 Programmable Digital Vibration Sensor driver"); diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 8a33374..a6d6d27 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -504,18 +504,7 @@ static struct spi_driver adis16203_driver = { .probe = adis16203_probe, .remove = __devexit_p(adis16203_remove), }; - -static __init int adis16203_init(void) -{ - return spi_register_driver(&adis16203_driver); -} -module_init(adis16203_init); - -static __exit void adis16203_exit(void) -{ - spi_unregister_driver(&adis16203_driver); -} -module_exit(adis16203_exit); +module_spi_driver(adis16203_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16203 Programmable Digital Vibration Sensor driver"); diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 644ac8e..7ac5b4c 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -577,18 +577,7 @@ static struct spi_driver adis16204_driver = { .probe = adis16204_probe, .remove = __devexit_p(adis16204_remove), }; - -static __init int adis16204_init(void) -{ - return spi_register_driver(&adis16204_driver); -} -module_init(adis16204_init); - -static __exit void adis16204_exit(void) -{ - spi_unregister_driver(&adis16204_driver); -} -module_exit(adis16204_exit); +module_spi_driver(adis16204_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("ADIS16204 High-g Digital Impact Sensor and Recorder"); diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index 0a8571b..c03afbf 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -553,18 +553,7 @@ static struct spi_driver adis16209_driver = { .probe = adis16209_probe, .remove = __devexit_p(adis16209_remove), }; - -static __init int adis16209_init(void) -{ - return spi_register_driver(&adis16209_driver); -} -module_init(adis16209_init); - -static __exit void adis16209_exit(void) -{ - spi_unregister_driver(&adis16209_driver); -} -module_exit(adis16209_exit); +module_spi_driver(adis16209_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16209 Digital Vibration Sensor driver"); diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 6d4503d..73298e7 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -708,18 +708,7 @@ static struct spi_driver adis16220_driver = { .probe = adis16220_probe, .remove = __devexit_p(adis16220_remove), }; - -static __init int adis16220_init(void) -{ - return spi_register_driver(&adis16220_driver); -} -module_init(adis16220_init); - -static __exit void adis16220_exit(void) -{ - spi_unregister_driver(&adis16220_driver); -} -module_exit(adis16220_exit); +module_spi_driver(adis16220_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16220 Digital Vibration Sensor"); diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index b8be292..88881b9 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -606,18 +606,7 @@ static struct spi_driver adis16240_driver = { .probe = adis16240_probe, .remove = __devexit_p(adis16240_remove), }; - -static __init int adis16240_init(void) -{ - return spi_register_driver(&adis16240_driver); -} -module_init(adis16240_init); - -static __exit void adis16240_exit(void) -{ - spi_unregister_driver(&adis16240_driver); -} -module_exit(adis16240_exit); +module_spi_driver(adis16240_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices Programmable Impact Sensor and Recorder"); diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c index 5238503..cfce21c 100644 --- a/drivers/staging/iio/accel/kxsd9.c +++ b/drivers/staging/iio/accel/kxsd9.c @@ -280,18 +280,7 @@ static struct spi_driver kxsd9_driver = { .remove = __devexit_p(kxsd9_remove), .id_table = kxsd9_id, }; - -static __init int kxsd9_spi_init(void) -{ - return spi_register_driver(&kxsd9_driver); -} -module_init(kxsd9_spi_init); - -static __exit void kxsd9_spi_exit(void) -{ - spi_unregister_driver(&kxsd9_driver); -} -module_exit(kxsd9_spi_exit); +module_spi_driver(kxsd9_driver); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("Kionix KXSD9 SPI driver"); diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 559545a..6877521 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -804,18 +804,7 @@ static struct spi_driver lis3l02dq_driver = { .probe = lis3l02dq_probe, .remove = __devexit_p(lis3l02dq_remove), }; - -static __init int lis3l02dq_init(void) -{ - return spi_register_driver(&lis3l02dq_driver); -} -module_init(lis3l02dq_init); - -static __exit void lis3l02dq_exit(void) -{ - spi_unregister_driver(&lis3l02dq_driver); -} -module_exit(lis3l02dq_exit); +module_spi_driver(lis3l02dq_driver); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("ST LIS3L02DQ Accelerometer SPI driver"); diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index a44a705..6c35907 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1250,18 +1250,7 @@ static struct spi_driver sca3000_driver = { .remove = __devexit_p(sca3000_remove), .id_table = sca3000_id, }; - -static __init int sca3000_init(void) -{ - return spi_register_driver(&sca3000_driver); -} -module_init(sca3000_init); - -static __exit void sca3000_exit(void) -{ - spi_unregister_driver(&sca3000_driver); -} -module_exit(sca3000_exit); +module_spi_driver(sca3000_driver); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("VTI SCA3000 Series Accelerometers SPI driver"); diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 31c376b..a6a4a4e 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -1161,18 +1161,7 @@ static struct spi_driver ad7192_driver = { .remove = __devexit_p(ad7192_remove), .id_table = ad7192_id, }; - -static int __init ad7192_init(void) -{ - return spi_register_driver(&ad7192_driver); -} -module_init(ad7192_init); - -static void __exit ad7192_exit(void) -{ - spi_unregister_driver(&ad7192_driver); -} -module_exit(ad7192_exit); +module_spi_driver(ad7192_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7190, AD7192, AD7195 ADC"); diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 372d059..dbaeae8 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -979,18 +979,7 @@ static struct spi_driver ad7280_driver = { .remove = __devexit_p(ad7280_remove), .id_table = ad7280_id, }; - -static int __init ad7280_init(void) -{ - return spi_register_driver(&ad7280_driver); -} -module_init(ad7280_init); - -static void __exit ad7280_exit(void) -{ - spi_unregister_driver(&ad7280_driver); -} -module_exit(ad7280_exit); +module_spi_driver(ad7280_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7280A"); diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index c1de73a..a799bd1 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c @@ -276,18 +276,7 @@ static struct spi_driver ad7298_driver = { .remove = __devexit_p(ad7298_remove), .id_table = ad7298_id, }; - -static int __init ad7298_init(void) -{ - return spi_register_driver(&ad7298_driver); -} -module_init(ad7298_init); - -static void __exit ad7298_exit(void) -{ - spi_unregister_driver(&ad7298_driver); -} -module_exit(ad7298_exit); +module_spi_driver(ad7298_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7298 ADC"); diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index fd79fac..0b58520 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c @@ -248,18 +248,7 @@ static struct spi_driver ad7476_driver = { .remove = __devexit_p(ad7476_remove), .id_table = ad7476_id, }; - -static int __init ad7476_init(void) -{ - return spi_register_driver(&ad7476_driver); -} -module_init(ad7476_init); - -static void __exit ad7476_exit(void) -{ - spi_unregister_driver(&ad7476_driver); -} -module_exit(ad7476_exit); +module_spi_driver(ad7476_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7475/6/7/8(A) AD7466/7/8 ADC"); diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c index aede1ba..b984bd2 100644 --- a/drivers/staging/iio/adc/ad7606_spi.c +++ b/drivers/staging/iio/adc/ad7606_spi.c @@ -109,18 +109,7 @@ static struct spi_driver ad7606_driver = { .remove = __devexit_p(ad7606_spi_remove), .id_table = ad7606_id, }; - -static int __init ad7606_spi_init(void) -{ - return spi_register_driver(&ad7606_driver); -} -module_init(ad7606_spi_init); - -static void __exit ad7606_spi_exit(void) -{ - spi_unregister_driver(&ad7606_driver); -} -module_exit(ad7606_spi_exit); +module_spi_driver(ad7606_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7606 ADC"); diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 7a579a1..ec90261 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -283,18 +283,7 @@ static struct spi_driver ad7780_driver = { .remove = __devexit_p(ad7780_remove), .id_table = ad7780_id, }; - -static int __init ad7780_init(void) -{ - return spi_register_driver(&ad7780_driver); -} -module_init(ad7780_init); - -static void __exit ad7780_exit(void) -{ - spi_unregister_driver(&ad7780_driver); -} -module_exit(ad7780_exit); +module_spi_driver(ad7780_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7780/1 ADC"); diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index 999f8f7..1c5588e 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -1045,18 +1045,7 @@ static struct spi_driver ad7793_driver = { .remove = __devexit_p(ad7793_remove), .id_table = ad7793_id, }; - -static int __init ad7793_init(void) -{ - return spi_register_driver(&ad7793_driver); -} -module_init(ad7793_init); - -static void __exit ad7793_exit(void) -{ - spi_unregister_driver(&ad7793_driver); -} -module_exit(ad7793_exit); +module_spi_driver(ad7793_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7792/3 ADC"); diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index bdb9049..acbf936 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -466,21 +466,9 @@ static struct spi_driver ad7816_driver = { .remove = __devexit_p(ad7816_remove), .id_table = ad7816_id, }; - -static __init int ad7816_init(void) -{ - return spi_register_driver(&ad7816_driver); -} - -static __exit void ad7816_exit(void) -{ - spi_unregister_driver(&ad7816_driver); -} +module_spi_driver(ad7816_driver); MODULE_AUTHOR("Sonic Zhang "); MODULE_DESCRIPTION("Analog Devices AD7816/7/8 digital" " temperature sensor driver"); MODULE_LICENSE("GPL v2"); - -module_init(ad7816_init); -module_exit(ad7816_exit); diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 609dcd5..91b8fb0 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c @@ -257,18 +257,7 @@ static struct spi_driver ad7887_driver = { .remove = __devexit_p(ad7887_remove), .id_table = ad7887_id, }; - -static int __init ad7887_init(void) -{ - return spi_register_driver(&ad7887_driver); -} -module_init(ad7887_init); - -static void __exit ad7887_exit(void) -{ - spi_unregister_driver(&ad7887_driver); -} -module_exit(ad7887_exit); +module_spi_driver(ad7887_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD7887 ADC"); diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index c9e0be3..bc307f3 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c @@ -884,21 +884,9 @@ static struct spi_driver adt7310_driver = { .remove = __devexit_p(adt7310_remove), .id_table = adt7310_id, }; - -static __init int adt7310_init(void) -{ - return spi_register_driver(&adt7310_driver); -} - -static __exit void adt7310_exit(void) -{ - spi_unregister_driver(&adt7310_driver); -} +module_spi_driver(adt7310_driver); MODULE_AUTHOR("Sonic Zhang "); MODULE_DESCRIPTION("Analog Devices ADT7310 digital" " temperature sensor driver"); MODULE_LICENSE("GPL v2"); - -module_init(adt7310_init); -module_exit(adt7310_exit); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 369d4d0..1e93c7b 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -160,21 +160,9 @@ static struct spi_driver adt7316_driver = { .resume = adt7316_spi_resume, .id_table = adt7316_spi_id, }; - -static __init int adt7316_spi_init(void) -{ - return spi_register_driver(&adt7316_driver); -} - -static __exit void adt7316_spi_exit(void) -{ - spi_unregister_driver(&adt7316_driver); -} +module_spi_driver(adt7316_driver); MODULE_AUTHOR("Sonic Zhang "); MODULE_DESCRIPTION("SPI bus driver for Analog Devices ADT7316/7/8 and" "ADT7516/7/9 digital temperature sensor, ADC and DAC"); MODULE_LICENSE("GPL v2"); - -module_init(adt7316_spi_init); -module_exit(adt7316_spi_exit); diff --git a/drivers/staging/iio/dac/ad5064.c b/drivers/staging/iio/dac/ad5064.c index 24279f2..39cfe6c 100644 --- a/drivers/staging/iio/dac/ad5064.c +++ b/drivers/staging/iio/dac/ad5064.c @@ -445,18 +445,7 @@ static struct spi_driver ad5064_driver = { .remove = __devexit_p(ad5064_remove), .id_table = ad5064_id, }; - -static __init int ad5064_spi_init(void) -{ - return spi_register_driver(&ad5064_driver); -} -module_init(ad5064_spi_init); - -static __exit void ad5064_spi_exit(void) -{ - spi_unregister_driver(&ad5064_driver); -} -module_exit(ad5064_spi_exit); +module_spi_driver(ad5064_driver); MODULE_AUTHOR("Lars-Peter Clausen "); MODULE_DESCRIPTION("Analog Devices AD5064/64-1/44/24 DAC"); diff --git a/drivers/staging/iio/dac/ad5360.c b/drivers/staging/iio/dac/ad5360.c index 72d0f3f..bc0459e 100644 --- a/drivers/staging/iio/dac/ad5360.c +++ b/drivers/staging/iio/dac/ad5360.c @@ -563,18 +563,7 @@ static struct spi_driver ad5360_driver = { .remove = __devexit_p(ad5360_remove), .id_table = ad5360_ids, }; - -static __init int ad5360_spi_init(void) -{ - return spi_register_driver(&ad5360_driver); -} -module_init(ad5360_spi_init); - -static __exit void ad5360_spi_exit(void) -{ - spi_unregister_driver(&ad5360_driver); -} -module_exit(ad5360_spi_exit); +module_spi_driver(ad5360_driver); MODULE_AUTHOR("Lars-Peter Clausen "); MODULE_DESCRIPTION("Analog Devices AD5360/61/62/63/70/71/72/73 DAC"); diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index e1c204d..ac3bc5f5 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c @@ -465,18 +465,7 @@ static struct spi_driver ad5446_driver = { .remove = __devexit_p(ad5446_remove), .id_table = ad5446_id, }; - -static int __init ad5446_init(void) -{ - return spi_register_driver(&ad5446_driver); -} -module_init(ad5446_init); - -static void __exit ad5446_exit(void) -{ - spi_unregister_driver(&ad5446_driver); -} -module_exit(ad5446_exit); +module_spi_driver(ad5446_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD5444/AD5446 DAC"); diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 60dd640..57539ce 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c @@ -377,18 +377,7 @@ static struct spi_driver ad5504_driver = { .remove = __devexit_p(ad5504_remove), .id_table = ad5504_id, }; - -static __init int ad5504_spi_init(void) -{ - return spi_register_driver(&ad5504_driver); -} -module_init(ad5504_spi_init); - -static __exit void ad5504_spi_exit(void) -{ - spi_unregister_driver(&ad5504_driver); -} -module_exit(ad5504_spi_exit); +module_spi_driver(ad5504_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD5501/AD5501 DAC"); diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index 284d8790..6e05f0d 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c @@ -317,18 +317,7 @@ static struct spi_driver ad5624r_driver = { .remove = __devexit_p(ad5624r_remove), .id_table = ad5624r_id, }; - -static __init int ad5624r_spi_init(void) -{ - return spi_register_driver(&ad5624r_driver); -} -module_init(ad5624r_spi_init); - -static __exit void ad5624r_spi_exit(void) -{ - spi_unregister_driver(&ad5624r_driver); -} -module_exit(ad5624r_spi_exit); +module_spi_driver(ad5624r_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices AD5624/44/64R DAC spi driver"); diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index 974c6f5..e72db2f 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -447,18 +447,7 @@ static struct spi_driver ad5686_driver = { .remove = __devexit_p(ad5686_remove), .id_table = ad5686_id, }; - -static __init int ad5686_spi_init(void) -{ - return spi_register_driver(&ad5686_driver); -} -module_init(ad5686_spi_init); - -static __exit void ad5686_spi_exit(void) -{ - spi_unregister_driver(&ad5686_driver); -} -module_exit(ad5686_spi_exit); +module_spi_driver(ad5686_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD5686/85/84 DAC"); diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index 6fbca8d..4a80fd8 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c @@ -410,18 +410,7 @@ static struct spi_driver ad5791_driver = { .remove = __devexit_p(ad5791_remove), .id_table = ad5791_id, }; - -static __init int ad5791_spi_init(void) -{ - return spi_register_driver(&ad5791_driver); -} -module_init(ad5791_spi_init); - -static __exit void ad5791_spi_exit(void) -{ - spi_unregister_driver(&ad5791_driver); -} -module_exit(ad5791_spi_exit); +module_spi_driver(ad5791_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD5760/AD5780/AD5781/AD5791 DAC"); diff --git a/drivers/staging/iio/dds/ad5930.c b/drivers/staging/iio/dds/ad5930.c index f5e368b..4a360d0 100644 --- a/drivers/staging/iio/dds/ad5930.c +++ b/drivers/staging/iio/dds/ad5930.c @@ -143,18 +143,7 @@ static struct spi_driver ad5930_driver = { .probe = ad5930_probe, .remove = __devexit_p(ad5930_remove), }; - -static __init int ad5930_spi_init(void) -{ - return spi_register_driver(&ad5930_driver); -} -module_init(ad5930_spi_init); - -static __exit void ad5930_spi_exit(void) -{ - spi_unregister_driver(&ad5930_driver); -} -module_exit(ad5930_spi_exit); +module_spi_driver(ad5930_driver); MODULE_AUTHOR("Cliff Cai"); MODULE_DESCRIPTION("Analog Devices ad5930 driver"); diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/dds/ad9832.c index 9b4ff60..cc32fd6 100644 --- a/drivers/staging/iio/dds/ad9832.c +++ b/drivers/staging/iio/dds/ad9832.c @@ -355,18 +355,7 @@ static struct spi_driver ad9832_driver = { .remove = __devexit_p(ad9832_remove), .id_table = ad9832_id, }; - -static int __init ad9832_init(void) -{ - return spi_register_driver(&ad9832_driver); -} -module_init(ad9832_init); - -static void __exit ad9832_exit(void) -{ - spi_unregister_driver(&ad9832_driver); -} -module_exit(ad9832_exit); +module_spi_driver(ad9832_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD9832/AD9835 DDS"); diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index c468f69..2b31e35 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c @@ -446,18 +446,7 @@ static struct spi_driver ad9834_driver = { .remove = __devexit_p(ad9834_remove), .id_table = ad9834_id, }; - -static int __init ad9834_init(void) -{ - return spi_register_driver(&ad9834_driver); -} -module_init(ad9834_init); - -static void __exit ad9834_exit(void) -{ - spi_unregister_driver(&ad9834_driver); -} -module_exit(ad9834_exit); +module_spi_driver(ad9834_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD9833/AD9834/AD9837/AD9838 DDS"); diff --git a/drivers/staging/iio/dds/ad9850.c b/drivers/staging/iio/dds/ad9850.c index a14771b..f9c96af 100644 --- a/drivers/staging/iio/dds/ad9850.c +++ b/drivers/staging/iio/dds/ad9850.c @@ -129,18 +129,7 @@ static struct spi_driver ad9850_driver = { .probe = ad9850_probe, .remove = __devexit_p(ad9850_remove), }; - -static __init int ad9850_spi_init(void) -{ - return spi_register_driver(&ad9850_driver); -} -module_init(ad9850_spi_init); - -static __exit void ad9850_spi_exit(void) -{ - spi_unregister_driver(&ad9850_driver); -} -module_exit(ad9850_spi_exit); +module_spi_driver(ad9850_driver); MODULE_AUTHOR("Cliff Cai"); MODULE_DESCRIPTION("Analog Devices ad9850 driver"); diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/dds/ad9852.c index cfceaa6..9fc73fd 100644 --- a/drivers/staging/iio/dds/ad9852.c +++ b/drivers/staging/iio/dds/ad9852.c @@ -280,18 +280,7 @@ static struct spi_driver ad9852_driver = { .probe = ad9852_probe, .remove = __devexit_p(ad9852_remove), }; - -static __init int ad9852_spi_init(void) -{ - return spi_register_driver(&ad9852_driver); -} -module_init(ad9852_spi_init); - -static __exit void ad9852_spi_exit(void) -{ - spi_unregister_driver(&ad9852_driver); -} -module_exit(ad9852_spi_exit); +module_spi_driver(ad9852_driver); MODULE_AUTHOR("Cliff Cai"); MODULE_DESCRIPTION("Analog Devices ad9852 driver"); diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/dds/ad9910.c index da83d2b..57046b0 100644 --- a/drivers/staging/iio/dds/ad9910.c +++ b/drivers/staging/iio/dds/ad9910.c @@ -413,18 +413,7 @@ static struct spi_driver ad9910_driver = { .probe = ad9910_probe, .remove = __devexit_p(ad9910_remove), }; - -static __init int ad9910_spi_init(void) -{ - return spi_register_driver(&ad9910_driver); -} -module_init(ad9910_spi_init); - -static __exit void ad9910_spi_exit(void) -{ - spi_unregister_driver(&ad9910_driver); -} -module_exit(ad9910_spi_exit); +module_spi_driver(ad9910_driver); MODULE_AUTHOR("Cliff Cai"); MODULE_DESCRIPTION("Analog Devices ad9910 driver"); diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/dds/ad9951.c index 20c1825..d29130e 100644 --- a/drivers/staging/iio/dds/ad9951.c +++ b/drivers/staging/iio/dds/ad9951.c @@ -224,18 +224,7 @@ static struct spi_driver ad9951_driver = { .probe = ad9951_probe, .remove = __devexit_p(ad9951_remove), }; - -static __init int ad9951_spi_init(void) -{ - return spi_register_driver(&ad9951_driver); -} -module_init(ad9951_spi_init); - -static __exit void ad9951_spi_exit(void) -{ - spi_unregister_driver(&ad9951_driver); -} -module_exit(ad9951_spi_exit); +module_spi_driver(ad9951_driver); MODULE_AUTHOR("Cliff Cai"); MODULE_DESCRIPTION("Analog Devices ad9951 driver"); diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index 5d7a906..9405f2d 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c @@ -189,18 +189,7 @@ static struct spi_driver adis16080_driver = { .probe = adis16080_probe, .remove = __devexit_p(adis16080_remove), }; - -static __init int adis16080_init(void) -{ - return spi_register_driver(&adis16080_driver); -} -module_init(adis16080_init); - -static __exit void adis16080_exit(void) -{ - spi_unregister_driver(&adis16080_driver); -} -module_exit(adis16080_exit); +module_spi_driver(adis16080_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16080/100 Yaw Rate Gyroscope Driver"); diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index 749240d..c9aaca9 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c @@ -168,18 +168,7 @@ static struct spi_driver adis16130_driver = { .probe = adis16130_probe, .remove = __devexit_p(adis16130_remove), }; - -static __init int adis16130_init(void) -{ - return spi_register_driver(&adis16130_driver); -} -module_init(adis16130_init); - -static __exit void adis16130_exit(void) -{ - spi_unregister_driver(&adis16130_driver); -} -module_exit(adis16130_exit); +module_spi_driver(adis16130_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16130 High Precision Angular Rate"); diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index aaa3967..886dddf 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -711,18 +711,7 @@ static struct spi_driver adis16260_driver = { .remove = __devexit_p(adis16260_remove), .id_table = adis16260_id, }; - -static __init int adis16260_init(void) -{ - return spi_register_driver(&adis16260_driver); -} -module_init(adis16260_init); - -static __exit void adis16260_exit(void) -{ - spi_unregister_driver(&adis16260_driver); -} -module_exit(adis16260_exit); +module_spi_driver(adis16260_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADIS16260/5 Digital Gyroscope Sensor"); diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 3c3ef79..70fd468 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -381,18 +381,7 @@ static struct spi_driver adxrs450_driver = { .probe = adxrs450_probe, .remove = __devexit_p(adxrs450_remove), }; - -static __init int adxrs450_init(void) -{ - return spi_register_driver(&adxrs450_driver); -} -module_init(adxrs450_init); - -static __exit void adxrs450_exit(void) -{ - spi_unregister_driver(&adxrs450_driver); -} -module_exit(adxrs450_exit); +module_spi_driver(adxrs450_driver); MODULE_AUTHOR("Cliff Cai "); MODULE_DESCRIPTION("Analog Devices ADXRS450 Gyroscope SPI driver"); diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index d082a37..efc0f65 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -1128,18 +1128,7 @@ static struct spi_driver adis16400_driver = { .probe = adis16400_probe, .remove = __devexit_p(adis16400_remove), }; - -static __init int adis16400_init(void) -{ - return spi_register_driver(&adis16400_driver); -} -module_init(adis16400_init); - -static __exit void adis16400_exit(void) -{ - spi_unregister_driver(&adis16400_driver); -} -module_exit(adis16400_exit); +module_spi_driver(adis16400_driver); MODULE_AUTHOR("Manuel Stahl "); MODULE_DESCRIPTION("Analog Devices ADIS16400/5 IMU SPI driver"); diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 940fef6..4c7b0cb 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -577,18 +577,7 @@ static struct spi_driver ade7753_driver = { .probe = ade7753_probe, .remove = __devexit_p(ade7753_remove), }; - -static __init int ade7753_init(void) -{ - return spi_register_driver(&ade7753_driver); -} -module_init(ade7753_init); - -static __exit void ade7753_exit(void) -{ - spi_unregister_driver(&ade7753_driver); -} -module_exit(ade7753_exit); +module_spi_driver(ade7753_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADE7753/6 Single-Phase Multifunction Meter"); diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 33f0d32..15c98cd 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -600,18 +600,7 @@ static struct spi_driver ade7754_driver = { .probe = ade7754_probe, .remove = __devexit_p(ade7754_remove), }; - -static __init int ade7754_init(void) -{ - return spi_register_driver(&ade7754_driver); -} -module_init(ade7754_init); - -static __exit void ade7754_exit(void) -{ - spi_unregister_driver(&ade7754_driver); -} -module_exit(ade7754_exit); +module_spi_driver(ade7754_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADE7754 Polyphase Multifunction Energy Metering IC Driver"); diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index c5dafbd..39338bc 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -853,18 +853,7 @@ static struct spi_driver ade7758_driver = { .remove = __devexit_p(ade7758_remove), .id_table = ade7758_id, }; - -static __init int ade7758_init(void) -{ - return spi_register_driver(&ade7758_driver); -} -module_init(ade7758_init); - -static __exit void ade7758_exit(void) -{ - spi_unregister_driver(&ade7758_driver); -} -module_exit(ade7758_exit); +module_spi_driver(ade7758_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADE7758 Polyphase Multifunction Energy Metering IC Driver"); diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index b691f10..cfa2a5e 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -521,18 +521,7 @@ static struct spi_driver ade7759_driver = { .probe = ade7759_probe, .remove = __devexit_p(ade7759_remove), }; - -static __init int ade7759_init(void) -{ - return spi_register_driver(&ade7759_driver); -} -module_init(ade7759_init); - -static __exit void ade7759_exit(void) -{ - spi_unregister_driver(&ade7759_driver); -} -module_exit(ade7759_exit); +module_spi_driver(ade7759_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADE7759 Active Energy Metering IC Driver"); diff --git a/drivers/staging/iio/meter/ade7854-spi.c b/drivers/staging/iio/meter/ade7854-spi.c index cfa23ba..c485a79 100644 --- a/drivers/staging/iio/meter/ade7854-spi.c +++ b/drivers/staging/iio/meter/ade7854-spi.c @@ -353,18 +353,7 @@ static struct spi_driver ade7854_driver = { .remove = __devexit_p(ade7854_spi_remove), .id_table = ade7854_id, }; - -static __init int ade7854_init(void) -{ - return spi_register_driver(&ade7854_driver); -} -module_init(ade7854_init); - -static __exit void ade7854_exit(void) -{ - spi_unregister_driver(&ade7854_driver); -} -module_exit(ade7854_exit); +module_spi_driver(ade7854_driver); MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); MODULE_DESCRIPTION("Analog Devices ADE7854/58/68/78 SPI Driver"); diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index d7ad46a..1c6a02b 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -170,18 +170,7 @@ static struct spi_driver ad2s1200_driver = { .remove = __devexit_p(ad2s1200_remove), .id_table = ad2s1200_id, }; - -static __init int ad2s1200_spi_init(void) -{ - return spi_register_driver(&ad2s1200_driver); -} -module_init(ad2s1200_spi_init); - -static __exit void ad2s1200_spi_exit(void) -{ - spi_unregister_driver(&ad2s1200_driver); -} -module_exit(ad2s1200_spi_exit); +module_spi_driver(ad2s1200_driver); MODULE_AUTHOR("Graff Yang "); MODULE_DESCRIPTION("Analog Devices AD2S1200/1205 Resolver to Digital SPI driver"); diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 6401a62..ff1b331 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -759,18 +759,7 @@ static struct spi_driver ad2s1210_driver = { .remove = __devexit_p(ad2s1210_remove), .id_table = ad2s1210_id, }; - -static __init int ad2s1210_spi_init(void) -{ - return spi_register_driver(&ad2s1210_driver); -} -module_init(ad2s1210_spi_init); - -static __exit void ad2s1210_spi_exit(void) -{ - spi_unregister_driver(&ad2s1210_driver); -} -module_exit(ad2s1210_spi_exit); +module_spi_driver(ad2s1210_driver); MODULE_AUTHOR("Graff Yang "); MODULE_DESCRIPTION("Analog Devices AD2S1210 Resolver to Digital SPI driver"); diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index a9200d9..6d07943 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -119,18 +119,7 @@ static struct spi_driver ad2s90_driver = { .remove = __devexit_p(ad2s90_remove), .id_table = ad2s90_id, }; - -static __init int ad2s90_spi_init(void) -{ - return spi_register_driver(&ad2s90_driver); -} -module_init(ad2s90_spi_init); - -static __exit void ad2s90_spi_exit(void) -{ - spi_unregister_driver(&ad2s90_driver); -} -module_exit(ad2s90_spi_exit); +module_spi_driver(ad2s90_driver); MODULE_AUTHOR("Graff Yang "); MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI driver"); -- cgit v0.10.2 From f3a6a4b6cfc80e57bf16bb12f9425bec1a5731a9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 17 Nov 2011 14:38:33 -0800 Subject: USB: Add helper macro for usb_driver boilerplate This patch introduces the module_usb_driver macro which is a convenience macro for USB driver modules similar to module_platform_driver. It is intended to be used by drivers which init/exit section does nothing but register/unregister the USB driver. By using this macro it is possible to eliminate a few lines of boilerplate code per USB driver. Based on work done by Lars-Peter Clausen for other busses (i2c and spi). Cc: Lars-Peter Clausen Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/usb.h b/include/linux/usb.h index d3d0c13..5d258c3 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -953,6 +953,18 @@ extern int usb_register_driver(struct usb_driver *, struct module *, extern void usb_deregister(struct usb_driver *); +/** + * module_usb_driver() - Helper macro for registering a USB driver + * @__usb_driver: usb_driver struct + * + * Helper macro for USB drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_usb_driver(__usb_driver) \ + module_driver(__usb_driver, usb_register, \ + usb_deregister) + extern int usb_register_device_driver(struct usb_device_driver *, struct module *); extern void usb_deregister_device_driver(struct usb_device_driver *); -- cgit v0.10.2 From 65db43054065790a75291b0834657445fea2cf56 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:34:02 -0800 Subject: USB: convert drivers/usb/* to use module_usb_driver() This converts the drivers in drivers/usb/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Simon Arlott Cc: Duncan Sands Cc: Matthieu CASTET Cc: Stanislaw Gruszka Cc: Pete Zaitcev Cc: Oliver Neukum Cc: Juergen Stuber Cc: Cesar Miquel Cc: Matthew Dharm Cc: Matthew Wilcox Cc: Sarah Sharp Cc: Kuninori Morimoto Cc: Felipe Balbi Cc: Lucas De Marchi Cc: Michael Hund Cc: Zack Parsons Cc: Melchior FRANZ Cc: Tomoki Sekiyama Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index a845f8b..98b89fe 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -1372,18 +1372,7 @@ static struct usb_driver cxacru_usb_driver = { .id_table = cxacru_usb_ids }; -static int __init cxacru_init(void) -{ - return usb_register(&cxacru_usb_driver); -} - -static void __exit cxacru_cleanup(void) -{ - usb_deregister(&cxacru_usb_driver); -} - -module_init(cxacru_init); -module_exit(cxacru_cleanup); +module_usb_driver(cxacru_usb_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index 0842cfb..b42092e 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c @@ -953,22 +953,7 @@ static int speedtch_usb_probe(struct usb_interface *intf, const struct usb_devic return usbatm_usb_probe(intf, id, &speedtch_usbatm_driver); } -static int __init speedtch_usb_init(void) -{ - dbg("%s: driver version %s", __func__, DRIVER_VERSION); - - return usb_register(&speedtch_usb_driver); -} - -static void __exit speedtch_usb_cleanup(void) -{ - dbg("%s", __func__); - - usb_deregister(&speedtch_usb_driver); -} - -module_init(speedtch_usb_init); -module_exit(speedtch_usb_cleanup); +module_usb_driver(speedtch_usb_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 428f368..00f171a 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -2753,36 +2753,7 @@ static struct usb_driver uea_driver = { MODULE_DEVICE_TABLE(usb, uea_ids); -/** - * uea_init - Initialize the module. - * Register to USB subsystem - */ -static int __init uea_init(void) -{ - printk(KERN_INFO "[ueagle-atm] driver " EAGLEUSBVERSION " loaded\n"); - - usb_register(&uea_driver); - - return 0; -} - -module_init(uea_init); - -/** - * uea_exit - Destroy module - * Deregister with USB subsystem - */ -static void __exit uea_exit(void) -{ - /* - * This calls automatically the uea_disconnect method if necessary: - */ - usb_deregister(&uea_driver); - - printk(KERN_INFO "[ueagle-atm] driver unloaded\n"); -} - -module_exit(uea_exit); +module_usb_driver(uea_driver); MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index efe6849..1c50baf 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -895,24 +895,7 @@ static struct usb_driver wdm_driver = { .supports_autosuspend = 1, }; -/* --- low level module stuff --- */ - -static int __init wdm_init(void) -{ - int rv; - - rv = usb_register(&wdm_driver); - - return rv; -} - -static void __exit wdm_exit(void) -{ - usb_deregister(&wdm_driver); -} - -module_init(wdm_init); -module_exit(wdm_exit); +module_usb_driver(wdm_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index cb3a932..81ef2e2 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -1412,18 +1412,7 @@ static struct usb_driver usblp_driver = { .supports_autosuspend = 1, }; -static int __init usblp_init(void) -{ - return usb_register(&usblp_driver); -} - -static void __exit usblp_exit(void) -{ - usb_deregister(&usblp_driver); -} - -module_init(usblp_init); -module_exit(usblp_exit); +module_usb_driver(usblp_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 12cf5e7..70d69d0 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -1116,21 +1116,6 @@ static struct usb_driver usbtmc_driver = { .resume = usbtmc_resume, }; -static int __init usbtmc_init(void) -{ - int retcode; - - retcode = usb_register(&usbtmc_driver); - if (retcode) - printk(KERN_ERR KBUILD_MODNAME": Unable to register driver\n"); - return retcode; -} -module_init(usbtmc_init); - -static void __exit usbtmc_exit(void) -{ - usb_deregister(&usbtmc_driver); -} -module_exit(usbtmc_exit); +module_usb_driver(usbtmc_driver); MODULE_LICENSE("GPL"); diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c index 9bfac65..056fb2d 100644 --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c @@ -837,18 +837,7 @@ static struct usb_driver hwahc_driver = { .id_table = hwahc_id_table, }; -static int __init hwahc_driver_init(void) -{ - return usb_register(&hwahc_driver); -} -module_init(hwahc_driver_init); - -static void __exit hwahc_driver_exit(void) -{ - usb_deregister(&hwahc_driver); -} -module_exit(hwahc_driver_exit); - +module_usb_driver(hwahc_driver); MODULE_AUTHOR("Inaky Perez-Gonzalez "); MODULE_DESCRIPTION("Host Wired Adapter USB Host Control Driver"); diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 27e209a..9c0f8ca 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -809,19 +809,7 @@ static void mts_usb_disconnect (struct usb_interface *intf) kfree(desc); } - -static int __init microtek_drv_init(void) -{ - return usb_register(&mts_usb_driver); -} - -static void __exit microtek_drv_exit(void) -{ - usb_deregister(&mts_usb_driver); -} - -module_init(microtek_drv_init); -module_exit(microtek_drv_exit); +module_usb_driver(mts_usb_driver); MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_DESCRIPTION( DRIVER_DESC ); diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c index fe85871..284b854 100644 --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -885,40 +885,7 @@ static struct usb_driver adu_driver = { .id_table = device_table, }; -static int __init adu_init(void) -{ - int result; - - dbg(2," %s : enter", __func__); - - /* register this driver with the USB subsystem */ - result = usb_register(&adu_driver); - if (result < 0) { - printk(KERN_ERR "usb_register failed for the "__FILE__ - " driver. Error number %d\n", result); - goto exit; - } - - printk(KERN_INFO "adutux " DRIVER_DESC " " DRIVER_VERSION "\n"); - printk(KERN_INFO "adutux is an experimental driver. " - "Use at your own risk\n"); - -exit: - dbg(2," %s : leave, return value %d", __func__, result); - - return result; -} - -static void __exit adu_exit(void) -{ - dbg(2," %s : enter", __func__); - /* deregister this driver with the USB subsystem */ - usb_deregister(&adu_driver); - dbg(2," %s : leave", __func__); -} - -module_init(adu_init); -module_exit(adu_exit); +module_usb_driver(adu_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 9251773..3f7c1a9 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c @@ -271,27 +271,7 @@ static struct usb_driver cypress_driver = { .id_table = cypress_table, }; -static int __init cypress_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&cypress_driver); - if (result) - printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " - "Error number: %d\n", result); - - return result; -} - -static void __exit cypress_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&cypress_driver); -} - -module_init(cypress_init); -module_exit(cypress_exit); +module_usb_driver(cypress_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 1d7251b..5b9831b 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c @@ -417,31 +417,7 @@ static void cytherm_disconnect(struct usb_interface *interface) dev_info(&interface->dev, "Cypress thermometer now disconnected\n"); } - -static int __init usb_cytherm_init(void) -{ - int result; - - result = usb_register(&cytherm_driver); - if (result) { - printk(KERN_ERR KBUILD_MODNAME ": usb_register failed! " - "Error number: %d\n", result); - return result; - } - - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return 0; -} - -static void __exit usb_cytherm_exit(void) -{ - usb_deregister(&cytherm_driver); -} - - -module_init (usb_cytherm_init); -module_exit (usb_cytherm_exit); +module_usb_driver(cytherm_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index a6521c95..d9b6a03 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c @@ -276,18 +276,7 @@ static struct usb_driver emi26_driver = { .id_table = id_table, }; -static int __init emi26_init (void) -{ - return usb_register(&emi26_driver); -} - -static void __exit emi26_exit (void) -{ - usb_deregister (&emi26_driver); -} - -module_init(emi26_init); -module_exit(emi26_exit); +module_usb_driver(emi26_driver); MODULE_AUTHOR("Tapio Laxström"); MODULE_DESCRIPTION("Emagic EMI 2|6 firmware loader."); diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index fc15ad4..9f39062 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -290,22 +290,7 @@ static struct usb_driver emi62_driver = { .id_table = id_table, }; -static int __init emi62_init (void) -{ - int retval; - retval = usb_register (&emi62_driver); - if (retval) - printk(KERN_ERR "adi-emi: registration failed\n"); - return retval; -} - -static void __exit emi62_exit (void) -{ - usb_deregister (&emi62_driver); -} - -module_init(emi62_init); -module_exit(emi62_exit); +module_usb_driver(emi62_driver); MODULE_AUTHOR("Tapio Laxström"); MODULE_DESCRIPTION("Emagic EMI 6|2m firmware loader."); diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 515b67f..0dee246 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -428,29 +428,7 @@ static void idmouse_disconnect(struct usb_interface *interface) dev_info(&interface->dev, "disconnected\n"); } -static int __init usb_idmouse_init(void) -{ - int result; - - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - - /* register this driver with the USB subsystem */ - result = usb_register(&idmouse_driver); - if (result) - err("Unable to register device (error %d).", result); - - return result; -} - -static void __exit usb_idmouse_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&idmouse_driver); -} - -module_init(usb_idmouse_init); -module_exit(usb_idmouse_exit); +module_usb_driver(idmouse_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 8145790..7676b5b 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -927,15 +927,4 @@ static struct usb_driver iowarrior_driver = { .id_table = iowarrior_ids, }; -static int __init iowarrior_init(void) -{ - return usb_register(&iowarrior_driver); -} - -static void __exit iowarrior_exit(void) -{ - usb_deregister(&iowarrior_driver); -} - -module_init(iowarrior_init); -module_exit(iowarrior_exit); +module_usb_driver(iowarrior_driver); diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c index fe1d443..1dc7e95 100644 --- a/drivers/usb/misc/isight_firmware.c +++ b/drivers/usb/misc/isight_firmware.c @@ -126,18 +126,7 @@ static struct usb_driver isight_firmware_driver = { .id_table = id_table, }; -static int __init isight_firmware_init(void) -{ - return usb_register(&isight_firmware_driver); -} - -static void __exit isight_firmware_exit(void) -{ - usb_deregister(&isight_firmware_driver); -} - -module_init(isight_firmware_init); -module_exit(isight_firmware_exit); +module_usb_driver(isight_firmware_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Matthew Garrett "); diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 48c166f..5db4ab5 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -821,30 +821,5 @@ static struct usb_driver ld_usb_driver = { .id_table = ld_usb_table, }; -/** - * ld_usb_init - */ -static int __init ld_usb_init(void) -{ - int retval; - - /* register this driver with the USB subsystem */ - retval = usb_register(&ld_usb_driver); - if (retval) - err("usb_register failed for the %s driver. Error number %d\n", __FILE__, retval); - - return retval; -} - -/** - * ld_usb_exit - */ -static void __exit ld_usb_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&ld_usb_driver); -} - -module_init(ld_usb_init); -module_exit(ld_usb_exit); +module_usb_driver(ld_usb_driver); diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index a989356..16937da 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -1043,51 +1043,7 @@ static void tower_disconnect (struct usb_interface *interface) dbg(2, "%s: leave", __func__); } - - -/** - * lego_usb_tower_init - */ -static int __init lego_usb_tower_init(void) -{ - int result; - int retval = 0; - - dbg(2, "%s: enter", __func__); - - /* register this driver with the USB subsystem */ - result = usb_register(&tower_driver); - if (result < 0) { - err("usb_register failed for the %s driver. Error number %d", __FILE__, result); - retval = -1; - goto exit; - } - - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - -exit: - dbg(2, "%s: leave, return value %d", __func__, retval); - - return retval; -} - - -/** - * lego_usb_tower_exit - */ -static void __exit lego_usb_tower_exit(void) -{ - dbg(2, "%s: enter", __func__); - - /* deregister this driver with the USB subsystem */ - usb_deregister (&tower_driver); - - dbg(2, "%s: leave", __func__); -} - -module_init (lego_usb_tower_init); -module_exit (lego_usb_tower_exit); +module_usb_driver(tower_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 4e23d38..487a8ce 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c @@ -531,33 +531,7 @@ static struct usb_driver rio_driver = { .id_table = rio_table, }; -static int __init usb_rio_init(void) -{ - int retval; - retval = usb_register(&rio_driver); - if (retval) - goto out; - - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - -out: - return retval; -} - - -static void __exit usb_rio_cleanup(void) -{ - struct rio_usb_data *rio = &rio_instance; - - rio->present = 0; - usb_deregister(&rio_driver); - - -} - -module_init(usb_rio_init); -module_exit(usb_rio_cleanup); +module_usb_driver(rio_driver); MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_DESCRIPTION( DRIVER_DESC ); diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index f63776a..741efed 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c @@ -137,26 +137,7 @@ static struct usb_driver tv_driver = { .id_table = id_table, }; -static int __init tv_init(void) -{ - int retval = usb_register(&tv_driver); - if (retval) { - err("usb_register failed. Error number %d", retval); - return retval; - } - - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return 0; -} - -static void __exit tv_exit(void) -{ - usb_deregister(&tv_driver); -} - -module_init (tv_init); -module_exit (tv_exit); +module_usb_driver(tv_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 1871cdf..e2b4bd3 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c @@ -450,25 +450,7 @@ static struct usb_driver lcd_driver = { .supports_autosuspend = 1, }; -static int __init usb_lcd_init(void) -{ - int result; - - result = usb_register(&lcd_driver); - if (result) - err("usb_register failed. Error number %d", result); - - return result; -} - - -static void __exit usb_lcd_exit(void) -{ - usb_deregister(&lcd_driver); -} - -module_init(usb_lcd_init); -module_exit(usb_lcd_exit); +module_usb_driver(lcd_driver); MODULE_AUTHOR("Georges Toth "); MODULE_DESCRIPTION(DRIVER_VERSION); diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 43f84e5..4af56fb 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c @@ -231,23 +231,7 @@ static struct usb_driver led_driver = { .id_table = id_table, }; -static int __init usb_led_init(void) -{ - int retval = 0; - - retval = usb_register(&led_driver); - if (retval) - err("usb_register failed. Error number %d", retval); - return retval; -} - -static void __exit usb_led_exit(void) -{ - usb_deregister(&led_driver); -} - -module_init(usb_led_init); -module_exit(usb_led_exit); +module_usb_driver(led_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 417b8f2..107bf13 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c @@ -437,23 +437,7 @@ static struct usb_driver sevseg_driver = { .supports_autosuspend = 1, }; -static int __init usb_sevseg_init(void) -{ - int rc = 0; - - rc = usb_register(&sevseg_driver); - if (rc) - err("usb_register failed. Error number %d", rc); - return rc; -} - -static void __exit usb_sevseg_exit(void) -{ - usb_deregister(&sevseg_driver); -} - -module_init(usb_sevseg_init); -module_exit(usb_sevseg_exit); +module_usb_driver(sevseg_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c index ac5bfd6..897edda 100644 --- a/drivers/usb/misc/yurex.c +++ b/drivers/usb/misc/yurex.c @@ -539,26 +539,6 @@ static const struct file_operations yurex_fops = { .llseek = default_llseek, }; - -static int __init usb_yurex_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&yurex_driver); - if (result) - err("usb_register failed. Error number %d", result); - - return result; -} - -static void __exit usb_yurex_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&yurex_driver); -} - -module_init(usb_yurex_init); -module_exit(usb_yurex_exit); +module_usb_driver(yurex_driver); MODULE_LICENSE("GPL"); diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 42d0eae..3ca87a8 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c @@ -1278,15 +1278,4 @@ static struct usb_driver alauda_driver = { .soft_unbind = 1, }; -static int __init alauda_init(void) -{ - return usb_register(&alauda_driver); -} - -static void __exit alauda_exit(void) -{ - usb_deregister(&alauda_driver); -} - -module_init(alauda_init); -module_exit(alauda_exit); +module_usb_driver(alauda_driver); diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index c844718..c7909df 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c @@ -274,15 +274,4 @@ static struct usb_driver cypress_driver = { .soft_unbind = 1, }; -static int __init cypress_init(void) -{ - return usb_register(&cypress_driver); -} - -static void __exit cypress_exit(void) -{ - usb_deregister(&cypress_driver); -} - -module_init(cypress_init); -module_exit(cypress_exit); +module_usb_driver(cypress_driver); diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index ded836b..a99be85 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c @@ -753,15 +753,4 @@ static struct usb_driver datafab_driver = { .soft_unbind = 1, }; -static int __init datafab_init(void) -{ - return usb_register(&datafab_driver); -} - -static void __exit datafab_exit(void) -{ - usb_deregister(&datafab_driver); -} - -module_init(datafab_init); -module_exit(datafab_exit); +module_usb_driver(datafab_driver); diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index 4dca3ef..5929f49 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c @@ -2410,15 +2410,4 @@ static struct usb_driver ene_ub6250_driver = { .soft_unbind = 1, }; -static int __init ene_ub6250_init(void) -{ - return usb_register(&ene_ub6250_driver); -} - -static void __exit ene_ub6250_exit(void) -{ - usb_deregister(&ene_ub6250_driver); -} - -module_init(ene_ub6250_init); -module_exit(ene_ub6250_exit); +module_usb_driver(ene_ub6250_driver); diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index 6542ca4..03d4a87 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c @@ -555,15 +555,4 @@ static struct usb_driver freecom_driver = { .soft_unbind = 1, }; -static int __init freecom_init(void) -{ - return usb_register(&freecom_driver); -} - -static void __exit freecom_exit(void) -{ - usb_deregister(&freecom_driver); -} - -module_init(freecom_init); -module_exit(freecom_exit); +module_usb_driver(freecom_driver); diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index ffc4193..6d69233 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c @@ -1568,15 +1568,4 @@ static struct usb_driver isd200_driver = { .soft_unbind = 1, }; -static int __init isd200_init(void) -{ - return usb_register(&isd200_driver); -} - -static void __exit isd200_exit(void) -{ - usb_deregister(&isd200_driver); -} - -module_init(isd200_init); -module_exit(isd200_exit); +module_usb_driver(isd200_driver); diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index 6168596..54b7165 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c @@ -679,15 +679,4 @@ static struct usb_driver jumpshot_driver = { .soft_unbind = 1, }; -static int __init jumpshot_init(void) -{ - return usb_register(&jumpshot_driver); -} - -static void __exit jumpshot_exit(void) -{ - usb_deregister(&jumpshot_driver); -} - -module_init(jumpshot_init); -module_exit(jumpshot_exit); +module_usb_driver(jumpshot_driver); diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index ba1b789..35181e2 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c @@ -232,15 +232,4 @@ static struct usb_driver karma_driver = { .soft_unbind = 1, }; -static int __init karma_init(void) -{ - return usb_register(&karma_driver); -} - -static void __exit karma_exit(void) -{ - usb_deregister(&karma_driver); -} - -module_init(karma_init); -module_exit(karma_exit); +module_usb_driver(karma_driver); diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 1943be5..721c8c5 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c @@ -314,15 +314,4 @@ static struct usb_driver onetouch_driver = { .soft_unbind = 1, }; -static int __init onetouch_init(void) -{ - return usb_register(&onetouch_driver); -} - -static void __exit onetouch_exit(void) -{ - usb_deregister(&onetouch_driver); -} - -module_init(onetouch_init); -module_exit(onetouch_exit); +module_usb_driver(onetouch_driver); diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index 0ce5f79..c41cd30 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c @@ -1104,15 +1104,4 @@ static struct usb_driver realtek_cr_driver = { .supports_autosuspend = 1, }; -static int __init realtek_cr_init(void) -{ - return usb_register(&realtek_cr_driver); -} - -static void __exit realtek_cr_exit(void) -{ - usb_deregister(&realtek_cr_driver); -} - -module_init(realtek_cr_init); -module_exit(realtek_cr_exit); +module_usb_driver(realtek_cr_driver); diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index bcb9a70..83ee49e 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -1789,15 +1789,4 @@ static struct usb_driver sddr09_driver = { .soft_unbind = 1, }; -static int __init sddr09_init(void) -{ - return usb_register(&sddr09_driver); -} - -static void __exit sddr09_exit(void) -{ - usb_deregister(&sddr09_driver); -} - -module_init(sddr09_init); -module_exit(sddr09_exit); +module_usb_driver(sddr09_driver); diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 44dfed7..8983ec2 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c @@ -1008,15 +1008,4 @@ static struct usb_driver sddr55_driver = { .soft_unbind = 1, }; -static int __init sddr55_init(void) -{ - return usb_register(&sddr55_driver); -} - -static void __exit sddr55_exit(void) -{ - usb_deregister(&sddr55_driver); -} - -module_init(sddr55_init); -module_exit(sddr55_exit); +module_usb_driver(sddr55_driver); diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 0b00091..a4c0275 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -1865,15 +1865,4 @@ static struct usb_driver usbat_driver = { .soft_unbind = 1, }; -static int __init usbat_init(void) -{ - return usb_register(&usbat_driver); -} - -static void __exit usbat_exit(void) -{ - usb_deregister(&usbat_driver); -} - -module_init(usbat_init); -module_exit(usbat_exit); +module_usb_driver(usbat_driver); diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 1d10d5b..a33ead5 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -760,18 +760,7 @@ static struct usb_driver uas_driver = { .id_table = uas_usb_ids, }; -static int uas_init(void) -{ - return usb_register(&uas_driver); -} - -static void uas_exit(void) -{ - usb_deregister(&uas_driver); -} - -module_init(uas_init); -module_exit(uas_exit); +module_usb_driver(uas_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Matthew Wilcox and Sarah Sharp"); diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 32d6fc9..5c6c1bd 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -688,25 +688,6 @@ static struct usb_driver skel_driver = { .supports_autosuspend = 1, }; -static int __init usb_skel_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&skel_driver); - if (result) - err("usb_register failed. Error number %d", result); - - return result; -} - -static void __exit usb_skel_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&skel_driver); -} - -module_init(usb_skel_init); -module_exit(usb_skel_exit); +module_usb_driver(skel_driver); MODULE_LICENSE("GPL"); diff --git a/drivers/usb/wusbcore/cbaf.c b/drivers/usb/wusbcore/cbaf.c index 200fd7c..7f78f30 100644 --- a/drivers/usb/wusbcore/cbaf.c +++ b/drivers/usb/wusbcore/cbaf.c @@ -655,17 +655,7 @@ static struct usb_driver cbaf_driver = { .disconnect = cbaf_disconnect, }; -static int __init cbaf_driver_init(void) -{ - return usb_register(&cbaf_driver); -} -module_init(cbaf_driver_init); - -static void __exit cbaf_driver_exit(void) -{ - usb_deregister(&cbaf_driver); -} -module_exit(cbaf_driver_exit); +module_usb_driver(cbaf_driver); MODULE_AUTHOR("Inaky Perez-Gonzalez "); MODULE_DESCRIPTION("Wireless USB Cable Based Association"); -- cgit v0.10.2 From bac2c126e452eb00f91305ba2c04a8b2bd95acf0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:42:11 -0800 Subject: USB: convert drivers/staging/* to use module_usb_driver() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This converts the drivers in drivers/staging/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: "David Täht" Cc: Marek Belisko Cc: Al Cho Cc: Forest Bond Cc: Pavel Machek Cc: Huajun Li Cc: Zac Storer Cc: Randy Dunlap Cc: Mauro Carvalho Chehab Cc: edwin_rong Cc: Ben Hutchings Cc: Julia Lawall Cc: Ilia Mirkin Cc: Joe Perches Cc: Pekka Enberg Cc: "John W. Linville" Cc: Paul Gortmaker Cc: Larry Finger Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c index 2babb03..d8efed6 100644 --- a/drivers/staging/frontier/alphatrack.c +++ b/drivers/staging/frontier/alphatrack.c @@ -867,30 +867,4 @@ static struct usb_driver usb_alphatrack_driver = { .id_table = usb_alphatrack_table, }; -/** - * usb_alphatrack_init - */ -static int __init usb_alphatrack_init(void) -{ - int retval; - - /* register this driver with the USB subsystem */ - retval = usb_register(&usb_alphatrack_driver); - if (retval) - err("usb_register failed for the " __FILE__ - " driver. Error number %d\n", retval); - - return retval; -} - -/** - * usb_alphatrack_exit - */ -static void __exit usb_alphatrack_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&usb_alphatrack_driver); -} - -module_init(usb_alphatrack_init); -module_exit(usb_alphatrack_exit); +module_usb_driver(usb_alphatrack_driver); diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 8894ab1..c263284 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -971,29 +971,4 @@ static struct usb_driver usb_tranzport_driver = { .id_table = usb_tranzport_table, }; -/** - * usb_tranzport_init - */ -static int __init usb_tranzport_init(void) -{ - int retval; - - /* register this driver with the USB subsystem */ - retval = usb_register(&usb_tranzport_driver); - if (retval) - err("usb_register failed for the " __FILE__ - " driver. Error number %d\n", retval); - return retval; -} -/** - * usb_tranzport_exit - */ - -static void __exit usb_tranzport_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&usb_tranzport_driver); -} - -module_init(usb_tranzport_init); -module_exit(usb_tranzport_exit); +module_usb_driver(usb_tranzport_driver); diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c index 79482ac..84c38d5 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.c @@ -263,24 +263,4 @@ static struct usb_driver ft1000_usb_driver = { .id_table = id_table, }; -static int __init usb_ft1000_init(void) -{ - int ret = 0; - - DEBUG("Initialize and register the driver\n"); - - ret = usb_register(&ft1000_usb_driver); - if (ret) - err("usb_register failed. Error number %d", ret); - - return ret; -} - -static void __exit usb_ft1000_exit(void) -{ - DEBUG("Deregister the driver\n"); - usb_deregister(&ft1000_usb_driver); -} - -module_init(usb_ft1000_init); -module_exit(usb_ft1000_exit); +module_usb_driver(ft1000_usb_driver); diff --git a/drivers/staging/keucr/usb.c b/drivers/staging/keucr/usb.c index 66aad3a..4833034 100644 --- a/drivers/staging/keucr/usb.c +++ b/drivers/staging/keucr/usb.c @@ -701,26 +701,4 @@ static struct usb_driver usb_storage_driver = { .soft_unbind = 1, }; -//----- usb_stor_init() --------------------- -static int __init usb_stor_init(void) -{ - int retval; - pr_info("usb --- usb_stor_init start\n"); - - retval = usb_register(&usb_storage_driver); - if (retval == 0) - pr_info("ENE USB Mass Storage support registered.\n"); - - return retval; -} - -//----- usb_stor_exit() --------------------- -static void __exit usb_stor_exit(void) -{ - pr_info("usb --- usb_stor_exit\n"); - - usb_deregister(&usb_storage_driver) ; -} - -module_init(usb_stor_init); -module_exit(usb_stor_exit); +module_usb_driver(usb_storage_driver); diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c index 3db3b0a..b7175fe 100644 --- a/drivers/staging/media/go7007/go7007-usb.c +++ b/drivers/staging/media/go7007/go7007-usb.c @@ -1272,17 +1272,4 @@ static struct usb_driver go7007_usb_driver = { .id_table = go7007_usb_id_table, }; -static int __init go7007_usb_init(void) -{ - return usb_register(&go7007_usb_driver); -} - -static void __exit go7007_usb_cleanup(void) -{ - usb_deregister(&go7007_usb_driver); -} - -module_init(go7007_usb_init); -module_exit(go7007_usb_cleanup); - -MODULE_LICENSE("GPL v2"); +module_usb_driver(go7007_usb_driver); diff --git a/drivers/staging/media/lirc/lirc_igorplugusb.c b/drivers/staging/media/lirc/lirc_igorplugusb.c index 0dc2c2b..6cd4cd6 100644 --- a/drivers/staging/media/lirc/lirc_igorplugusb.c +++ b/drivers/staging/media/lirc/lirc_igorplugusb.c @@ -541,26 +541,7 @@ static struct usb_driver igorplugusb_remote_driver = { .id_table = igorplugusb_remote_id_table }; -static int __init igorplugusb_remote_init(void) -{ - int ret = 0; - - dprintk(DRIVER_NAME ": loaded, debug mode enabled\n"); - - ret = usb_register(&igorplugusb_remote_driver); - if (ret) - printk(KERN_ERR DRIVER_NAME ": usb register failed!\n"); - - return ret; -} - -static void __exit igorplugusb_remote_exit(void) -{ - usb_deregister(&igorplugusb_remote_driver); -} - -module_init(igorplugusb_remote_init); -module_exit(igorplugusb_remote_exit); +module_usb_driver(igorplugusb_remote_driver); #include MODULE_INFO(vermagic, VERMAGIC_STRING); diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c index f5308d5..f682180 100644 --- a/drivers/staging/media/lirc/lirc_imon.c +++ b/drivers/staging/media/lirc/lirc_imon.c @@ -1025,26 +1025,4 @@ static int imon_resume(struct usb_interface *intf) return rc; } -static int __init imon_init(void) -{ - int rc; - - printk(KERN_INFO MOD_NAME ": " MOD_DESC ", v" MOD_VERSION "\n"); - - rc = usb_register(&imon_driver); - if (rc) { - err("%s: usb register failed(%d)", __func__, rc); - return -ENODEV; - } - - return 0; -} - -static void __exit imon_exit(void) -{ - usb_deregister(&imon_driver); - printk(KERN_INFO MOD_NAME ": module removed. Goodbye!\n"); -} - -module_init(imon_init); -module_exit(imon_exit); +module_usb_driver(imon_driver); diff --git a/drivers/staging/media/lirc/lirc_sasem.c b/drivers/staging/media/lirc/lirc_sasem.c index a2d18b0..7855baa 100644 --- a/drivers/staging/media/lirc/lirc_sasem.c +++ b/drivers/staging/media/lirc/lirc_sasem.c @@ -913,27 +913,4 @@ static void sasem_disconnect(struct usb_interface *interface) mutex_unlock(&disconnect_lock); } -static int __init sasem_init(void) -{ - int rc; - - printk(KERN_INFO MOD_DESC ", v" MOD_VERSION "\n"); - printk(KERN_INFO MOD_AUTHOR "\n"); - - rc = usb_register(&sasem_driver); - if (rc < 0) { - err("%s: usb register failed (%d)", __func__, rc); - return -ENODEV; - } - return 0; -} - -static void __exit sasem_exit(void) -{ - usb_deregister(&sasem_driver); - printk(KERN_INFO "module removed. Goodbye!\n"); -} - - -module_init(sasem_init); -module_exit(sasem_exit); +module_usb_driver(sasem_driver); diff --git a/drivers/staging/media/lirc/lirc_ttusbir.c b/drivers/staging/media/lirc/lirc_ttusbir.c index e4b329b..7950887 100644 --- a/drivers/staging/media/lirc/lirc_ttusbir.c +++ b/drivers/staging/media/lirc/lirc_ttusbir.c @@ -372,24 +372,4 @@ static void disconnect(struct usb_interface *intf) kfree(ttusbir); } -static int ttusbir_init_module(void) -{ - int result; - - DPRINTK(KERN_DEBUG "Module ttusbir init\n"); - - /* register this driver with the USB subsystem */ - result = usb_register(&usb_driver); - if (result) - err("usb_register failed. Error number %d", result); - return result; -} - -static void ttusbir_exit_module(void) -{ - printk(KERN_DEBUG "Module ttusbir exit\n"); - usb_deregister(&usb_driver); -} - -module_init(ttusbir_init_module); -module_exit(ttusbir_exit_module); +module_usb_driver(usb_driver); diff --git a/drivers/staging/rts5139/rts51x.c b/drivers/staging/rts5139/rts51x.c index d9cee6d..2b9f785 100644 --- a/drivers/staging/rts5139/rts51x.c +++ b/drivers/staging/rts5139/rts51x.c @@ -934,34 +934,4 @@ struct usb_driver rts51x_driver = { .soft_unbind = 1, }; -static int __init rts51x_init(void) -{ - int retval; - - printk(KERN_INFO "Initializing %s USB card reader driver...\n", - RTS51X_NAME); - - /* register the driver, return usb_register return code if error */ - retval = usb_register(&rts51x_driver); - if (retval == 0) { - printk(KERN_INFO - "Realtek %s USB card reader support registered.\n", - RTS51X_NAME); - } - return retval; -} - -static void __exit rts51x_exit(void) -{ - RTS51X_DEBUGP("rts51x_exit() called\n"); - - /* Deregister the driver - * This will cause disconnect() to be called for each - * attached unit - */ - RTS51X_DEBUGP("-- calling usb_deregister()\n"); - usb_deregister(&rts51x_driver); -} - -module_init(rts51x_init); -module_exit(rts51x_exit); +module_usb_driver(rts51x_driver); diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 27521b6..541f9aa 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -2103,16 +2103,4 @@ static struct usb_driver vt6656_driver = { #endif /* CONFIG_PM */ }; -static int __init vt6656_init_module(void) -{ - printk(KERN_NOTICE DEVICE_FULL_DRV_NAM " " DEVICE_VERSION); - return usb_register(&vt6656_driver); -} - -static void __exit vt6656_cleanup_module(void) -{ - usb_deregister(&vt6656_driver); -} - -module_init(vt6656_init_module); -module_exit(vt6656_cleanup_module); +module_usb_driver(vt6656_driver); diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c index f958eb4..c3751a7 100644 --- a/drivers/staging/winbond/wbusb.c +++ b/drivers/staging/winbond/wbusb.c @@ -865,15 +865,4 @@ static struct usb_driver wb35_driver = { .disconnect = wb35_disconnect, }; -static int __init wb35_init(void) -{ - return usb_register(&wb35_driver); -} - -static void __exit wb35_exit(void) -{ - usb_deregister(&wb35_driver); -} - -module_init(wb35_init); -module_exit(wb35_exit); +module_usb_driver(wb35_driver); diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 4efa027..b1aed1f 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -358,16 +358,4 @@ static struct usb_driver prism2_usb_driver = { /* fops, minor? */ }; -static int __init prism2usb_init(void) -{ - /* This call will result in calls to prism2sta_probe_usb. */ - return usb_register(&prism2_usb_driver); -}; - -static void __exit prism2usb_cleanup(void) -{ - usb_deregister(&prism2_usb_driver); -}; - -module_init(prism2usb_init); -module_exit(prism2usb_cleanup); +module_usb_driver(prism2_usb_driver); -- cgit v0.10.2 From d632eb1bf22e11def74e4e53cc47d790fbdba105 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:44:20 -0800 Subject: USB: convert drivers/net/* to use module_usb_driver() This converts the drivers in drivers/net/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Wolfgang Grandegger Cc: Samuel Ortiz Cc: Oliver Neukum Cc: Peter Korsgaard Cc: Petko Manolov Cc: Steve Glendinning Cc: Christian Lamparter Cc: "John W. Linville" Cc: Dan Williams Cc: Jussi Kivilinna Cc: Ivo van Doorn Cc: Gertjan van Wingerde Cc: Helmut Schaa Cc: Herton Ronaldo Krzesinski Cc: Hin-Tak Leung Cc: Larry Finger Cc: Chaoming Li Cc: Lucas De Marchi Cc: "David S. Miller" Cc: Roel Kluin Cc: Paul Gortmaker Cc: Jiri Pirko Cc: Pavel Roskin Cc: Yoann DI-RUZZA Cc: George Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c index a72c7bf..9697c14 100644 --- a/drivers/net/can/usb/ems_usb.c +++ b/drivers/net/can/usb/ems_usb.c @@ -1115,28 +1115,4 @@ static struct usb_driver ems_usb_driver = { .id_table = ems_usb_table, }; -static int __init ems_usb_init(void) -{ - int err; - - printk(KERN_INFO "CPC-USB kernel driver loaded\n"); - - /* register this driver with the USB subsystem */ - err = usb_register(&ems_usb_driver); - - if (err) { - err("usb_register failed. Error number %d\n", err); - return err; - } - - return 0; -} - -static void __exit ems_usb_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&ems_usb_driver); -} - -module_init(ems_usb_init); -module_exit(ems_usb_exit); +module_usb_driver(ems_usb_driver); diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c index eb8b0e6..9277463 100644 --- a/drivers/net/can/usb/esd_usb2.c +++ b/drivers/net/can/usb/esd_usb2.c @@ -1108,25 +1108,4 @@ static struct usb_driver esd_usb2_driver = { .id_table = esd_usb2_table, }; -static int __init esd_usb2_init(void) -{ - int err; - - /* register this driver with the USB subsystem */ - err = usb_register(&esd_usb2_driver); - - if (err) { - err("usb_register failed. Error number %d\n", err); - return err; - } - - return 0; -} -module_init(esd_usb2_init); - -static void __exit esd_usb2_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&esd_usb2_driver); -} -module_exit(esd_usb2_exit); +module_usb_driver(esd_usb2_driver); diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index d9267cb..72f687b 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1914,41 +1914,8 @@ static struct usb_driver irda_driver = { #endif }; -/************************* MODULE CALLBACKS *************************/ -/* - * Deal with module insertion/removal - * Mostly tell USB about our existence - */ - -/*------------------------------------------------------------------*/ -/* - * Module insertion - */ -static int __init usb_irda_init(void) -{ - int ret; - - ret = usb_register(&irda_driver); - if (ret < 0) - return ret; - - IRDA_MESSAGE("USB IrDA support registered\n"); - return 0; -} -module_init(usb_irda_init); +module_usb_driver(irda_driver); -/*------------------------------------------------------------------*/ -/* - * Module removal - */ -static void __exit usb_irda_cleanup(void) -{ - /* Deregister the driver and remove all pending instances */ - usb_deregister(&irda_driver); -} -module_exit(usb_irda_cleanup); - -/*------------------------------------------------------------------*/ /* * Module parameters */ diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c index cb90d64..79aebee 100644 --- a/drivers/net/irda/kingsun-sir.c +++ b/drivers/net/irda/kingsun-sir.c @@ -621,24 +621,7 @@ static struct usb_driver irda_driver = { #endif }; -/* - * Module insertion - */ -static int __init kingsun_init(void) -{ - return usb_register(&irda_driver); -} -module_init(kingsun_init); - -/* - * Module removal - */ -static void __exit kingsun_cleanup(void) -{ - /* Deregister the driver and remove all pending instances */ - usb_deregister(&irda_driver); -} -module_exit(kingsun_cleanup); +module_usb_driver(irda_driver); MODULE_AUTHOR("Alex Villacís Lasso "); MODULE_DESCRIPTION("IrDA-USB Dongle Driver for KingSun/DonShine"); diff --git a/drivers/net/irda/ks959-sir.c b/drivers/net/irda/ks959-sir.c index 1046014..abe689d 100644 --- a/drivers/net/irda/ks959-sir.c +++ b/drivers/net/irda/ks959-sir.c @@ -901,26 +901,7 @@ static struct usb_driver irda_driver = { #endif }; -/* - * Module insertion - */ -static int __init ks959_init(void) -{ - return usb_register(&irda_driver); -} - -module_init(ks959_init); - -/* - * Module removal - */ -static void __exit ks959_cleanup(void) -{ - /* Deregister the driver and remove all pending instances */ - usb_deregister(&irda_driver); -} - -module_exit(ks959_cleanup); +module_usb_driver(irda_driver); MODULE_AUTHOR("Alex Villacís Lasso "); MODULE_DESCRIPTION("IrDA-USB Dongle Driver for KingSun KS-959"); diff --git a/drivers/net/irda/ksdazzle-sir.c b/drivers/net/irda/ksdazzle-sir.c index 9cc142f..f8c0108 100644 --- a/drivers/net/irda/ksdazzle-sir.c +++ b/drivers/net/irda/ksdazzle-sir.c @@ -796,26 +796,7 @@ static struct usb_driver irda_driver = { #endif }; -/* - * Module insertion - */ -static int __init ksdazzle_init(void) -{ - return usb_register(&irda_driver); -} - -module_init(ksdazzle_init); - -/* - * Module removal - */ -static void __exit ksdazzle_cleanup(void) -{ - /* Deregister the driver and remove all pending instances */ - usb_deregister(&irda_driver); -} - -module_exit(ksdazzle_cleanup); +module_usb_driver(irda_driver); MODULE_AUTHOR("Alex Villacís Lasso "); MODULE_DESCRIPTION("IrDA-USB Dongle Driver for KingSun Dazzle"); diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c index be52bfe..1a00b59 100644 --- a/drivers/net/irda/mcs7780.c +++ b/drivers/net/irda/mcs7780.c @@ -968,25 +968,4 @@ static void mcs_disconnect(struct usb_interface *intf) IRDA_DEBUG(0, "MCS7780 now disconnected.\n"); } -/* Module insertion */ -static int __init mcs_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&mcs_driver); - if (result) - IRDA_ERROR("usb_register failed. Error number %d\n", result); - - return result; -} -module_init(mcs_init); - -/* Module removal */ -static void __exit mcs_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&mcs_driver); -} -module_exit(mcs_exit); - +module_usb_driver(mcs_driver); diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index 41c96b3..212868e 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c @@ -1133,21 +1133,4 @@ static struct usb_driver irda_driver = { #endif }; -/* - * Module insertion - */ -static int __init stir_init(void) -{ - return usb_register(&irda_driver); -} -module_init(stir_init); - -/* - * Module removal - */ -static void __exit stir_cleanup(void) -{ - /* Deregister the driver and remove all pending instances */ - usb_deregister(&irda_driver); -} -module_exit(stir_cleanup); +module_usb_driver(irda_driver); diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c index e81e22e..97a1cc7 100644 --- a/drivers/net/usb/asix.c +++ b/drivers/net/usb/asix.c @@ -1634,17 +1634,7 @@ static struct usb_driver asix_driver = { .supports_autosuspend = 1, }; -static int __init asix_init(void) -{ - return usb_register(&asix_driver); -} -module_init(asix_init); - -static void __exit asix_exit(void) -{ - usb_deregister(&asix_driver); -} -module_exit(asix_exit); +module_usb_driver(asix_driver); MODULE_AUTHOR("David Hollis"); MODULE_VERSION(DRIVER_VERSION); diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c index a68272c..182cfb4 100644 --- a/drivers/net/usb/catc.c +++ b/drivers/net/usb/catc.c @@ -949,19 +949,4 @@ static struct usb_driver catc_driver = { .id_table = catc_id_table, }; -static int __init catc_init(void) -{ - int result = usb_register(&catc_driver); - if (result == 0) - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return result; -} - -static void __exit catc_exit(void) -{ - usb_deregister(&catc_driver); -} - -module_init(catc_init); -module_exit(catc_exit); +module_usb_driver(catc_driver); diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c index a60d006..30aedcd 100644 --- a/drivers/net/usb/cdc-phonet.c +++ b/drivers/net/usb/cdc-phonet.c @@ -457,18 +457,7 @@ static struct usb_driver usbpn_driver = { .id_table = usbpn_ids, }; -static int __init usbpn_init(void) -{ - return usb_register(&usbpn_driver); -} - -static void __exit usbpn_exit(void) -{ - usb_deregister(&usbpn_driver); -} - -module_init(usbpn_init); -module_exit(usbpn_exit); +module_usb_driver(usbpn_driver); MODULE_AUTHOR("Remi Denis-Courmont"); MODULE_DESCRIPTION("USB CDC Phonet host interface"); diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c index 882f53f..439690b 100644 --- a/drivers/net/usb/cdc_eem.c +++ b/drivers/net/usb/cdc_eem.c @@ -369,18 +369,7 @@ static struct usb_driver eem_driver = { .resume = usbnet_resume, }; - -static int __init eem_init(void) -{ - return usb_register(&eem_driver); -} -module_init(eem_init); - -static void __exit eem_exit(void) -{ - usb_deregister(&eem_driver); -} -module_exit(eem_exit); +module_usb_driver(eem_driver); MODULE_AUTHOR("Omar Laazimani "); MODULE_DESCRIPTION("USB CDC EEM"); diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index c924ea2..26637c3 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -425,6 +425,9 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf) int status; struct cdc_state *info = (void *) &dev->data; + BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) + < sizeof(struct cdc_state))); + status = usbnet_generic_cdc_bind(dev, intf); if (status < 0) return status; @@ -615,21 +618,7 @@ static struct usb_driver cdc_driver = { .supports_autosuspend = 1, }; - -static int __init cdc_init(void) -{ - BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) - < sizeof(struct cdc_state))); - - return usb_register(&cdc_driver); -} -module_init(cdc_init); - -static void __exit cdc_exit(void) -{ - usb_deregister(&cdc_driver); -} -module_exit(cdc_exit); +module_usb_driver(cdc_driver); MODULE_AUTHOR("David Brownell"); MODULE_DESCRIPTION("USB CDC Ethernet devices"); diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index f06fb78..9904b7e 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c @@ -1232,20 +1232,7 @@ static struct ethtool_ops cdc_ncm_ethtool_ops = { .nway_reset = usbnet_nway_reset, }; -static int __init cdc_ncm_init(void) -{ - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION "\n"); - return usb_register(&cdc_ncm_driver); -} - -module_init(cdc_ncm_init); - -static void __exit cdc_ncm_exit(void) -{ - usb_deregister(&cdc_ncm_driver); -} - -module_exit(cdc_ncm_exit); +module_usb_driver(cdc_ncm_driver); MODULE_AUTHOR("Hans Petter Selasky"); MODULE_DESCRIPTION("USB CDC NCM host driver"); diff --git a/drivers/net/usb/cdc_subset.c b/drivers/net/usb/cdc_subset.c index fc5f13d..b403d93 100644 --- a/drivers/net/usb/cdc_subset.c +++ b/drivers/net/usb/cdc_subset.c @@ -338,17 +338,7 @@ static struct usb_driver cdc_subset_driver = { .id_table = products, }; -static int __init cdc_subset_init(void) -{ - return usb_register(&cdc_subset_driver); -} -module_init(cdc_subset_init); - -static void __exit cdc_subset_exit(void) -{ - usb_deregister(&cdc_subset_driver); -} -module_exit(cdc_subset_exit); +module_usb_driver(cdc_subset_driver); MODULE_AUTHOR("David Brownell"); MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c index 8969f12..0e05313 100644 --- a/drivers/net/usb/cx82310_eth.c +++ b/drivers/net/usb/cx82310_eth.c @@ -329,17 +329,7 @@ static struct usb_driver cx82310_driver = { .resume = usbnet_resume, }; -static int __init cx82310_init(void) -{ - return usb_register(&cx82310_driver); -} -module_init(cx82310_init); - -static void __exit cx82310_exit(void) -{ - usb_deregister(&cx82310_driver); -} -module_exit(cx82310_exit); +module_usb_driver(cx82310_driver); MODULE_AUTHOR("Ondrej Zary"); MODULE_DESCRIPTION("Conexant CX82310-based ADSL router USB ethernet driver"); diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c index fbc0e4d..b972263 100644 --- a/drivers/net/usb/dm9601.c +++ b/drivers/net/usb/dm9601.c @@ -672,18 +672,7 @@ static struct usb_driver dm9601_driver = { .resume = usbnet_resume, }; -static int __init dm9601_init(void) -{ - return usb_register(&dm9601_driver); -} - -static void __exit dm9601_exit(void) -{ - usb_deregister(&dm9601_driver); -} - -module_init(dm9601_init); -module_exit(dm9601_exit); +module_usb_driver(dm9601_driver); MODULE_AUTHOR("Peter Korsgaard "); MODULE_DESCRIPTION("Davicom DM9601 USB 1.1 ethernet devices"); diff --git a/drivers/net/usb/gl620a.c b/drivers/net/usb/gl620a.c index c4cfd1d..38266bd 100644 --- a/drivers/net/usb/gl620a.c +++ b/drivers/net/usb/gl620a.c @@ -227,17 +227,7 @@ static struct usb_driver gl620a_driver = { .resume = usbnet_resume, }; -static int __init usbnet_init(void) -{ - return usb_register(&gl620a_driver); -} -module_init(usbnet_init); - -static void __exit usbnet_exit(void) -{ - usb_deregister(&gl620a_driver); -} -module_exit(usbnet_exit); +module_usb_driver(gl620a_driver); MODULE_AUTHOR("Jiun-Jie Huang"); MODULE_DESCRIPTION("GL620-USB-A Host-to-Host Link cables"); diff --git a/drivers/net/usb/int51x1.c b/drivers/net/usb/int51x1.c index 131ac6c..12a22a4 100644 --- a/drivers/net/usb/int51x1.c +++ b/drivers/net/usb/int51x1.c @@ -238,17 +238,7 @@ static struct usb_driver int51x1_driver = { .resume = usbnet_resume, }; -static int __init int51x1_init(void) -{ - return usb_register(&int51x1_driver); -} -module_init(int51x1_init); - -static void __exit int51x1_exit(void) -{ - usb_deregister(&int51x1_driver); -} -module_exit(int51x1_exit); +module_usb_driver(int51x1_driver); MODULE_AUTHOR("Peter Holik"); MODULE_DESCRIPTION("Intellon usb powerline adapter"); diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 13c1f04..08a4df2 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -543,25 +543,7 @@ static struct usb_driver ipheth_driver = { .id_table = ipheth_table, }; -static int __init ipheth_init(void) -{ - int retval; - - retval = usb_register(&ipheth_driver); - if (retval) { - err("usb_register failed: %d", retval); - return retval; - } - return 0; -} - -static void __exit ipheth_exit(void) -{ - usb_deregister(&ipheth_driver); -} - -module_init(ipheth_init); -module_exit(ipheth_exit); +module_usb_driver(ipheth_driver); MODULE_AUTHOR("Diego Giagio "); MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver"); diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c index 5a6d0f8..7562649 100644 --- a/drivers/net/usb/kalmia.c +++ b/drivers/net/usb/kalmia.c @@ -375,17 +375,7 @@ static struct usb_driver kalmia_driver = { .resume = usbnet_resume }; -static int __init kalmia_init(void) -{ - return usb_register(&kalmia_driver); -} -module_init( kalmia_init); - -static void __exit kalmia_exit(void) -{ - usb_deregister(&kalmia_driver); -} -module_exit( kalmia_exit); +module_usb_driver(kalmia_driver); MODULE_AUTHOR("Marius Bjoernstad Kotsbak "); MODULE_DESCRIPTION("Samsung Kalmia USB network driver"); diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 582ca2d..d034d9c 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -1324,32 +1324,4 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev, } } - -/**************************************************************** - * kaweth_init - ****************************************************************/ -static int __init kaweth_init(void) -{ - dbg("Driver loading"); - return usb_register(&kaweth_driver); -} - -/**************************************************************** - * kaweth_exit - ****************************************************************/ -static void __exit kaweth_exit(void) -{ - usb_deregister(&kaweth_driver); -} - -module_init(kaweth_init); -module_exit(kaweth_exit); - - - - - - - - - +module_usb_driver(kaweth_driver); diff --git a/drivers/net/usb/lg-vl600.c b/drivers/net/usb/lg-vl600.c index d43db32..497db19 100644 --- a/drivers/net/usb/lg-vl600.c +++ b/drivers/net/usb/lg-vl600.c @@ -349,17 +349,7 @@ static struct usb_driver lg_vl600_driver = { .resume = usbnet_resume, }; -static int __init vl600_init(void) -{ - return usb_register(&lg_vl600_driver); -} -module_init(vl600_init); - -static void __exit vl600_exit(void) -{ - usb_deregister(&lg_vl600_driver); -} -module_exit(vl600_exit); +module_usb_driver(lg_vl600_driver); MODULE_AUTHOR("Anrzej Zaborowski"); MODULE_DESCRIPTION("LG-VL600 modem's ethernet link"); diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c index db2cb74..a29aa9c 100644 --- a/drivers/net/usb/mcs7830.c +++ b/drivers/net/usb/mcs7830.c @@ -692,17 +692,7 @@ static struct usb_driver mcs7830_driver = { .reset_resume = mcs7830_reset_resume, }; -static int __init mcs7830_init(void) -{ - return usb_register(&mcs7830_driver); -} -module_init(mcs7830_init); - -static void __exit mcs7830_exit(void) -{ - usb_deregister(&mcs7830_driver); -} -module_exit(mcs7830_exit); +module_usb_driver(mcs7830_driver); MODULE_DESCRIPTION("USB to network adapter MCS7830)"); MODULE_LICENSE("GPL"); diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c index 01db460..83f965c 100644 --- a/drivers/net/usb/net1080.c +++ b/drivers/net/usb/net1080.c @@ -589,17 +589,7 @@ static struct usb_driver net1080_driver = { .resume = usbnet_resume, }; -static int __init net1080_init(void) -{ - return usb_register(&net1080_driver); -} -module_init(net1080_init); - -static void __exit net1080_exit(void) -{ - usb_deregister(&net1080_driver); -} -module_exit(net1080_exit); +module_usb_driver(net1080_driver); MODULE_AUTHOR("David Brownell"); MODULE_DESCRIPTION("NetChip 1080 based USB Host-to-Host Links"); diff --git a/drivers/net/usb/plusb.c b/drivers/net/usb/plusb.c index 217aec8..b2b035e 100644 --- a/drivers/net/usb/plusb.c +++ b/drivers/net/usb/plusb.c @@ -154,17 +154,7 @@ static struct usb_driver plusb_driver = { .resume = usbnet_resume, }; -static int __init plusb_init(void) -{ - return usb_register(&plusb_driver); -} -module_init(plusb_init); - -static void __exit plusb_exit(void) -{ - usb_deregister(&plusb_driver); -} -module_exit(plusb_exit); +module_usb_driver(plusb_driver); MODULE_AUTHOR("David Brownell"); MODULE_DESCRIPTION("Prolific PL-2301/2302/25A1 USB Host to Host Link Driver"); diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index 255d6a4..c8f1b5b 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c @@ -635,17 +635,7 @@ static struct usb_driver rndis_driver = { .resume = usbnet_resume, }; -static int __init rndis_init(void) -{ - return usb_register(&rndis_driver); -} -module_init(rndis_init); - -static void __exit rndis_exit(void) -{ - usb_deregister(&rndis_driver); -} -module_exit(rndis_exit); +module_usb_driver(rndis_driver); MODULE_AUTHOR("David Brownell"); MODULE_DESCRIPTION("USB Host side RNDIS driver"); diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c index bf8c84d..0710b4c 100644 --- a/drivers/net/usb/rtl8150.c +++ b/drivers/net/usb/rtl8150.c @@ -978,20 +978,7 @@ static struct usb_driver rtl8150_driver = { .resume = rtl8150_resume }; -static int __init usb_rtl8150_init(void) -{ - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return usb_register(&rtl8150_driver); -} - -static void __exit usb_rtl8150_exit(void) -{ - usb_deregister(&rtl8150_driver); -} - -module_init(usb_rtl8150_init); -module_exit(usb_rtl8150_exit); +module_usb_driver(rtl8150_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c index ed1b432..e45dfdc 100644 --- a/drivers/net/usb/sierra_net.c +++ b/drivers/net/usb/sierra_net.c @@ -900,6 +900,9 @@ struct sk_buff *sierra_net_tx_fixup(struct usbnet *dev, struct sk_buff *skb, u16 len; bool need_tail; + BUILD_BUG_ON(FIELD_SIZEOF(struct usbnet, data) + < sizeof(struct cdc_state)); + dev_dbg(&dev->udev->dev, "%s", __func__); if (priv->link_up && check_ethip_packet(skb, dev) && is_ip(skb)) { /* enough head room as is? */ @@ -981,21 +984,7 @@ static struct usb_driver sierra_net_driver = { .no_dynamic_id = 1, }; -static int __init sierra_net_init(void) -{ - BUILD_BUG_ON(FIELD_SIZEOF(struct usbnet, data) - < sizeof(struct cdc_state)); - - return usb_register(&sierra_net_driver); -} - -static void __exit sierra_net_exit(void) -{ - usb_deregister(&sierra_net_driver); -} - -module_exit(sierra_net_exit); -module_init(sierra_net_init); +module_usb_driver(sierra_net_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c index 22a7cf9..9741b24 100644 --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -1236,17 +1236,7 @@ static struct usb_driver smsc75xx_driver = { .disconnect = usbnet_disconnect, }; -static int __init smsc75xx_init(void) -{ - return usb_register(&smsc75xx_driver); -} -module_init(smsc75xx_init); - -static void __exit smsc75xx_exit(void) -{ - usb_deregister(&smsc75xx_driver); -} -module_exit(smsc75xx_exit); +module_usb_driver(smsc75xx_driver); MODULE_AUTHOR("Nancy Lin"); MODULE_AUTHOR("Steve Glendinning "); diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index eff6767..4a10761 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1297,17 +1297,7 @@ static struct usb_driver smsc95xx_driver = { .disconnect = usbnet_disconnect, }; -static int __init smsc95xx_init(void) -{ - return usb_register(&smsc95xx_driver); -} -module_init(smsc95xx_init); - -static void __exit smsc95xx_exit(void) -{ - usb_deregister(&smsc95xx_driver); -} -module_exit(smsc95xx_exit); +module_usb_driver(smsc95xx_driver); MODULE_AUTHOR("Nancy Lin"); MODULE_AUTHOR("Steve Glendinning "); diff --git a/drivers/net/usb/zaurus.c b/drivers/net/usb/zaurus.c index 1a2234c..f701d41 100644 --- a/drivers/net/usb/zaurus.c +++ b/drivers/net/usb/zaurus.c @@ -362,17 +362,7 @@ static struct usb_driver zaurus_driver = { .resume = usbnet_resume, }; -static int __init zaurus_init(void) -{ - return usb_register(&zaurus_driver); -} -module_init(zaurus_init); - -static void __exit zaurus_exit(void) -{ - usb_deregister(&zaurus_driver); -} -module_exit(zaurus_exit); +module_usb_driver(zaurus_driver); MODULE_AUTHOR("Pavel Machek, David Brownell"); MODULE_DESCRIPTION("Sharp Zaurus PDA, and compatible products"); diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c index 333b69e..89821e4 100644 --- a/drivers/net/wireless/ath/carl9170/usb.c +++ b/drivers/net/wireless/ath/carl9170/usb.c @@ -1161,15 +1161,4 @@ static struct usb_driver carl9170_driver = { #endif /* CONFIG_PM */ }; -static int __init carl9170_usb_init(void) -{ - return usb_register(&carl9170_driver); -} - -static void __exit carl9170_usb_exit(void) -{ - usb_deregister(&carl9170_driver); -} - -module_init(carl9170_usb_init); -module_exit(carl9170_usb_exit); +module_usb_driver(carl9170_driver); diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index db879c3..b5fbbc7 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c @@ -1184,29 +1184,7 @@ static struct usb_driver if_usb_driver = { .reset_resume = if_usb_resume, }; -static int __init if_usb_init_module(void) -{ - int ret = 0; - - lbs_deb_enter(LBS_DEB_MAIN); - - ret = usb_register(&if_usb_driver); - - lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); - return ret; -} - -static void __exit if_usb_exit_module(void) -{ - lbs_deb_enter(LBS_DEB_MAIN); - - usb_deregister(&if_usb_driver); - - lbs_deb_leave(LBS_DEB_MAIN); -} - -module_init(if_usb_init_module); -module_exit(if_usb_exit_module); +module_usb_driver(if_usb_driver); MODULE_DESCRIPTION("8388 USB WLAN Driver"); MODULE_AUTHOR("Marvell International Ltd. and Red Hat, Inc."); diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c index 68202e6..aff8b57 100644 --- a/drivers/net/wireless/libertas_tf/if_usb.c +++ b/drivers/net/wireless/libertas_tf/if_usb.c @@ -924,27 +924,7 @@ static struct usb_driver if_usb_driver = { .resume = if_usb_resume, }; -static int __init if_usb_init_module(void) -{ - int ret = 0; - - lbtf_deb_enter(LBTF_DEB_MAIN); - - ret = usb_register(&if_usb_driver); - - lbtf_deb_leave_args(LBTF_DEB_MAIN, "ret %d", ret); - return ret; -} - -static void __exit if_usb_exit_module(void) -{ - lbtf_deb_enter(LBTF_DEB_MAIN); - usb_deregister(&if_usb_driver); - lbtf_deb_leave(LBTF_DEB_MAIN); -} - -module_init(if_usb_init_module); -module_exit(if_usb_exit_module); +module_usb_driver(if_usb_driver); MODULE_DESCRIPTION("8388 USB WLAN Thinfirm Driver"); MODULE_AUTHOR("Cozybit Inc."); diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c index 0793e42..ae8ce56 100644 --- a/drivers/net/wireless/orinoco/orinoco_usb.c +++ b/drivers/net/wireless/orinoco/orinoco_usb.c @@ -1759,32 +1759,7 @@ static struct usb_driver orinoco_driver = { static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION " (Manuel Estrada Sainz)"; -static int __init ezusb_module_init(void) -{ - int err; - - printk(KERN_DEBUG "%s\n", version); - - /* register this driver with the USB subsystem */ - err = usb_register(&orinoco_driver); - if (err < 0) { - printk(KERN_ERR PFX "usb_register failed, error %d\n", - err); - return err; - } - - return 0; -} - -static void __exit ezusb_module_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&orinoco_driver); -} - - -module_init(ezusb_module_init); -module_exit(ezusb_module_exit); +module_usb_driver(orinoco_driver); MODULE_AUTHOR("Manuel Estrada Sainz"); MODULE_DESCRIPTION("Driver for Orinoco wireless LAN cards using EZUSB bridge"); diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c index 9b60968..f4d28c3 100644 --- a/drivers/net/wireless/p54/p54usb.c +++ b/drivers/net/wireless/p54/p54usb.c @@ -1083,15 +1083,4 @@ static struct usb_driver p54u_driver = { .soft_unbind = 1, }; -static int __init p54u_init(void) -{ - return usb_register(&p54u_driver); -} - -static void __exit p54u_exit(void) -{ - usb_deregister(&p54u_driver); -} - -module_init(p54u_init); -module_exit(p54u_exit); +module_usb_driver(p54u_driver); diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 0c13840..85370a7 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -3754,17 +3754,7 @@ static struct usb_driver rndis_wlan_driver = { .resume = usbnet_resume, }; -static int __init rndis_wlan_init(void) -{ - return usb_register(&rndis_wlan_driver); -} -module_init(rndis_wlan_init); - -static void __exit rndis_wlan_exit(void) -{ - usb_deregister(&rndis_wlan_driver); -} -module_exit(rndis_wlan_exit); +module_usb_driver(rndis_wlan_driver); MODULE_AUTHOR("Bjorge Dijkstra"); MODULE_AUTHOR("Jussi Kivilinna"); diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index 53c5f87..b31f38d 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c @@ -1982,15 +1982,4 @@ static struct usb_driver rt2500usb_driver = { .resume = rt2x00usb_resume, }; -static int __init rt2500usb_init(void) -{ - return usb_register(&rt2500usb_driver); -} - -static void __exit rt2500usb_exit(void) -{ - usb_deregister(&rt2500usb_driver); -} - -module_init(rt2500usb_init); -module_exit(rt2500usb_exit); +module_usb_driver(rt2500usb_driver); diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index f156579..78550a7 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -1233,15 +1233,4 @@ static struct usb_driver rt2800usb_driver = { .resume = rt2x00usb_resume, }; -static int __init rt2800usb_init(void) -{ - return usb_register(&rt2800usb_driver); -} - -static void __exit rt2800usb_exit(void) -{ - usb_deregister(&rt2800usb_driver); -} - -module_init(rt2800usb_init); -module_exit(rt2800usb_exit); +module_usb_driver(rt2800usb_driver); diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index cfb19db..0e5a101 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c @@ -2528,15 +2528,4 @@ static struct usb_driver rt73usb_driver = { .resume = rt2x00usb_resume, }; -static int __init rt73usb_init(void) -{ - return usb_register(&rt73usb_driver); -} - -static void __exit rt73usb_exit(void) -{ - usb_deregister(&rt73usb_driver); -} - -module_init(rt73usb_init); -module_exit(rt73usb_exit); +module_usb_driver(rt73usb_driver); diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c index 4a78f9e..638fbef 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c @@ -1592,15 +1592,4 @@ static struct usb_driver rtl8187_driver = { .disconnect = __devexit_p(rtl8187_disconnect), }; -static int __init rtl8187_init(void) -{ - return usb_register(&rtl8187_driver); -} - -static void __exit rtl8187_exit(void) -{ - usb_deregister(&rtl8187_driver); -} - -module_init(rtl8187_init); -module_exit(rtl8187_exit); +module_usb_driver(rtl8187_driver); diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index c244f2f..674cd1a 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -356,15 +356,4 @@ static struct usb_driver rtl8192cu_driver = { #endif }; -static int __init rtl8192cu_init(void) -{ - return usb_register(&rtl8192cu_driver); -} - -static void __exit rtl8192cu_exit(void) -{ - usb_deregister(&rtl8192cu_driver); -} - -module_init(rtl8192cu_init); -module_exit(rtl8192cu_exit); +module_usb_driver(rtl8192cu_driver); diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c index 8efa2f2..a66b93b 100644 --- a/drivers/net/wireless/zd1201.c +++ b/drivers/net/wireless/zd1201.c @@ -1907,15 +1907,4 @@ static struct usb_driver zd1201_usb = { .resume = zd1201_resume, }; -static int __init zd1201_init(void) -{ - return usb_register(&zd1201_usb); -} - -static void __exit zd1201_cleanup(void) -{ - usb_deregister(&zd1201_usb); -} - -module_init(zd1201_init); -module_exit(zd1201_cleanup); +module_usb_driver(zd1201_usb); -- cgit v0.10.2 From ecb3b2b35db49778b6d89e3ffd0c400776c20735 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:46:12 -0800 Subject: USB: convert drivers/media/* to use module_usb_driver() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This converts the drivers in drivers/media/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Mauro Carvalho Chehab Cc: Luca Risolia Cc: Jean-Francois Moine Cc: Frank Zago Cc: Olivier Lorin Cc: Erik Andren Cc: Hans de Goede Cc: Brian Johnson Cc: Leandro Costantino Cc: Antoine Jacquet Cc: Jarod Wilson Cc: Florian Mickler Cc: Antti Palosaari Cc: Michael Krufky Cc: "David Härdeman" Cc: Florent Audebert Cc: Sam Doshi Cc: Manu Abraham Cc: Olivier Grenie Cc: Patrick Boettcher Cc: "Igor M. Liplianin" Cc: Derek Kelly Cc: Malcolm Priestley Cc: Steven Toth Cc: "André Weidemann" Cc: Martin Wilks Cc: Tejun Heo Cc: Jose Alberto Reguero Cc: David Henningsson Cc: Paul Gortmaker Cc: Joe Perches Cc: Jesper Juhl Cc: Lucas De Marchi Cc: Hans Verkuil Cc: Alexey Khoroshilov Cc: Anssi Hannula Cc: Rafi Rubin Cc: Dan Carpenter Cc: Paul Bender Cc: Devin Heitmueller Cc: "Márcio A Alves" Cc: Julia Lawall Cc: Laurent Pinchart Cc: Chris Rankin Cc: Lee Jones Cc: Andy Walls Cc: Andrew Morton Cc: Mike Frysinger Cc: Dean Anderson Cc: Pete Eberlein Cc: Arvydas Sidorenko Cc: Andrea Anacleto Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c index bedcfb6..26c666d 100644 --- a/drivers/media/dvb/b2c2/flexcop-usb.c +++ b/drivers/media/dvb/b2c2/flexcop-usb.c @@ -583,25 +583,7 @@ static struct usb_driver flexcop_usb_driver = { .id_table = flexcop_usb_table, }; -/* module stuff */ -static int __init flexcop_usb_module_init(void) -{ - int result; - if ((result = usb_register(&flexcop_usb_driver))) { - err("usb_register failed. (%d)", result); - return result; - } - return 0; -} - -static void __exit flexcop_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&flexcop_usb_driver); -} - -module_init(flexcop_usb_module_init); -module_exit(flexcop_usb_module_exit); +module_usb_driver(flexcop_usb_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_NAME); diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index 2aef3c8..8d7fef8 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c @@ -183,26 +183,7 @@ static struct usb_driver a800_driver = { .id_table = a800_table, }; -/* module stuff */ -static int __init a800_module_init(void) -{ - int result; - if ((result = usb_register(&a800_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit a800_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&a800_driver); -} - -module_init (a800_module_init); -module_exit (a800_module_exit); +module_usb_driver(a800_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)"); diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index c6c275b..56cbd36 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c @@ -1713,25 +1713,7 @@ static struct usb_driver af9015_usb_driver = { .id_table = af9015_usb_table, }; -/* module stuff */ -static int __init af9015_usb_module_init(void) -{ - int ret; - ret = usb_register(&af9015_usb_driver); - if (ret) - err("module init failed:%d", ret); - - return ret; -} - -static void __exit af9015_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&af9015_usb_driver); -} - -module_init(af9015_usb_module_init); -module_exit(af9015_usb_module_exit); +module_usb_driver(af9015_usb_driver); MODULE_AUTHOR("Antti Palosaari "); MODULE_DESCRIPTION("Driver for Afatech AF9015 DVB-T"); diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c index 5f2278b..b39f14f 100644 --- a/drivers/media/dvb/dvb-usb/anysee.c +++ b/drivers/media/dvb/dvb-usb/anysee.c @@ -1091,26 +1091,7 @@ static struct usb_driver anysee_driver = { .id_table = anysee_table, }; -/* module stuff */ -static int __init anysee_module_init(void) -{ - int ret; - - ret = usb_register(&anysee_driver); - if (ret) - err("%s: usb_register failed. Error number %d", __func__, ret); - - return ret; -} - -static void __exit anysee_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&anysee_driver); -} - -module_init(anysee_module_init); -module_exit(anysee_module_exit); +module_usb_driver(anysee_driver); MODULE_AUTHOR("Antti Palosaari "); MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0"); diff --git a/drivers/media/dvb/dvb-usb/au6610.c b/drivers/media/dvb/dvb-usb/au6610.c index b779949..16210c0 100644 --- a/drivers/media/dvb/dvb-usb/au6610.c +++ b/drivers/media/dvb/dvb-usb/au6610.c @@ -244,26 +244,7 @@ static struct usb_driver au6610_driver = { .id_table = au6610_table, }; -/* module stuff */ -static int __init au6610_module_init(void) -{ - int ret; - - ret = usb_register(&au6610_driver); - if (ret) - err("usb_register failed. Error number %d", ret); - - return ret; -} - -static void __exit au6610_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&au6610_driver); -} - -module_init(au6610_module_init); -module_exit(au6610_module_exit); +module_usb_driver(au6610_driver); MODULE_AUTHOR("Antti Palosaari "); MODULE_DESCRIPTION("Driver for Alcor Micro AU6610 DVB-T USB2.0"); diff --git a/drivers/media/dvb/dvb-usb/az6027.c b/drivers/media/dvb/dvb-usb/az6027.c index bf67b4d..5e45ae6 100644 --- a/drivers/media/dvb/dvb-usb/az6027.c +++ b/drivers/media/dvb/dvb-usb/az6027.c @@ -1174,28 +1174,7 @@ static struct usb_driver az6027_usb_driver = { .id_table = az6027_usb_table, }; -/* module stuff */ -static int __init az6027_usb_module_init(void) -{ - int result; - - result = usb_register(&az6027_usb_driver); - if (result) { - err("usb_register failed. (%d)", result); - return result; - } - - return 0; -} - -static void __exit az6027_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&az6027_usb_driver); -} - -module_init(az6027_usb_module_init); -module_exit(az6027_usb_module_exit); +module_usb_driver(az6027_usb_driver); MODULE_AUTHOR("Adams Xu "); MODULE_DESCRIPTION("Driver for AZUREWAVE DVB-S/S2 USB2.0 (AZ6027)"); diff --git a/drivers/media/dvb/dvb-usb/ce6230.c b/drivers/media/dvb/dvb-usb/ce6230.c index 57afb5a..fa63725 100644 --- a/drivers/media/dvb/dvb-usb/ce6230.c +++ b/drivers/media/dvb/dvb-usb/ce6230.c @@ -317,27 +317,7 @@ static struct usb_driver ce6230_driver = { .id_table = ce6230_table, }; -/* module stuff */ -static int __init ce6230_module_init(void) -{ - int ret; - deb_info("%s:\n", __func__); - ret = usb_register(&ce6230_driver); - if (ret) - err("usb_register failed with error:%d", ret); - - return ret; -} - -static void __exit ce6230_module_exit(void) -{ - deb_info("%s:\n", __func__); - /* deregister this driver from the USB subsystem */ - usb_deregister(&ce6230_driver); -} - -module_init(ce6230_module_init); -module_exit(ce6230_module_exit); +module_usb_driver(ce6230_driver); MODULE_AUTHOR("Antti Palosaari "); MODULE_DESCRIPTION("Driver for Intel CE6230 DVB-T USB2.0"); diff --git a/drivers/media/dvb/dvb-usb/cinergyT2-core.c b/drivers/media/dvb/dvb-usb/cinergyT2-core.c index f9d9050..0a98548 100644 --- a/drivers/media/dvb/dvb-usb/cinergyT2-core.c +++ b/drivers/media/dvb/dvb-usb/cinergyT2-core.c @@ -247,25 +247,7 @@ static struct usb_driver cinergyt2_driver = { .id_table = cinergyt2_usb_table }; -static int __init cinergyt2_usb_init(void) -{ - int err; - - err = usb_register(&cinergyt2_driver); - if (err) { - err("usb_register() failed! (err %i)\n", err); - return err; - } - return 0; -} - -static void __exit cinergyt2_usb_exit(void) -{ - usb_deregister(&cinergyt2_driver); -} - -module_init(cinergyt2_usb_init); -module_exit(cinergyt2_usb_exit); +module_usb_driver(cinergyt2_driver); MODULE_DESCRIPTION("Terratec Cinergy T2 DVB-T driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 9f2a02c..949ea1b 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -2034,26 +2034,7 @@ static struct usb_driver cxusb_driver = { .id_table = cxusb_table, }; -/* module stuff */ -static int __init cxusb_module_init(void) -{ - int result; - if ((result = usb_register(&cxusb_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit cxusb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&cxusb_driver); -} - -module_init (cxusb_module_init); -module_exit (cxusb_module_exit); +module_usb_driver(cxusb_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_AUTHOR("Michael Krufky "); diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c index 156cbfc..2069994 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_core.c +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c @@ -832,27 +832,7 @@ static struct usb_driver dib0700_driver = { .id_table = dib0700_usb_id_table, }; -/* module stuff */ -static int __init dib0700_module_init(void) -{ - int result; - info("loaded with support for %d different device-types", dib0700_device_count); - if ((result = usb_register(&dib0700_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit dib0700_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&dib0700_driver); -} - -module_init (dib0700_module_init); -module_exit (dib0700_module_exit); +module_usb_driver(dib0700_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for devices based on DiBcom DiB0700 - USB bridge"); diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 7270791..a4ac37e 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -463,26 +463,7 @@ static struct usb_driver dibusb_driver = { .id_table = dibusb_dib3000mb_table, }; -/* module stuff */ -static int __init dibusb_module_init(void) -{ - int result; - if ((result = usb_register(&dibusb_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit dibusb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&dibusb_driver); -} - -module_init (dibusb_module_init); -module_exit (dibusb_module_exit); +module_usb_driver(dibusb_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for DiBcom USB DVB-T devices (DiB3000M-B based)"); diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index 9c165e2..9d1a59d0 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c @@ -141,26 +141,7 @@ static struct usb_driver dibusb_mc_driver = { .id_table = dibusb_dib3000mc_table, }; -/* module stuff */ -static int __init dibusb_mc_module_init(void) -{ - int result; - if ((result = usb_register(&dibusb_mc_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit dibusb_mc_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&dibusb_mc_driver); -} - -module_init (dibusb_mc_module_init); -module_exit (dibusb_mc_module_exit); +module_usb_driver(dibusb_mc_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for DiBcom USB2.0 DVB-T (DiB3000M-C/P based) devices"); diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index f718411..0a9a798 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -346,26 +346,7 @@ static struct usb_driver digitv_driver = { .id_table = digitv_table, }; -/* module stuff */ -static int __init digitv_module_init(void) -{ - int result; - if ((result = usb_register(&digitv_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit digitv_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&digitv_driver); -} - -module_init (digitv_module_init); -module_exit (digitv_module_exit); +module_usb_driver(digitv_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for Nebula Electronics uDigiTV DVB-T USB2.0"); diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index 106dfd5..66f205c 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -360,26 +360,7 @@ static struct usb_driver dtt200u_usb_driver = { .id_table = dtt200u_usb_table, }; -/* module stuff */ -static int __init dtt200u_usb_module_init(void) -{ - int result; - if ((result = usb_register(&dtt200u_usb_driver))) { - err("usb_register failed. (%d)",result); - return result; - } - - return 0; -} - -static void __exit dtt200u_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&dtt200u_usb_driver); -} - -module_init(dtt200u_usb_module_init); -module_exit(dtt200u_usb_module_exit); +module_usb_driver(dtt200u_usb_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D/Miglia DVB-T USB2.0 devices"); diff --git a/drivers/media/dvb/dvb-usb/dtv5100.c b/drivers/media/dvb/dvb-usb/dtv5100.c index 7373132..3d11df4 100644 --- a/drivers/media/dvb/dvb-usb/dtv5100.c +++ b/drivers/media/dvb/dvb-usb/dtv5100.c @@ -217,26 +217,7 @@ static struct usb_driver dtv5100_driver = { .id_table = dtv5100_table, }; -/* module stuff */ -static int __init dtv5100_module_init(void) -{ - int ret; - - ret = usb_register(&dtv5100_driver); - if (ret) - err("usb_register failed. Error number %d", ret); - - return ret; -} - -static void __exit dtv5100_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&dtv5100_driver); -} - -module_init(dtv5100_module_init); -module_exit(dtv5100_module_exit); +module_usb_driver(dtv5100_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/media/dvb/dvb-usb/dw2102.c b/drivers/media/dvb/dvb-usb/dw2102.c index f103ec1..ff941d2 100644 --- a/drivers/media/dvb/dvb-usb/dw2102.c +++ b/drivers/media/dvb/dvb-usb/dw2102.c @@ -1928,22 +1928,7 @@ static struct usb_driver dw2102_driver = { .id_table = dw2102_table, }; -static int __init dw2102_module_init(void) -{ - int ret = usb_register(&dw2102_driver); - if (ret) - err("usb_register failed. Error number %d", ret); - - return ret; -} - -static void __exit dw2102_module_exit(void) -{ - usb_deregister(&dw2102_driver); -} - -module_init(dw2102_module_init); -module_exit(dw2102_module_exit); +module_usb_driver(dw2102_driver); MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by"); MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," diff --git a/drivers/media/dvb/dvb-usb/ec168.c b/drivers/media/dvb/dvb-usb/ec168.c index 78442fe..b4989ba 100644 --- a/drivers/media/dvb/dvb-usb/ec168.c +++ b/drivers/media/dvb/dvb-usb/ec168.c @@ -428,27 +428,7 @@ static struct usb_driver ec168_driver = { .id_table = ec168_id, }; -/* module stuff */ -static int __init ec168_module_init(void) -{ - int ret; - deb_info("%s:\n", __func__); - ret = usb_register(&ec168_driver); - if (ret) - err("module init failed:%d", ret); - - return ret; -} - -static void __exit ec168_module_exit(void) -{ - deb_info("%s:\n", __func__); - /* deregister this driver from the USB subsystem */ - usb_deregister(&ec168_driver); -} - -module_init(ec168_module_init); -module_exit(ec168_module_exit); +module_usb_driver(ec168_driver); MODULE_AUTHOR("Antti Palosaari "); MODULE_DESCRIPTION("E3C EC168 DVB-T USB2.0 driver"); diff --git a/drivers/media/dvb/dvb-usb/friio.c b/drivers/media/dvb/dvb-usb/friio.c index b092dc2..474a17e 100644 --- a/drivers/media/dvb/dvb-usb/friio.c +++ b/drivers/media/dvb/dvb-usb/friio.c @@ -514,28 +514,7 @@ static struct usb_driver friio_driver = { .id_table = friio_table, }; - -/* module stuff */ -static int __init friio_module_init(void) -{ - int ret; - - ret = usb_register(&friio_driver); - if (ret) - err("usb_register failed. Error number %d", ret); - - return ret; -} - - -static void __exit friio_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&friio_driver); -} - -module_init(friio_module_init); -module_exit(friio_module_exit); +module_usb_driver(friio_driver); MODULE_AUTHOR("Akihiro Tsukada "); MODULE_DESCRIPTION("Driver for Friio ISDB-T USB2.0 Receiver"); diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c index 63681df..c1f5582 100644 --- a/drivers/media/dvb/dvb-usb/gl861.c +++ b/drivers/media/dvb/dvb-usb/gl861.c @@ -209,26 +209,7 @@ static struct usb_driver gl861_driver = { .id_table = gl861_table, }; -/* module stuff */ -static int __init gl861_module_init(void) -{ - int ret; - - ret = usb_register(&gl861_driver); - if (ret) - err("usb_register failed. Error number %d", ret); - - return ret; -} - -static void __exit gl861_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&gl861_driver); -} - -module_init(gl861_module_init); -module_exit(gl861_module_exit); +module_usb_driver(gl861_driver); MODULE_AUTHOR("Carl Lundqvist "); MODULE_DESCRIPTION("Driver MSI Mega Sky 580 DVB-T USB2.0 / GL861"); diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c index 5f71284..5d0384d 100644 --- a/drivers/media/dvb/dvb-usb/gp8psk.c +++ b/drivers/media/dvb/dvb-usb/gp8psk.c @@ -320,26 +320,7 @@ static struct usb_driver gp8psk_usb_driver = { .id_table = gp8psk_usb_table, }; -/* module stuff */ -static int __init gp8psk_usb_module_init(void) -{ - int result; - if ((result = usb_register(&gp8psk_usb_driver))) { - err("usb_register failed. (%d)",result); - return result; - } - - return 0; -} - -static void __exit gp8psk_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&gp8psk_usb_driver); -} - -module_init(gp8psk_usb_module_init); -module_exit(gp8psk_usb_module_exit); +module_usb_driver(gp8psk_usb_driver); MODULE_AUTHOR("Alan Nisota "); MODULE_DESCRIPTION("Driver for Genpix DVB-S"); diff --git a/drivers/media/dvb/dvb-usb/it913x.c b/drivers/media/dvb/dvb-usb/it913x.c index c462261..67094b8 100644 --- a/drivers/media/dvb/dvb-usb/it913x.c +++ b/drivers/media/dvb/dvb-usb/it913x.c @@ -675,26 +675,7 @@ static struct usb_driver it913x_driver = { .id_table = it913x_table, }; -/* module stuff */ -static int __init it913x_module_init(void) -{ - int result = usb_register(&it913x_driver); - if (result) { - err("usb_register failed. Error number %d", result); - return result; - } - - return 0; -} - -static void __exit it913x_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&it913x_driver); -} - -module_init(it913x_module_init); -module_exit(it913x_module_exit); +module_usb_driver(it913x_driver); MODULE_AUTHOR("Malcolm Priestley "); MODULE_DESCRIPTION("it913x USB 2 Driver"); diff --git a/drivers/media/dvb/dvb-usb/lmedm04.c b/drivers/media/dvb/dvb-usb/lmedm04.c index b922824..1a876a6 100644 --- a/drivers/media/dvb/dvb-usb/lmedm04.c +++ b/drivers/media/dvb/dvb-usb/lmedm04.c @@ -1289,26 +1289,7 @@ static struct usb_driver lme2510_driver = { .id_table = lme2510_table, }; -/* module stuff */ -static int __init lme2510_module_init(void) -{ - int result = usb_register(&lme2510_driver); - if (result) { - err("usb_register failed. Error number %d", result); - return result; - } - - return 0; -} - -static void __exit lme2510_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&lme2510_driver); -} - -module_init(lme2510_module_init); -module_exit(lme2510_module_exit); +module_usb_driver(lme2510_driver); MODULE_AUTHOR("Malcolm Priestley "); MODULE_DESCRIPTION("LME2510(C) DVB-S USB2.0"); diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c index a1e1287..288af29 100644 --- a/drivers/media/dvb/dvb-usb/m920x.c +++ b/drivers/media/dvb/dvb-usb/m920x.c @@ -1086,27 +1086,7 @@ static struct usb_driver m920x_driver = { .id_table = m920x_table, }; -/* module stuff */ -static int __init m920x_module_init(void) -{ - int ret; - - if ((ret = usb_register(&m920x_driver))) { - err("usb_register failed. Error number %d", ret); - return ret; - } - - return 0; -} - -static void __exit m920x_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&m920x_driver); -} - -module_init (m920x_module_init); -module_exit (m920x_module_exit); +module_usb_driver(m920x_driver); MODULE_AUTHOR("Aapo Tahkola "); MODULE_DESCRIPTION("DVB Driver for ULI M920x"); diff --git a/drivers/media/dvb/dvb-usb/mxl111sf.c b/drivers/media/dvb/dvb-usb/mxl111sf.c index b5c98da..825a8b2 100644 --- a/drivers/media/dvb/dvb-usb/mxl111sf.c +++ b/drivers/media/dvb/dvb-usb/mxl111sf.c @@ -1055,24 +1055,7 @@ static struct usb_driver mxl111sf_driver = { .id_table = mxl111sf_table, }; -static int __init mxl111sf_module_init(void) -{ - int result = usb_register(&mxl111sf_driver); - if (result) { - err("usb_register failed. Error number %d", result); - return result; - } - - return 0; -} - -static void __exit mxl111sf_module_exit(void) -{ - usb_deregister(&mxl111sf_driver); -} - -module_init(mxl111sf_module_init); -module_exit(mxl111sf_module_exit); +module_usb_driver(mxl111sf_driver); MODULE_AUTHOR("Michael Krufky "); MODULE_DESCRIPTION("Driver for MaxLinear MxL111SF"); diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 21384da..6c55384 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c @@ -225,26 +225,7 @@ static struct usb_driver nova_t_driver = { .id_table = nova_t_table, }; -/* module stuff */ -static int __init nova_t_module_init(void) -{ - int result; - if ((result = usb_register(&nova_t_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit nova_t_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&nova_t_driver); -} - -module_init (nova_t_module_init); -module_exit (nova_t_module_exit); +module_usb_driver(nova_t_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2"); diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c index 98fd9a6..c8a9504 100644 --- a/drivers/media/dvb/dvb-usb/opera1.c +++ b/drivers/media/dvb/dvb-usb/opera1.c @@ -574,22 +574,7 @@ static struct usb_driver opera1_driver = { .id_table = opera1_table, }; -static int __init opera1_module_init(void) -{ - int result = 0; - if ((result = usb_register(&opera1_driver))) { - err("usb_register failed. Error number %d", result); - } - return result; -} - -static void __exit opera1_module_exit(void) -{ - usb_deregister(&opera1_driver); -} - -module_init(opera1_module_init); -module_exit(opera1_module_exit); +module_usb_driver(opera1_driver); MODULE_AUTHOR("Mario Hlawitschka (c) dh1pa@amsat.org"); MODULE_AUTHOR("Marco Gittler (c) g.marco@freenet.de"); diff --git a/drivers/media/dvb/dvb-usb/pctv452e.c b/drivers/media/dvb/dvb-usb/pctv452e.c index f9aec5c..f526eb0 100644 --- a/drivers/media/dvb/dvb-usb/pctv452e.c +++ b/drivers/media/dvb/dvb-usb/pctv452e.c @@ -1055,22 +1055,7 @@ static struct usb_driver pctv452e_usb_driver = { .id_table = pctv452e_usb_table, }; -static int __init pctv452e_usb_init(void) -{ - int ret = usb_register(&pctv452e_usb_driver); - if (ret) - err("%s: usb_register failed! Error %d", __FILE__, ret); - - return ret; -} - -static void __exit pctv452e_usb_exit(void) -{ - usb_deregister(&pctv452e_usb_driver); -} - -module_init(pctv452e_usb_init); -module_exit(pctv452e_usb_exit); +module_usb_driver(pctv452e_usb_driver); MODULE_AUTHOR("Dominik Kuhlen "); MODULE_AUTHOR("Andre Weidemann "); diff --git a/drivers/media/dvb/dvb-usb/technisat-usb2.c b/drivers/media/dvb/dvb-usb/technisat-usb2.c index 0998fe9..acefaa8 100644 --- a/drivers/media/dvb/dvb-usb/technisat-usb2.c +++ b/drivers/media/dvb/dvb-usb/technisat-usb2.c @@ -781,25 +781,7 @@ static struct usb_driver technisat_usb2_driver = { .id_table = technisat_usb2_id_table, }; -/* module stuff */ -static int __init technisat_usb2_module_init(void) -{ - int result = usb_register(&technisat_usb2_driver); - if (result) { - err("usb_register failed. Code %d", result); - return result; - } - - return 0; -} - -static void __exit technisat_usb2_module_exit(void) -{ - usb_deregister(&technisat_usb2_driver); -} - -module_init(technisat_usb2_module_init); -module_exit(technisat_usb2_module_exit); +module_usb_driver(technisat_usb2_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for Technisat DVB-S/S2 USB 2.0 device"); diff --git a/drivers/media/dvb/dvb-usb/ttusb2.c b/drivers/media/dvb/dvb-usb/ttusb2.c index ea4eab8..56acf8e 100644 --- a/drivers/media/dvb/dvb-usb/ttusb2.c +++ b/drivers/media/dvb/dvb-usb/ttusb2.c @@ -799,26 +799,7 @@ static struct usb_driver ttusb2_driver = { .id_table = ttusb2_table, }; -/* module stuff */ -static int __init ttusb2_module_init(void) -{ - int result; - if ((result = usb_register(&ttusb2_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit ttusb2_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&ttusb2_driver); -} - -module_init (ttusb2_module_init); -module_exit (ttusb2_module_exit); +module_usb_driver(ttusb2_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0"); diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 463673a..9b04229 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c @@ -143,26 +143,7 @@ static struct usb_driver umt_driver = { .id_table = umt_table, }; -/* module stuff */ -static int __init umt_module_init(void) -{ - int result; - if ((result = usb_register(&umt_driver))) { - err("usb_register failed. Error number %d",result); - return result; - } - - return 0; -} - -static void __exit umt_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&umt_driver); -} - -module_init (umt_module_init); -module_exit (umt_module_exit); +module_usb_driver(umt_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device"); diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 45e31f2..07c673a 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -436,26 +436,7 @@ static struct usb_driver vp702x_usb_driver = { .id_table = vp702x_usb_table, }; -/* module stuff */ -static int __init vp702x_usb_module_init(void) -{ - int result; - if ((result = usb_register(&vp702x_usb_driver))) { - err("usb_register failed. (%d)",result); - return result; - } - - return 0; -} - -static void __exit vp702x_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&vp702x_usb_driver); -} - -module_init(vp702x_usb_module_init); -module_exit(vp702x_usb_module_exit); +module_usb_driver(vp702x_usb_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones"); diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 90873af..d750724 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -294,26 +294,7 @@ static struct usb_driver vp7045_usb_driver = { .id_table = vp7045_usb_table, }; -/* module stuff */ -static int __init vp7045_usb_module_init(void) -{ - int result; - if ((result = usb_register(&vp7045_usb_driver))) { - err("usb_register failed. (%d)",result); - return result; - } - - return 0; -} - -static void __exit vp7045_usb_module_exit(void) -{ - /* deregister this driver from the USB subsystem */ - usb_deregister(&vp7045_usb_driver); -} - -module_init(vp7045_usb_module_init); -module_exit(vp7045_usb_module_exit); +module_usb_driver(vp7045_usb_driver); MODULE_AUTHOR("Patrick Boettcher "); MODULE_DESCRIPTION("Driver for Twinhan MagicBox/Alpha and DNTV tinyUSB2 DVB-T USB2.0"); diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c index 51c7121..b1fe513 100644 --- a/drivers/media/dvb/siano/smsusb.c +++ b/drivers/media/dvb/siano/smsusb.c @@ -557,26 +557,7 @@ static struct usb_driver smsusb_driver = { .resume = smsusb_resume, }; -static int __init smsusb_module_init(void) -{ - int rc = usb_register(&smsusb_driver); - if (rc) - sms_err("usb_register failed. Error number %d", rc); - - sms_debug(""); - - return rc; -} - -static void __exit smsusb_module_exit(void) -{ - /* Regular USB Cleanup */ - usb_deregister(&smsusb_driver); - sms_info("end"); -} - -module_init(smsusb_module_init); -module_exit(smsusb_module_exit); +module_usb_driver(smsusb_driver); MODULE_DESCRIPTION("Driver for the Siano SMS1xxx USB dongle"); MODULE_AUTHOR("Siano Mobile Silicon, INC. (uris@siano-ms.com)"); diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 420bb42..e90192f 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c @@ -1794,26 +1794,7 @@ static struct usb_driver ttusb_driver = { .id_table = ttusb_table, }; -static int __init ttusb_init(void) -{ - int err; - - if ((err = usb_register(&ttusb_driver)) < 0) { - printk("%s: usb_register failed! Error number %d", - __FILE__, err); - return err; - } - - return 0; -} - -static void __exit ttusb_exit(void) -{ - usb_deregister(&ttusb_driver); -} - -module_init(ttusb_init); -module_exit(ttusb_exit); +module_usb_driver(ttusb_driver); MODULE_AUTHOR("Holger Waechtler "); MODULE_DESCRIPTION("TTUSB DVB Driver"); diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index f893bff..504c812 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c @@ -1756,26 +1756,7 @@ static struct usb_driver ttusb_dec_driver = { .id_table = ttusb_dec_table, }; -static int __init ttusb_dec_init(void) -{ - int result; - - if ((result = usb_register(&ttusb_dec_driver)) < 0) { - printk("%s: initialisation failed: error %d.\n", __func__, - result); - return result; - } - - return 0; -} - -static void __exit ttusb_dec_exit(void) -{ - usb_deregister(&ttusb_dec_driver); -} - -module_init(ttusb_dec_init); -module_exit(ttusb_dec_exit); +module_usb_driver(ttusb_dec_driver); MODULE_AUTHOR("Alex Woods "); MODULE_DESCRIPTION(DRIVER_NAME); diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 25e58cb..f36905b 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c @@ -624,21 +624,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf, return 0; } -static int __init dsbr100_init(void) -{ - int retval = usb_register(&usb_dsbr100_driver); - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return retval; -} - -static void __exit dsbr100_exit(void) -{ - usb_deregister(&usb_dsbr100_driver); -} - -module_init (dsbr100_init); -module_exit (dsbr100_exit); +module_usb_driver(usb_dsbr100_driver); MODULE_AUTHOR( DRIVER_AUTHOR ); MODULE_DESCRIPTION( DRIVER_DESC ); diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 1742bd8..a860a72 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -659,25 +659,4 @@ err: return retval; } -static int __init amradio_init(void) -{ - int retval = usb_register(&usb_amradio_driver); - - pr_info(KBUILD_MODNAME - ": version " DRIVER_VERSION " " DRIVER_DESC "\n"); - - if (retval) - pr_err(KBUILD_MODNAME - ": usb_register failed. Error number %d\n", retval); - - return retval; -} - -static void __exit amradio_exit(void) -{ - usb_deregister(&usb_amradio_driver); -} - -module_init(amradio_init); -module_exit(amradio_exit); - +module_usb_driver(usb_amradio_driver); diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c index a6ad707..b7debb6 100644 --- a/drivers/media/radio/si470x/radio-si470x-usb.c +++ b/drivers/media/radio/si470x/radio-si470x-usb.c @@ -861,33 +861,7 @@ static struct usb_driver si470x_usb_driver = { .supports_autosuspend = 1, }; - - -/************************************************************************** - * Module Interface - **************************************************************************/ - -/* - * si470x_module_init - module init - */ -static int __init si470x_module_init(void) -{ - printk(KERN_INFO DRIVER_DESC ", Version " DRIVER_VERSION "\n"); - return usb_register(&si470x_usb_driver); -} - - -/* - * si470x_module_exit - module exit - */ -static void __exit si470x_module_exit(void) -{ - usb_deregister(&si470x_usb_driver); -} - - -module_init(si470x_module_init); -module_exit(si470x_module_exit); +module_usb_driver(si470x_usb_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR(DRIVER_AUTHOR); diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c index 303f22e..4363bc3 100644 --- a/drivers/media/rc/ati_remote.c +++ b/drivers/media/rc/ati_remote.c @@ -908,38 +908,7 @@ static void ati_remote_disconnect(struct usb_interface *interface) kfree(ati_remote); } -/* - * ati_remote_init - */ -static int __init ati_remote_init(void) -{ - int result; - - result = usb_register(&ati_remote_driver); - if (result) - printk(KERN_ERR KBUILD_MODNAME - ": usb_register error #%d\n", result); - else - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - - return result; -} - -/* - * ati_remote_exit - */ -static void __exit ati_remote_exit(void) -{ - usb_deregister(&ati_remote_driver); -} - -/* - * module specification - */ - -module_init(ati_remote_init); -module_exit(ati_remote_exit); +module_usb_driver(ati_remote_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 6ed9646..3aeb29a 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -2458,23 +2458,4 @@ static int imon_resume(struct usb_interface *intf) return rc; } -static int __init imon_init(void) -{ - int rc; - - rc = usb_register(&imon_driver); - if (rc) { - pr_err("usb register failed(%d)\n", rc); - rc = -ENODEV; - } - - return rc; -} - -static void __exit imon_exit(void) -{ - usb_deregister(&imon_driver); -} - -module_init(imon_init); -module_exit(imon_exit); +module_usb_driver(imon_driver); diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 60d3c1e..20bb12d 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -1448,25 +1448,7 @@ static struct usb_driver mceusb_dev_driver = { .id_table = mceusb_dev_table }; -static int __init mceusb_dev_init(void) -{ - int ret; - - ret = usb_register(&mceusb_dev_driver); - if (ret < 0) - printk(KERN_ERR DRIVER_NAME - ": usb register failed, result = %d\n", ret); - - return ret; -} - -static void __exit mceusb_dev_exit(void) -{ - usb_deregister(&mceusb_dev_driver); -} - -module_init(mceusb_dev_init); -module_exit(mceusb_dev_exit); +module_usb_driver(mceusb_dev_driver); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_AUTHOR(DRIVER_AUTHOR); diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index 61287fc..07322fb 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c @@ -1300,25 +1300,7 @@ static struct usb_driver redrat3_dev_driver = { .id_table = redrat3_dev_table }; -static int __init redrat3_dev_init(void) -{ - int ret; - - ret = usb_register(&redrat3_dev_driver); - if (ret < 0) - pr_err(DRIVER_NAME - ": usb register failed, result = %d\n", ret); - - return ret; -} - -static void __exit redrat3_dev_exit(void) -{ - usb_deregister(&redrat3_dev_driver); -} - -module_init(redrat3_dev_init); -module_exit(redrat3_dev_exit); +module_usb_driver(redrat3_dev_driver); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_AUTHOR(DRIVER_AUTHOR); diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c index e435d94..b1d29d0 100644 --- a/drivers/media/rc/streamzap.c +++ b/drivers/media/rc/streamzap.c @@ -523,33 +523,7 @@ static int streamzap_resume(struct usb_interface *intf) return 0; } -/** - * streamzap_init - */ -static int __init streamzap_init(void) -{ - int ret; - - /* register this driver with the USB subsystem */ - ret = usb_register(&streamzap_driver); - if (ret < 0) - printk(KERN_ERR DRIVER_NAME ": usb register failed, " - "result = %d\n", ret); - - return ret; -} - -/** - * streamzap_exit - */ -static void __exit streamzap_exit(void) -{ - usb_deregister(&streamzap_driver); -} - - -module_init(streamzap_init); -module_exit(streamzap_exit); +module_usb_driver(streamzap_driver); MODULE_AUTHOR("Jarod Wilson "); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 53dae2a..60b021e 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c @@ -1385,26 +1385,4 @@ static struct usb_driver cx231xx_usb_driver = { .id_table = cx231xx_id_table, }; -static int __init cx231xx_module_init(void) -{ - int result; - - printk(KERN_INFO DRIVER_NAME " v4l2 driver loaded.\n"); - - /* register this driver with the USB subsystem */ - result = usb_register(&cx231xx_usb_driver); - if (result) - cx231xx_err(DRIVER_NAME - " usb_register failed. Error number %d.\n", result); - - return result; -} - -static void __exit cx231xx_module_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&cx231xx_usb_driver); -} - -module_init(cx231xx_module_init); -module_exit(cx231xx_module_exit); +module_usb_driver(cx231xx_usb_driver); diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 9b747c2..93807dc 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c @@ -3325,26 +3325,4 @@ static struct usb_driver em28xx_usb_driver = { .id_table = em28xx_id_table, }; -static int __init em28xx_module_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&em28xx_usb_driver); - if (result) - em28xx_err(DRIVER_NAME - " usb_register failed. Error number %d.\n", result); - - printk(KERN_INFO DRIVER_NAME " driver loaded\n"); - - return result; -} - -static void __exit em28xx_module_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&em28xx_usb_driver); -} - -module_init(em28xx_module_init); -module_exit(em28xx_module_exit); +module_usb_driver(em28xx_usb_driver); diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index d3777c8..40f214a 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c @@ -2680,27 +2680,4 @@ static struct usb_driver et61x251_usb_driver = { .disconnect = et61x251_usb_disconnect, }; -/*****************************************************************************/ - -static int __init et61x251_module_init(void) -{ - int err = 0; - - KDBG(2, ET61X251_MODULE_NAME " v" ET61X251_MODULE_VERSION); - KDBG(3, ET61X251_MODULE_AUTHOR); - - if ((err = usb_register(&et61x251_usb_driver))) - KDBG(1, "usb_register() failed"); - - return err; -} - - -static void __exit et61x251_module_exit(void) -{ - usb_deregister(&et61x251_usb_driver); -} - - -module_init(et61x251_module_init); -module_exit(et61x251_module_exit); +module_usb_driver(et61x251_usb_driver); diff --git a/drivers/media/video/gspca/benq.c b/drivers/media/video/gspca/benq.c index 6ae2616..636627b 100644 --- a/drivers/media/video/gspca/benq.c +++ b/drivers/media/video/gspca/benq.c @@ -288,15 +288,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c index 4c56dbe..ea17b5d 100644 --- a/drivers/media/video/gspca/conex.c +++ b/drivers/media/video/gspca/conex.c @@ -1067,15 +1067,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/cpia1.c b/drivers/media/video/gspca/cpia1.c index f9b86b2..8f33bbd 100644 --- a/drivers/media/video/gspca/cpia1.c +++ b/drivers/media/video/gspca/cpia1.c @@ -2132,15 +2132,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c index 0357d6d..81a4adb 100644 --- a/drivers/media/video/gspca/etoms.c +++ b/drivers/media/video/gspca/etoms.c @@ -895,16 +895,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c index ea48200..0107513 100644 --- a/drivers/media/video/gspca/finepix.c +++ b/drivers/media/video/gspca/finepix.c @@ -290,16 +290,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/gl860/gl860.c b/drivers/media/video/gspca/gl860/gl860.c index 2ced3b7..a8f54c2 100644 --- a/drivers/media/video/gspca/gl860/gl860.c +++ b/drivers/media/video/gspca/gl860/gl860.c @@ -524,22 +524,7 @@ static struct usb_driver sd_driver = { /*====================== Init and Exit module functions ====================*/ -static int __init sd_mod_init(void) -{ - PDEBUG(D_PROBE, "driver startup - version %s", DRIVER_VERSION); - - if (usb_register(&sd_driver) < 0) - return -1; - return 0; -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); /*==========================================================================*/ diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c index 8e3dabe..5ab3f7e 100644 --- a/drivers/media/video/gspca/jeilinj.c +++ b/drivers/media/video/gspca/jeilinj.c @@ -582,16 +582,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/kinect.c b/drivers/media/video/gspca/kinect.c index 4fe51fd..e8e8f2f 100644 --- a/drivers/media/video/gspca/kinect.c +++ b/drivers/media/video/gspca/kinect.c @@ -413,16 +413,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/konica.c b/drivers/media/video/gspca/konica.c index f3f7fe0..b1da7f4 100644 --- a/drivers/media/video/gspca/konica.c +++ b/drivers/media/video/gspca/konica.c @@ -634,15 +634,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c index 67533e5..9fe3816b 100644 --- a/drivers/media/video/gspca/m5602/m5602_core.c +++ b/drivers/media/video/gspca/m5602/m5602_core.c @@ -404,19 +404,7 @@ static struct usb_driver sd_driver = { .disconnect = m5602_disconnect }; -/* -- module insert / remove -- */ -static int __init mod_m5602_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit mod_m5602_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(mod_m5602_init); -module_exit(mod_m5602_exit); +module_usb_driver(sd_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c index ef45fa5..5c2ea05c 100644 --- a/drivers/media/video/gspca/mars.c +++ b/drivers/media/video/gspca/mars.c @@ -517,15 +517,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c index 473e813..d73e5bd 100644 --- a/drivers/media/video/gspca/mr97310a.c +++ b/drivers/media/video/gspca/mr97310a.c @@ -1259,15 +1259,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/nw80x.c b/drivers/media/video/gspca/nw80x.c index 7681814..d4bec93 100644 --- a/drivers/media/video/gspca/nw80x.c +++ b/drivers/media/video/gspca/nw80x.c @@ -2118,18 +2118,7 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); module_param(webcam, int, 0644); MODULE_PARM_DESC(webcam, diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index 6a01b35..08b8ce1 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c @@ -5056,18 +5056,7 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); module_param(frame_rate, int, 0644); MODULE_PARM_DESC(frame_rate, "Frame rate (5, 10, 15, 20 or 30 fps)"); diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c index 76907ec..0475339 100644 --- a/drivers/media/video/gspca/ov534.c +++ b/drivers/media/video/gspca/ov534.c @@ -1533,16 +1533,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/ov534_9.c b/drivers/media/video/gspca/ov534_9.c index b3b1ea6..f30060d 100644 --- a/drivers/media/video/gspca/ov534_9.c +++ b/drivers/media/video/gspca/ov534_9.c @@ -1432,16 +1432,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c index 1600df1..ece8b1e 100644 --- a/drivers/media/video/gspca/pac207.c +++ b/drivers/media/video/gspca/pac207.c @@ -569,15 +569,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c index 1c44f78..2811195 100644 --- a/drivers/media/video/gspca/pac7302.c +++ b/drivers/media/video/gspca/pac7302.c @@ -1220,15 +1220,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index 7509d05..1ac1111 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c @@ -868,15 +868,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/se401.c b/drivers/media/video/gspca/se401.c index 3b71bbc..1494e18 100644 --- a/drivers/media/video/gspca/se401.c +++ b/drivers/media/video/gspca/se401.c @@ -766,15 +766,4 @@ static struct usb_driver sd_driver = { .post_reset = sd_post_reset, }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sn9c2028.c b/drivers/media/video/gspca/sn9c2028.c index 48aae39..478533c 100644 --- a/drivers/media/video/gspca/sn9c2028.c +++ b/drivers/media/video/gspca/sn9c2028.c @@ -737,16 +737,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c index 86e07a1..33cabc3 100644 --- a/drivers/media/video/gspca/sn9c20x.c +++ b/drivers/media/video/gspca/sn9c20x.c @@ -2554,15 +2554,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c index 146b459..ddb392d 100644 --- a/drivers/media/video/gspca/sonixb.c +++ b/drivers/media/video/gspca/sonixb.c @@ -1527,15 +1527,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index c746bf1..afa3186 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c @@ -3104,15 +3104,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca1528.c b/drivers/media/video/gspca/spca1528.c index 6956731..070b9c3 100644 --- a/drivers/media/video/gspca/spca1528.c +++ b/drivers/media/video/gspca/spca1528.c @@ -590,15 +590,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c index bb82c94..1039847 100644 --- a/drivers/media/video/gspca/spca500.c +++ b/drivers/media/video/gspca/spca500.c @@ -1092,15 +1092,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c index 7aaac72..9c16821 100644 --- a/drivers/media/video/gspca/spca501.c +++ b/drivers/media/video/gspca/spca501.c @@ -2188,15 +2188,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c index 16722dc..1320f35 100644 --- a/drivers/media/video/gspca/spca505.c +++ b/drivers/media/video/gspca/spca505.c @@ -815,15 +815,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c index 89fec4c..54eed87 100644 --- a/drivers/media/video/gspca/spca506.c +++ b/drivers/media/video/gspca/spca506.c @@ -714,21 +714,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - int ret; - ret = usb_register(&sd_driver); - if (ret < 0) - return ret; - PDEBUG(D_PROBE, "registered"); - return 0; -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); - PDEBUG(D_PROBE, "deregistered"); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c index a44fe3d..df4e169 100644 --- a/drivers/media/video/gspca/spca508.c +++ b/drivers/media/video/gspca/spca508.c @@ -1544,15 +1544,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c index c82fd53..259a0c7 100644 --- a/drivers/media/video/gspca/spca561.c +++ b/drivers/media/video/gspca/spca561.c @@ -1106,15 +1106,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c index df805f7..2fe3c29 100644 --- a/drivers/media/video/gspca/sq905.c +++ b/drivers/media/video/gspca/sq905.c @@ -432,16 +432,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c index c2c0560..ae78363 100644 --- a/drivers/media/video/gspca/sq905c.c +++ b/drivers/media/video/gspca/sq905c.c @@ -339,16 +339,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/sq930x.c b/drivers/media/video/gspca/sq930x.c index e4255b4..1a8ba9b 100644 --- a/drivers/media/video/gspca/sq930x.c +++ b/drivers/media/video/gspca/sq930x.c @@ -1197,15 +1197,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c index 42a7a28..4ae7cc8 100644 --- a/drivers/media/video/gspca/stk014.c +++ b/drivers/media/video/gspca/stk014.c @@ -519,15 +519,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/stv0680.c b/drivers/media/video/gspca/stv0680.c index 4dcc7e3..461ed64 100644 --- a/drivers/media/video/gspca/stv0680.c +++ b/drivers/media/video/gspca/stv0680.c @@ -355,15 +355,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c index b1fca7d..0ab425f 100644 --- a/drivers/media/video/gspca/stv06xx/stv06xx.c +++ b/drivers/media/video/gspca/stv06xx/stv06xx.c @@ -612,18 +612,7 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); module_param(dump_bridge, bool, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup"); diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c index c890977..c80f0c0 100644 --- a/drivers/media/video/gspca/sunplus.c +++ b/drivers/media/video/gspca/sunplus.c @@ -1211,15 +1211,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c index 90f0877..ea44deb 100644 --- a/drivers/media/video/gspca/t613.c +++ b/drivers/media/video/gspca/t613.c @@ -1438,15 +1438,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/topro.c b/drivers/media/video/gspca/topro.c index 29596c5..b2695b1 100644 --- a/drivers/media/video/gspca/topro.c +++ b/drivers/media/video/gspca/topro.c @@ -4971,18 +4971,7 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); module_param(force_sensor, int, 0644); MODULE_PARM_DESC(force_sensor, diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c index 933ef2c..c8922c5 100644 --- a/drivers/media/video/gspca/tv8532.c +++ b/drivers/media/video/gspca/tv8532.c @@ -418,16 +418,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c index 7ee2c82..208f6b2 100644 --- a/drivers/media/video/gspca/vc032x.c +++ b/drivers/media/video/gspca/vc032x.c @@ -4230,15 +4230,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/vicam.c b/drivers/media/video/gspca/vicam.c index 81dd4c9..d12ea15 100644 --- a/drivers/media/video/gspca/vicam.c +++ b/drivers/media/video/gspca/vicam.c @@ -368,16 +368,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/xirlink_cit.c b/drivers/media/video/gspca/xirlink_cit.c index 3aed42a..fbb6ed2 100644 --- a/drivers/media/video/gspca/xirlink_cit.c +++ b/drivers/media/video/gspca/xirlink_cit.c @@ -3325,15 +3325,4 @@ static struct usb_driver sd_driver = { #endif }; -/* -- module insert / remove -- */ -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index 30ea1e4..0202fea 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c @@ -7050,18 +7050,7 @@ static struct usb_driver sd_driver = { #endif }; -static int __init sd_mod_init(void) -{ - return usb_register(&sd_driver); -} - -static void __exit sd_mod_exit(void) -{ - usb_deregister(&sd_driver); -} - -module_init(sd_mod_init); -module_exit(sd_mod_exit); +module_usb_driver(sd_driver); module_param(force_sensor, int, 0644); MODULE_PARM_DESC(force_sensor, diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c index 441dacf..3f1a5b1 100644 --- a/drivers/media/video/hdpvr/hdpvr-core.c +++ b/drivers/media/video/hdpvr/hdpvr-core.c @@ -452,26 +452,7 @@ static struct usb_driver hdpvr_usb_driver = { .id_table = hdpvr_table, }; -static int __init hdpvr_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&hdpvr_usb_driver); - if (result) - err("usb_register failed. Error number %d", result); - - return result; -} - -static void __exit hdpvr_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&hdpvr_usb_driver); -} - -module_init(hdpvr_init); -module_exit(hdpvr_exit); +module_usb_driver(hdpvr_usb_driver); MODULE_LICENSE("GPL"); MODULE_VERSION("0.2.1"); diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index 803c9c8..c1bef61 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c @@ -2682,25 +2682,7 @@ static struct usb_driver s2255_driver = { .id_table = s2255_table, }; -static int __init usb_s2255_init(void) -{ - int result; - /* register this driver with the USB subsystem */ - result = usb_register(&s2255_driver); - if (result) - pr_err(KBUILD_MODNAME - ": usb_register failed. Error number %d\n", result); - dprintk(2, "%s\n", __func__); - return result; -} - -static void __exit usb_s2255_exit(void) -{ - usb_deregister(&s2255_driver); -} - -module_init(usb_s2255_init); -module_exit(usb_s2255_exit); +module_usb_driver(s2255_driver); MODULE_DESCRIPTION("Sensoray 2255 Video for Linux driver"); MODULE_AUTHOR("Dean Anderson (Sensoray Company Inc.)"); diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index 16cb07c5..7025be1 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c @@ -3420,27 +3420,4 @@ static struct usb_driver sn9c102_usb_driver = { .disconnect = sn9c102_usb_disconnect, }; -/*****************************************************************************/ - -static int __init sn9c102_module_init(void) -{ - int err = 0; - - KDBG(2, SN9C102_MODULE_NAME " v" SN9C102_MODULE_VERSION); - KDBG(3, SN9C102_MODULE_AUTHOR); - - if ((err = usb_register(&sn9c102_usb_driver))) - KDBG(1, "usb_register() failed"); - - return err; -} - - -static void __exit sn9c102_module_exit(void) -{ - usb_deregister(&sn9c102_usb_driver); -} - - -module_init(sn9c102_module_init); -module_exit(sn9c102_module_exit); +module_usb_driver(sn9c102_usb_driver); diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index cbc105f..b7fb5a5 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c @@ -1377,25 +1377,4 @@ static struct usb_driver stk_camera_driver = { #endif }; - -static int __init stk_camera_init(void) -{ - int result; - - result = usb_register(&stk_camera_driver); - if (result) - STK_ERROR("usb_register failed ! Error number %d\n", result); - - - return result; -} - -static void __exit stk_camera_exit(void) -{ - usb_deregister(&stk_camera_driver); -} - -module_init(stk_camera_init); -module_exit(stk_camera_exit); - - +module_usb_driver(stk_camera_driver); diff --git a/drivers/media/video/tm6000/tm6000-cards.c b/drivers/media/video/tm6000/tm6000-cards.c index ec2578a..ff939bc 100644 --- a/drivers/media/video/tm6000/tm6000-cards.c +++ b/drivers/media/video/tm6000/tm6000-cards.c @@ -1371,31 +1371,7 @@ static struct usb_driver tm6000_usb_driver = { .id_table = tm6000_id_table, }; -static int __init tm6000_module_init(void) -{ - int result; - - printk(KERN_INFO "tm6000" " v4l2 driver version %d.%d.%d loaded\n", - (TM6000_VERSION >> 16) & 0xff, - (TM6000_VERSION >> 8) & 0xff, TM6000_VERSION & 0xff); - - /* register this driver with the USB subsystem */ - result = usb_register(&tm6000_usb_driver); - if (result) - printk(KERN_ERR "tm6000" - " usb_register failed. Error number %d.\n", result); - - return result; -} - -static void __exit tm6000_module_exit(void) -{ - /* deregister at USB subsystem */ - usb_deregister(&tm6000_usb_driver); -} - -module_init(tm6000_module_init); -module_exit(tm6000_module_exit); +module_usb_driver(tm6000_usb_driver); MODULE_DESCRIPTION("Trident TVMaster TM5600/TM6000/TM6010 USB2 adapter"); MODULE_AUTHOR("Mauro Carvalho Chehab"); diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index e78cf94..cd2e39f 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c @@ -1695,28 +1695,7 @@ static struct usb_driver zr364xx_driver = { .id_table = device_table }; - -static int __init zr364xx_init(void) -{ - int retval; - retval = usb_register(&zr364xx_driver); - if (retval) - printk(KERN_ERR KBUILD_MODNAME ": usb_register failed!\n"); - else - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); - return retval; -} - - -static void __exit zr364xx_exit(void) -{ - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC " module unloaded\n"); - usb_deregister(&zr364xx_driver); -} - - -module_init(zr364xx_init); -module_exit(zr364xx_exit); +module_usb_driver(zr364xx_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- cgit v0.10.2 From 93f1508cffc3d578c2b7bbbf298dc52326b80777 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:47:34 -0800 Subject: USB: convert drivers/bluetooth/* to use module_usb_driver() This converts the drivers in drivers/bluetooth/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Marcel Holtmann Cc: "Gustavo F. Padovan" Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index 106beb1..cf77a9a 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c @@ -423,19 +423,7 @@ static struct usb_driver ath3k_driver = { .id_table = ath3k_table, }; -static int __init ath3k_init(void) -{ - BT_INFO("Atheros AR30xx firmware driver ver %s", VERSION); - return usb_register(&ath3k_driver); -} - -static void __exit ath3k_exit(void) -{ - usb_deregister(&ath3k_driver); -} - -module_init(ath3k_init); -module_exit(ath3k_exit); +module_usb_driver(ath3k_driver); MODULE_AUTHOR("Atheros Communications"); MODULE_DESCRIPTION("Atheros AR30xx firmware driver"); diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 54952ab..1e742a5 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -281,26 +281,7 @@ static struct usb_driver bcm203x_driver = { .id_table = bcm203x_table, }; -static int __init bcm203x_init(void) -{ - int err; - - BT_INFO("Broadcom Blutonium firmware driver ver %s", VERSION); - - err = usb_register(&bcm203x_driver); - if (err < 0) - BT_ERR("Failed to register USB driver"); - - return err; -} - -static void __exit bcm203x_exit(void) -{ - usb_deregister(&bcm203x_driver); -} - -module_init(bcm203x_init); -module_exit(bcm203x_exit); +module_usb_driver(bcm203x_driver); MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Broadcom Blutonium firmware driver ver " VERSION); diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 61b5914..e64a290 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -764,26 +764,7 @@ static struct usb_driver bfusb_driver = { .id_table = bfusb_table, }; -static int __init bfusb_init(void) -{ - int err; - - BT_INFO("BlueFRITZ! USB driver ver %s", VERSION); - - err = usb_register(&bfusb_driver); - if (err < 0) - BT_ERR("Failed to register BlueFRITZ! USB driver"); - - return err; -} - -static void __exit bfusb_exit(void) -{ - usb_deregister(&bfusb_driver); -} - -module_init(bfusb_init); -module_exit(bfusb_exit); +module_usb_driver(bfusb_driver); MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("BlueFRITZ! USB driver ver " VERSION); diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 751b338..6283160 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -521,20 +521,7 @@ static struct usb_driver bpa10x_driver = { .id_table = bpa10x_table, }; -static int __init bpa10x_init(void) -{ - BT_INFO("Digianswer Bluetooth USB driver ver %s", VERSION); - - return usb_register(&bpa10x_driver); -} - -static void __exit bpa10x_exit(void) -{ - usb_deregister(&bpa10x_driver); -} - -module_init(bpa10x_init); -module_exit(bpa10x_exit); +module_usb_driver(bpa10x_driver); MODULE_AUTHOR("Marcel Holtmann "); MODULE_DESCRIPTION("Digianswer Bluetooth USB driver ver " VERSION); diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index f9b7260..b0e6d8d 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1220,20 +1220,7 @@ static struct usb_driver btusb_driver = { .supports_autosuspend = 1, }; -static int __init btusb_init(void) -{ - BT_INFO("Generic Bluetooth USB driver ver %s", VERSION); - - return usb_register(&btusb_driver); -} - -static void __exit btusb_exit(void) -{ - usb_deregister(&btusb_driver); -} - -module_init(btusb_init); -module_exit(btusb_exit); +module_usb_driver(btusb_driver); module_param(ignore_dga, bool, 0644); MODULE_PARM_DESC(ignore_dga, "Ignore devices with id 08fd:0001"); -- cgit v0.10.2 From 08642e7c52cf43616821520828e504bc717e54a6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:48:31 -0800 Subject: USB: convert drivers/input/* to use module_usb_driver() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This converts the drivers in drivers/input/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Dmitry Torokhov Cc: Ville Syrjala Cc: Henk Vergonet Cc: Alessandro Rubini Cc: Henrik Rydberg Cc: "Magnus Hörlin" Cc: Chris Moeller Cc: Christoph Fritz Cc: Lucas De Marchi Cc: Jesper Juhl Cc: Edwin van Vliet Cc: Ping Cheng Cc: Eduard Hasenleithner Cc: Alexander Strakh Cc: Glenn Sommer Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index d728875..32bbd4c 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1041,18 +1041,7 @@ static struct usb_driver xpad_driver = { .id_table = xpad_table, }; -static int __init usb_xpad_init(void) -{ - return usb_register(&xpad_driver); -} - -static void __exit usb_xpad_exit(void) -{ - usb_deregister(&xpad_driver); -} - -module_init(usb_xpad_init); -module_exit(usb_xpad_exit); +module_usb_driver(xpad_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index 8d345e8..874a51c 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c @@ -1010,23 +1010,4 @@ static int ati_remote2_post_reset(struct usb_interface *interface) return r; } -static int __init ati_remote2_init(void) -{ - int r; - - r = usb_register(&ati_remote2_driver); - if (r) - printk(KERN_ERR "ati_remote2: usb_register() = %d\n", r); - else - printk(KERN_INFO "ati_remote2: " DRIVER_DESC " " DRIVER_VERSION "\n"); - - return r; -} - -static void __exit ati_remote2_exit(void) -{ - usb_deregister(&ati_remote2_driver); -} - -module_init(ati_remote2_init); -module_exit(ati_remote2_exit); +module_usb_driver(ati_remote2_driver); diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c index fc62256..d99151a 100644 --- a/drivers/input/misc/keyspan_remote.c +++ b/drivers/input/misc/keyspan_remote.c @@ -580,26 +580,7 @@ static struct usb_driver keyspan_driver = .id_table = keyspan_table }; -static int __init usb_keyspan_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&keyspan_driver); - if (result) - err("usb_register failed. Error number %d\n", result); - - return result; -} - -static void __exit usb_keyspan_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&keyspan_driver); -} - -module_init(usb_keyspan_init); -module_exit(usb_keyspan_exit); +module_usb_driver(keyspan_driver); MODULE_DEVICE_TABLE(usb, keyspan_table); MODULE_AUTHOR(DRIVER_AUTHOR); diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c index f459471..538f704 100644 --- a/drivers/input/misc/powermate.c +++ b/drivers/input/misc/powermate.c @@ -441,18 +441,7 @@ static struct usb_driver powermate_driver = { .id_table = powermate_devices, }; -static int __init powermate_init(void) -{ - return usb_register(&powermate_driver); -} - -static void __exit powermate_cleanup(void) -{ - usb_deregister(&powermate_driver); -} - -module_init(powermate_init); -module_exit(powermate_cleanup); +module_usb_driver(powermate_driver); MODULE_AUTHOR( "William R Sowerbutts" ); MODULE_DESCRIPTION( "Griffin Technology, Inc PowerMate driver" ); diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c index 41201c6..f4776e7 100644 --- a/drivers/input/misc/yealink.c +++ b/drivers/input/misc/yealink.c @@ -988,22 +988,7 @@ static struct usb_driver yealink_driver = { .id_table = usb_table, }; -static int __init yealink_dev_init(void) -{ - int ret = usb_register(&yealink_driver); - if (ret == 0) - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return ret; -} - -static void __exit yealink_dev_exit(void) -{ - usb_deregister(&yealink_driver); -} - -module_init(yealink_dev_init); -module_exit(yealink_dev_exit); +module_usb_driver(yealink_driver); MODULE_DEVICE_TABLE (usb, usb_table); diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index b77f999..0acbc7d 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c @@ -938,15 +938,4 @@ static struct usb_driver atp_driver = { .id_table = atp_table, }; -static int __init atp_init(void) -{ - return usb_register(&atp_driver); -} - -static void __exit atp_exit(void) -{ - usb_deregister(&atp_driver); -} - -module_init(atp_init); -module_exit(atp_exit); +module_usb_driver(atp_driver); diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index 5ec617e..cf87f8b 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c @@ -940,16 +940,4 @@ static struct usb_driver bcm5974_driver = { .supports_autosuspend = 1, }; -static int __init bcm5974_init(void) -{ - return usb_register(&bcm5974_driver); -} - -static void __exit bcm5974_exit(void) -{ - usb_deregister(&bcm5974_driver); -} - -module_init(bcm5974_init); -module_exit(bcm5974_exit); - +module_usb_driver(bcm5974_driver); diff --git a/drivers/input/tablet/acecad.c b/drivers/input/tablet/acecad.c index d94f7e9..f8b0b1d 100644 --- a/drivers/input/tablet/acecad.c +++ b/drivers/input/tablet/acecad.c @@ -269,19 +269,4 @@ static struct usb_driver usb_acecad_driver = { .id_table = usb_acecad_id_table, }; -static int __init usb_acecad_init(void) -{ - int result = usb_register(&usb_acecad_driver); - if (result == 0) - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return result; -} - -static void __exit usb_acecad_exit(void) -{ - usb_deregister(&usb_acecad_driver); -} - -module_init(usb_acecad_init); -module_exit(usb_acecad_exit); +module_usb_driver(usb_acecad_driver); diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c index 6d89fd1..d5ef3de 100644 --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c @@ -1919,21 +1919,7 @@ static struct usb_driver aiptek_driver = { .id_table = aiptek_ids, }; -static int __init aiptek_init(void) -{ - int result = usb_register(&aiptek_driver); - if (result == 0) { - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_AUTHOR "\n"); - } - return result; -} - -static void __exit aiptek_exit(void) -{ - usb_deregister(&aiptek_driver); -} +module_usb_driver(aiptek_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); @@ -1943,6 +1929,3 @@ module_param(programmableDelay, int, 0); MODULE_PARM_DESC(programmableDelay, "delay used during tablet programming"); module_param(jitterDelay, int, 0); MODULE_PARM_DESC(jitterDelay, "stylus/mouse settlement delay"); - -module_init(aiptek_init); -module_exit(aiptek_exit); diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c index 8ea6afe..89a2978 100644 --- a/drivers/input/tablet/gtco.c +++ b/drivers/input/tablet/gtco.c @@ -1022,33 +1022,7 @@ static struct usb_driver gtco_driverinfo_table = { .disconnect = gtco_disconnect, }; -/* - * Register this module with the USB subsystem - */ -static int __init gtco_init(void) -{ - int error; - - error = usb_register(>co_driverinfo_table); - if (error) { - err("usb_register() failed rc=0x%x", error); - return error; - } - - printk("GTCO usb driver version: %s", GTCO_VERSION); - return 0; -} - -/* - * Deregister this module with the USB subsystem - */ -static void __exit gtco_exit(void) -{ - usb_deregister(>co_driverinfo_table); -} - -module_init(gtco_init); -module_exit(gtco_exit); +module_usb_driver(gtco_driverinfo_table); MODULE_DESCRIPTION("GTCO digitizer USB driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/input/tablet/hanwang.c b/drivers/input/tablet/hanwang.c index 6504b62..b2db3cf 100644 --- a/drivers/input/tablet/hanwang.c +++ b/drivers/input/tablet/hanwang.c @@ -432,15 +432,4 @@ static struct usb_driver hanwang_driver = { .id_table = hanwang_ids, }; -static int __init hanwang_init(void) -{ - return usb_register(&hanwang_driver); -} - -static void __exit hanwang_exit(void) -{ - usb_deregister(&hanwang_driver); -} - -module_init(hanwang_init); -module_exit(hanwang_exit); +module_usb_driver(hanwang_driver); diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c index 290f4e5..85a5b40 100644 --- a/drivers/input/tablet/kbtab.c +++ b/drivers/input/tablet/kbtab.c @@ -198,22 +198,4 @@ static struct usb_driver kbtab_driver = { .id_table = kbtab_ids, }; -static int __init kbtab_init(void) -{ - int retval; - retval = usb_register(&kbtab_driver); - if (retval) - goto out; - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); -out: - return retval; -} - -static void __exit kbtab_exit(void) -{ - usb_deregister(&kbtab_driver); -} - -module_init(kbtab_init); -module_exit(kbtab_exit); +module_usb_driver(kbtab_driver); diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 1c1b7b4..8f9cde3 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -919,21 +919,4 @@ static struct usb_driver wacom_driver = { .supports_autosuspend = 1, }; -static int __init wacom_init(void) -{ - int result; - - result = usb_register(&wacom_driver); - if (result == 0) - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return result; -} - -static void __exit wacom_exit(void) -{ - usb_deregister(&wacom_driver); -} - -module_init(wacom_init); -module_exit(wacom_exit); +module_usb_driver(wacom_driver); diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 73fd664..e539d92 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -1580,18 +1580,7 @@ static struct usb_driver usbtouch_driver = { .supports_autosuspend = 1, }; -static int __init usbtouch_init(void) -{ - return usb_register(&usbtouch_driver); -} - -static void __exit usbtouch_cleanup(void) -{ - usb_deregister(&usbtouch_driver); -} - -module_init(usbtouch_init); -module_exit(usbtouch_cleanup); +module_usb_driver(usbtouch_driver); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); -- cgit v0.10.2 From 42f06a13445bffae96c5e42fdd721ef65fed6abf Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:49:34 -0800 Subject: USB: convert drivers/hid/* to use module_usb_driver() This converts the drivers in drivers/hid/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Jiri Kosina Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index 0658173..bc445d7 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c @@ -354,19 +354,4 @@ static struct usb_driver usb_kbd_driver = { .id_table = usb_kbd_id_table, }; -static int __init usb_kbd_init(void) -{ - int result = usb_register(&usb_kbd_driver); - if (result == 0) - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return result; -} - -static void __exit usb_kbd_exit(void) -{ - usb_deregister(&usb_kbd_driver); -} - -module_init(usb_kbd_init); -module_exit(usb_kbd_exit); +module_usb_driver(usb_kbd_driver); diff --git a/drivers/hid/usbhid/usbmouse.c b/drivers/hid/usbhid/usbmouse.c index 79b2bf8..0f6be45 100644 --- a/drivers/hid/usbhid/usbmouse.c +++ b/drivers/hid/usbhid/usbmouse.c @@ -241,19 +241,4 @@ static struct usb_driver usb_mouse_driver = { .id_table = usb_mouse_id_table, }; -static int __init usb_mouse_init(void) -{ - int retval = usb_register(&usb_mouse_driver); - if (retval == 0) - printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" - DRIVER_DESC "\n"); - return retval; -} - -static void __exit usb_mouse_exit(void) -{ - usb_deregister(&usb_mouse_driver); -} - -module_init(usb_mouse_init); -module_exit(usb_mouse_exit); +module_usb_driver(usb_mouse_driver); -- cgit v0.10.2 From 424f0750edd5af866f80f5e65998e0610503cb5c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:50:44 -0800 Subject: USB: convert sound/* to use module_usb_driver() This converts the drivers in sound/* to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Daniel Mack Cc: Clemens Ladisch Cc: Torsten Schenk Cc: Paul Gortmaker Cc: Karsten Wiese Signed-off-by: Greg Kroah-Hartman diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c index c7dca7b..ac2d5e1 100644 --- a/sound/usb/6fire/chip.c +++ b/sound/usb/6fire/chip.c @@ -211,22 +211,11 @@ static struct usb_device_id device_table[] = { MODULE_DEVICE_TABLE(usb, device_table); -static struct usb_driver driver = { +static struct usb_driver usb_driver = { .name = "snd-usb-6fire", .probe = usb6fire_chip_probe, .disconnect = usb6fire_chip_disconnect, .id_table = device_table, }; -static int __init usb6fire_chip_init(void) -{ - return usb_register(&driver); -} - -static void __exit usb6fire_chip_cleanup(void) -{ - usb_deregister(&driver); -} - -module_init(usb6fire_chip_init); -module_exit(usb6fire_chip_cleanup); +module_usb_driver(usb_driver); diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index 3eb605b..457fb27 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c @@ -538,16 +538,5 @@ static struct usb_driver snd_usb_driver = { .id_table = snd_usb_id_table, }; -static int __init snd_module_init(void) -{ - return usb_register(&snd_usb_driver); -} - -static void __exit snd_module_exit(void) -{ - usb_deregister(&snd_usb_driver); -} - -module_init(snd_module_init) -module_exit(snd_module_exit) +module_usb_driver(snd_usb_driver); diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c index c0609c2..4c11da9 100644 --- a/sound/usb/misc/ua101.c +++ b/sound/usb/misc/ua101.c @@ -1387,16 +1387,4 @@ static struct usb_driver ua101_driver = { #endif }; -static int __init alsa_card_ua101_init(void) -{ - return usb_register(&ua101_driver); -} - -static void __exit alsa_card_ua101_exit(void) -{ - usb_deregister(&ua101_driver); - mutex_destroy(&devices_mutex); -} - -module_init(alsa_card_ua101_init); -module_exit(alsa_card_ua101_exit); +module_usb_driver(ua101_driver); diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index 726c1a7..625f7ca 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -772,16 +772,4 @@ static struct usb_driver snd_us122l_usb_driver = { .supports_autosuspend = 1 }; - -static int __init snd_us122l_module_init(void) -{ - return usb_register(&snd_us122l_usb_driver); -} - -static void __exit snd_us122l_module_exit(void) -{ - usb_deregister(&snd_us122l_usb_driver); -} - -module_init(snd_us122l_module_init) -module_exit(snd_us122l_module_exit) +module_usb_driver(snd_us122l_usb_driver); diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index cbd37f2..0c738ed 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -459,15 +459,4 @@ static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr) } } -static int __init snd_usX2Y_module_init(void) -{ - return usb_register(&snd_usX2Y_usb_driver); -} - -static void __exit snd_usX2Y_module_exit(void) -{ - usb_deregister(&snd_usX2Y_usb_driver); -} - -module_init(snd_usX2Y_module_init) -module_exit(snd_usX2Y_module_exit) +module_usb_driver(snd_usX2Y_usb_driver); -- cgit v0.10.2 From fe7484834bb614c2c205726647635171ce6cc070 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Nov 2011 09:52:10 -0800 Subject: USB: convert some miscellanies drivers to use module_usb_driver() This converts the remaining USB drivers in the kernel to use the module_usb_driver() macro which makes the code smaller and a bit simpler. Added bonus is that it removes some unneeded kernel log messages about drivers loading and/or unloading. Cc: Guenter Roeck Cc: Jean Delvare Cc: Ben Dooks Cc: Till Harbaum Cc: Karsten Keil Cc: Chris Ball Cc: David Woodhouse Cc: Lauro Ramos Venancio Cc: Aloisio Almeida Jr Cc: Samuel Ortiz Cc: Steve Glendinning Cc: Florian Tobias Schandinat Cc: Evgeniy Polyakov Cc: Wim Van Sebroeck Cc: "David S. Miller" Cc: Jesper Juhl Cc: Artem Bityutskiy Cc: Jamie Iles Cc: Andrew Morton Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c index 7636671..7eb19a5 100644 --- a/drivers/i2c/busses/i2c-diolan-u2c.c +++ b/drivers/i2c/busses/i2c-diolan-u2c.c @@ -515,20 +515,7 @@ static struct usb_driver diolan_u2c_driver = { .id_table = diolan_u2c_table, }; -static int __init diolan_u2c_init(void) -{ - /* register this driver with the USB subsystem */ - return usb_register(&diolan_u2c_driver); -} - -static void __exit diolan_u2c_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&diolan_u2c_driver); -} - -module_init(diolan_u2c_init); -module_exit(diolan_u2c_exit); +module_usb_driver(diolan_u2c_driver); MODULE_AUTHOR("Guenter Roeck "); MODULE_DESCRIPTION(DRIVER_NAME " driver"); diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index d03b040..f07307f 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c @@ -262,20 +262,7 @@ static struct usb_driver i2c_tiny_usb_driver = { .id_table = i2c_tiny_usb_table, }; -static int __init usb_i2c_tiny_usb_init(void) -{ - /* register this driver with the USB subsystem */ - return usb_register(&i2c_tiny_usb_driver); -} - -static void __exit usb_i2c_tiny_usb_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&i2c_tiny_usb_driver); -} - -module_init(usb_i2c_tiny_usb_init); -module_exit(usb_i2c_tiny_usb_exit); +module_usb_driver(i2c_tiny_usb_driver); /* ----- end of usb layer ------------------------------------------------ */ diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c index 71a8eb6..0e1f4d5 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.c +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c @@ -2154,30 +2154,4 @@ static struct usb_driver hfcsusb_drv = { .disconnect = hfcsusb_disconnect, }; -static int __init -hfcsusb_init(void) -{ - printk(KERN_INFO DRIVER_NAME " driver Rev. %s debug(0x%x) poll(%i)\n", - hfcsusb_rev, debug, poll); - - if (usb_register(&hfcsusb_drv)) { - printk(KERN_INFO DRIVER_NAME - ": Unable to register hfcsusb module at usb stack\n"); - return -ENODEV; - } - - return 0; -} - -static void __exit -hfcsusb_cleanup(void) -{ - if (debug & DBG_HFC_CALL_TRACE) - printk(KERN_INFO DRIVER_NAME ": %s\n", __func__); - - /* unregister Hardware */ - usb_deregister(&hfcsusb_drv); /* release our driver */ -} - -module_init(hfcsusb_init); -module_exit(hfcsusb_cleanup); +module_usb_driver(hfcsusb_drv); diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c index f08f944..c0105a2 100644 --- a/drivers/mmc/host/ushc.c +++ b/drivers/mmc/host/ushc.c @@ -562,17 +562,7 @@ static struct usb_driver ushc_driver = { .disconnect = ushc_disconnect, }; -static int __init ushc_init(void) -{ - return usb_register(&ushc_driver); -} -module_init(ushc_init); - -static void __exit ushc_exit(void) -{ - usb_deregister(&ushc_driver); -} -module_exit(ushc_exit); +module_usb_driver(ushc_driver); MODULE_DESCRIPTION("USB SD Host Controller driver"); MODULE_AUTHOR("David Vrabel "); diff --git a/drivers/mtd/nand/alauda.c b/drivers/mtd/nand/alauda.c index eb40ea8..6a5ff64 100644 --- a/drivers/mtd/nand/alauda.c +++ b/drivers/mtd/nand/alauda.c @@ -717,17 +717,6 @@ static struct usb_driver alauda_driver = { .id_table = alauda_table, }; -static int __init alauda_init(void) -{ - return usb_register(&alauda_driver); -} - -static void __exit alauda_exit(void) -{ - usb_deregister(&alauda_driver); -} - -module_init(alauda_init); -module_exit(alauda_exit); +module_usb_driver(alauda_driver); MODULE_LICENSE("GPL"); diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index 7bcb1fe..bd02384 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -1597,24 +1597,7 @@ static struct usb_driver pn533_driver = { .id_table = pn533_table, }; -static int __init pn533_init(void) -{ - int rc; - - rc = usb_register(&pn533_driver); - if (rc) - err("usb_register failed. Error number %d", rc); - - return rc; -} - -static void __exit pn533_exit(void) -{ - usb_deregister(&pn533_driver); -} - -module_init(pn533_init); -module_exit(pn533_exit); +module_usb_driver(pn533_driver); MODULE_AUTHOR("Lauro Ramos Venancio ," " Aloisio Almeida Jr "); diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c index 2babcd4..66797e9 100644 --- a/drivers/uwb/hwa-rc.c +++ b/drivers/uwb/hwa-rc.c @@ -914,17 +914,7 @@ static struct usb_driver hwarc_driver = { .post_reset = hwarc_post_reset, }; -static int __init hwarc_driver_init(void) -{ - return usb_register(&hwarc_driver); -} -module_init(hwarc_driver_init); - -static void __exit hwarc_driver_exit(void) -{ - usb_deregister(&hwarc_driver); -} -module_exit(hwarc_driver_exit); +module_usb_driver(hwarc_driver); MODULE_AUTHOR("Inaky Perez-Gonzalez "); MODULE_DESCRIPTION("Host Wireless Adapter Radio Control Driver"); diff --git a/drivers/uwb/i1480/dfu/usb.c b/drivers/uwb/i1480/dfu/usb.c index ba86643..c8f6848 100644 --- a/drivers/uwb/i1480/dfu/usb.c +++ b/drivers/uwb/i1480/dfu/usb.c @@ -451,25 +451,7 @@ static struct usb_driver i1480_dfu_driver = { .disconnect = NULL, }; - -/* - * Initialize the i1480 DFU driver. - * - * We also need to register our function for guessing event sizes. - */ -static int __init i1480_dfu_driver_init(void) -{ - return usb_register(&i1480_dfu_driver); -} -module_init(i1480_dfu_driver_init); - - -static void __exit i1480_dfu_driver_exit(void) -{ - usb_deregister(&i1480_dfu_driver); -} -module_exit(i1480_dfu_driver_exit); - +module_usb_driver(i1480_dfu_driver); MODULE_AUTHOR("Inaky Perez-Gonzalez "); MODULE_DESCRIPTION("Intel Wireless UWB Link 1480 firmware uploader for USB"); diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c index aaccffa..3c22994 100644 --- a/drivers/video/smscufx.c +++ b/drivers/video/smscufx.c @@ -1792,24 +1792,7 @@ static struct usb_driver ufx_driver = { .id_table = id_table, }; -static int __init ufx_module_init(void) -{ - int res; - - res = usb_register(&ufx_driver); - if (res) - err("usb_register failed. Error number %d", res); - - return res; -} - -static void __exit ufx_module_exit(void) -{ - usb_deregister(&ufx_driver); -} - -module_init(ufx_module_init); -module_exit(ufx_module_exit); +module_usb_driver(ufx_driver); static void ufx_urb_completion(struct urb *urb) { diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c index 3473e75..1f868d0 100644 --- a/drivers/video/udlfb.c +++ b/drivers/video/udlfb.c @@ -1761,24 +1761,7 @@ static struct usb_driver dlfb_driver = { .id_table = id_table, }; -static int __init dlfb_module_init(void) -{ - int res; - - res = usb_register(&dlfb_driver); - if (res) - err("usb_register failed. Error number %d", res); - - return res; -} - -static void __exit dlfb_module_exit(void) -{ - usb_deregister(&dlfb_driver); -} - -module_init(dlfb_module_init); -module_exit(dlfb_module_exit); +module_usb_driver(dlfb_driver); static void dlfb_urb_completion(struct urb *urb) { diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c index b5abaae..4f7e1d7 100644 --- a/drivers/w1/masters/ds2490.c +++ b/drivers/w1/masters/ds2490.c @@ -1002,26 +1002,7 @@ static void ds_disconnect(struct usb_interface *intf) kfree(dev); } -static int ds_init(void) -{ - int err; - - err = usb_register(&ds_driver); - if (err) { - printk(KERN_INFO "Failed to register DS9490R USB device: err=%d.\n", err); - return err; - } - - return 0; -} - -static void ds_fini(void) -{ - usb_deregister(&ds_driver); -} - -module_init(ds_init); -module_exit(ds_fini); +module_usb_driver(ds_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Evgeniy Polyakov "); diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c index 748a74b..d8de1dd 100644 --- a/drivers/watchdog/pcwd_usb.c +++ b/drivers/watchdog/pcwd_usb.c @@ -827,37 +827,4 @@ static void usb_pcwd_disconnect(struct usb_interface *interface) printk(KERN_INFO PFX "USB PC Watchdog disconnected\n"); } - - -/** - * usb_pcwd_init - */ -static int __init usb_pcwd_init(void) -{ - int result; - - /* register this driver with the USB subsystem */ - result = usb_register(&usb_pcwd_driver); - if (result) { - printk(KERN_ERR PFX "usb_register failed. Error number %d\n", - result); - return result; - } - - printk(KERN_INFO PFX DRIVER_DESC " v" DRIVER_VERSION "\n"); - return 0; -} - - -/** - * usb_pcwd_exit - */ -static void __exit usb_pcwd_exit(void) -{ - /* deregister this driver with the USB subsystem */ - usb_deregister(&usb_pcwd_driver); -} - - -module_init(usb_pcwd_init); -module_exit(usb_pcwd_exit); +module_usb_driver(usb_pcwd_driver); -- cgit v0.10.2 From 1a087c6ad975bcc193b4bab2e9d61f9c6c547138 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Fri, 18 Nov 2011 14:50:21 +0100 Subject: debugfs: add tools to printk 32-bit registers Some debugfs file I deal with are mostly blocks of registers, i.e. lines of the form " = 0x". Some files are only registers, some include registers blocks among other material. This patch introduces data structures and functions to deal with both cases. I expect more users of this over time. Signed-off-by: Alessandro Rubini Acked-by: Giancarlo Asnaghi Cc: Felipe Balbi Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/filesystems/debugfs.txt b/Documentation/filesystems/debugfs.txt index 742cc06..f04066a 100644 --- a/Documentation/filesystems/debugfs.txt +++ b/Documentation/filesystems/debugfs.txt @@ -97,7 +97,8 @@ A read on the resulting file will yield either Y (for non-zero values) or N, followed by a newline. If written to, it will accept either upper- or lower-case values, or 1 or 0. Any other input will be silently ignored. -Finally, a block of arbitrary binary data can be exported with: +Another option is exporting a block of arbitrary binary data, with +this structure and function: struct debugfs_blob_wrapper { void *data; @@ -115,6 +116,35 @@ can be used to export binary information, but there does not appear to be any code which does so in the mainline. Note that all files created with debugfs_create_blob() are read-only. +If you want to dump a block of registers (something that happens quite +often during development, even if little such code reaches mainline. +Debugfs offers two functions: one to make a registers-only file, and +another to insert a register block in the middle of another sequential +file. + + struct debugfs_reg32 { + char *name; + unsigned long offset; + }; + + struct debugfs_regset32 { + struct debugfs_reg32 *regs; + int nregs; + void __iomem *base; + }; + + struct dentry *debugfs_create_regset32(const char *name, mode_t mode, + struct dentry *parent, + struct debugfs_regset32 *regset); + + int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, + int nregs, void __iomem *base, char *prefix); + +The "base" argument may be 0, but you may want to build the reg32 array +using __stringify, and a number of register names (macros) are actually +byte offsets over a base for the register block. + + There are a couple of other directory-oriented helper functions: struct dentry *debugfs_rename(struct dentry *old_dir, diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 90f7657..f31a27c 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -525,3 +526,92 @@ struct dentry *debugfs_create_blob(const char *name, mode_t mode, return debugfs_create_file(name, mode, parent, blob, &fops_blob); } EXPORT_SYMBOL_GPL(debugfs_create_blob); + +/* + * The regset32 stuff is used to print 32-bit registers using the + * seq_file utilities. We offer printing a register set in an already-opened + * sequential file or create a debugfs file that only prints a regset32. + */ + +/** + * debugfs_print_regs32 - use seq_print to describe a set of registers + * @s: the seq_file structure being used to generate output + * @regs: an array if struct debugfs_reg32 structures + * @mregs: the length of the above array + * @base: the base address to be used in reading the registers + * @prefix: a string to be prefixed to every output line + * + * This function outputs a text block describing the current values of + * some 32-bit hardware registers. It is meant to be used within debugfs + * files based on seq_file that need to show registers, intermixed with other + * information. The prefix argument may be used to specify a leading string, + * because some peripherals have several blocks of identical registers, + * for example configuration of dma channels + */ +int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, + int nregs, void __iomem *base, char *prefix) +{ + int i, ret = 0; + + for (i = 0; i < nregs; i++, regs++) { + if (prefix) + ret += seq_printf(s, "%s", prefix); + ret += seq_printf(s, "%s = 0x%08x\n", regs->name, + readl((void *)(base + regs->offset))); + } + return ret; +} +EXPORT_SYMBOL_GPL(debugfs_print_regs32); + +static int debugfs_show_regset32(struct seq_file *s, void *data) +{ + struct debugfs_regset32 *regset = s->private; + + debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, ""); + return 0; +} + +static int debugfs_open_regset32(struct inode *inode, struct file *file) +{ + return single_open(file, debugfs_show_regset32, inode->i_private); +} + +static const struct file_operations fops_regset32 = { + .open = debugfs_open_regset32, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +/** + * debugfs_create_regset32 - create a debugfs file that returns register values + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is %NULL, then the + * file will be created in the root of the debugfs filesystem. + * @regset: a pointer to a struct debugfs_regset32, which contains a pointer + * to an array of register definitions, the array size and the base + * address where the register bank is to be found. + * + * This function creates a file in debugfs with the given name that reports + * the names and values of a set of 32-bit registers. If the @mode variable + * is so set it can be read from. Writing is not supported. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the debugfs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, %NULL will be returned. + * + * If debugfs is not enabled in the kernel, the value -%ENODEV will be + * returned. It is not wise to check for this value, but rather, check for + * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling + * code. + */ +struct dentry *debugfs_create_regset32(const char *name, mode_t mode, + struct dentry *parent, + struct debugfs_regset32 *regset) +{ + return debugfs_create_file(name, mode, parent, regset, &fops_regset32); +} +EXPORT_SYMBOL_GPL(debugfs_create_regset32); diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index e7d9b20..5e6b01f 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -16,6 +16,7 @@ #define _DEBUGFS_H_ #include +#include #include @@ -26,6 +27,17 @@ struct debugfs_blob_wrapper { unsigned long size; }; +struct debugfs_reg32 { + char *name; + unsigned long offset; +}; + +struct debugfs_regset32 { + struct debugfs_reg32 *regs; + int nregs; + void __iomem *base; +}; + extern struct dentry *arch_debugfs_dir; #if defined(CONFIG_DEBUG_FS) @@ -74,6 +86,13 @@ struct dentry *debugfs_create_blob(const char *name, mode_t mode, struct dentry *parent, struct debugfs_blob_wrapper *blob); +struct dentry *debugfs_create_regset32(const char *name, mode_t mode, + struct dentry *parent, + struct debugfs_regset32 *regset); + +int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, + int nregs, void __iomem *base, char *prefix); + bool debugfs_initialized(void); #else @@ -188,6 +207,13 @@ static inline struct dentry *debugfs_create_blob(const char *name, mode_t mode, return ERR_PTR(-ENODEV); } +static inline struct dentry *debugfs_create_regset32(const char *name, + mode_t mode, struct dentry *parent, + struct debugfs_regset32 *regset) +{ + return ERR_PTR(-ENODEV); +} + static inline bool debugfs_initialized(void) { return false; -- cgit v0.10.2 From c8d2a6f3999e175c4d564c445c7f1ececd926453 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Fri, 18 Nov 2011 14:51:43 +0100 Subject: usb: dwc3: use debugfs_print_regs32() This a use example of the regs32 utilities in debugfs, although this fuse use ":" as separator between name and value, and debugs uses "=" (as it looked to me a more common practice). Signed-off-by: Alessandro Rubini Acked-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index da1ad77..d9e7a26 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -51,18 +51,13 @@ #include "gadget.h" #include "io.h" -struct dwc3_register { - const char *name; - u32 offset; -}; - #define dump_register(nm) \ { \ .name = __stringify(nm), \ .offset = DWC3_ ##nm, \ } -static const struct dwc3_register dwc3_regs[] = { +static const struct debugfs_reg32 dwc3_regs[] = { dump_register(GSBUSCFG0), dump_register(GSBUSCFG1), dump_register(GTXTHRCFG), @@ -385,12 +380,8 @@ static int dwc3_regdump_show(struct seq_file *s, void *unused) int i; seq_printf(s, "DesignWare USB3 Core Register Dump\n"); - - for (i = 0; i < ARRAY_SIZE(dwc3_regs); i++) { - seq_printf(s, "%-20s : %08x\n", dwc3_regs[i].name, - dwc3_readl(dwc->regs, dwc3_regs[i].offset)); - } - + debugfs_print_regs32(s, dwc3_regs, ARRAY_SIZE(dwc3_regs), + dwc->regs, ""); return 0; } -- cgit v0.10.2 From 8ee4dd9f063ce59c08f3ce283ca03306131aaf3a Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Fri, 18 Nov 2011 23:53:29 +0100 Subject: debugfs: print_regs32: make regs array a const pointer Signed-off-by: Alessandro Rubini Signed-off-by: Greg Kroah-Hartman diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index f31a27c..fc98ec9 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -548,7 +548,7 @@ EXPORT_SYMBOL_GPL(debugfs_create_blob); * because some peripherals have several blocks of identical registers, * for example configuration of dma channels */ -int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, +int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, int nregs, void __iomem *base, char *prefix) { int i, ret = 0; diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 5e6b01f..e8c3abc 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -90,7 +90,7 @@ struct dentry *debugfs_create_regset32(const char *name, mode_t mode, struct dentry *parent, struct debugfs_regset32 *regset); -int debugfs_print_regs32(struct seq_file *s, struct debugfs_reg32 *regs, +int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, int nregs, void __iomem *base, char *prefix); bool debugfs_initialized(void); -- cgit v0.10.2 From 42b4d114b936f3f7da121823774a42e584bf09f9 Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Fri, 18 Nov 2011 23:53:16 +0100 Subject: usb: dwc3: fix a warning The previous patch left an unused variable, I apologize. Signed-off-by: Alessandro Rubini Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index d9e7a26..fcfa915 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -377,7 +377,6 @@ static const struct debugfs_reg32 dwc3_regs[] = { static int dwc3_regdump_show(struct seq_file *s, void *unused) { struct dwc3 *dwc = s->private; - int i; seq_printf(s, "DesignWare USB3 Core Register Dump\n"); debugfs_print_regs32(s, dwc3_regs, ARRAY_SIZE(dwc3_regs), -- cgit v0.10.2 From 03e099fbb0fbd8aaef9316e74790d9819c57c8ff Mon Sep 17 00:00:00 2001 From: Alessandro Rubini Date: Mon, 21 Nov 2011 10:01:40 +0100 Subject: debugfs: bugfix: include in file.c The regs32 machinery uses readl. I forgot the mandatory include and the code was not compiling on all archs. Reported-by: Stephen Rothwell Signed-off-by: Alessandro Rubini Signed-off-by: Greg Kroah-Hartman diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index fc98ec9..e0a3a59 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -19,6 +19,7 @@ #include #include #include +#include static ssize_t default_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) -- cgit v0.10.2 From a48b0c4c7dfe8de55057c6c431ec47d489d1ff7a Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Nov 2011 18:41:42 +0100 Subject: hv: Move Kconfig menu entry Move the "Device Drivers/Microsoft Hyper-V guest support" menu entry up such that it appears immediately below virtio (KVM and lguest guest driver support) instead of after a hypervisor driver menu entry. Signed-off-by: Bart Van Assche Cc: Greg Kroah-Hartman Cc: James Bottomley Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/Kconfig b/drivers/Kconfig index b5e6f24..5afe5d1 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -116,6 +116,8 @@ source "drivers/vlynq/Kconfig" source "drivers/virtio/Kconfig" +source "drivers/hv/Kconfig" + source "drivers/xen/Kconfig" source "drivers/staging/Kconfig" @@ -132,8 +134,6 @@ source "drivers/iommu/Kconfig" source "drivers/virt/Kconfig" -source "drivers/hv/Kconfig" - source "drivers/devfreq/Kconfig" endmenu -- cgit v0.10.2 From 43d4e119f944a41a7694552353635ad9b2cd8b37 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Mon, 24 Oct 2011 11:28:12 -0700 Subject: Staging: hv: vmbus: Support building the vmbus driver as part of the kernel Modify the way we initialize the vmbus driver so that all the hyper-v drivers can be linked with the kernel and still ensure that the vmbus driver is fully initialized before the drivers that depend upon the vmbus driver attempt to initialize. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 0c048dd..7d3bccb3 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -783,4 +783,4 @@ cleanup: MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); -module_init(hv_acpi_init); +subsys_initcall(hv_acpi_init); -- cgit v0.10.2 From 124a6b4c4dae0317a0689a42ed0c68fabeb10c8d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 18 Nov 2011 18:40:52 +0100 Subject: hv: Add Kconfig menu entry Most of the drivers/*/Kconfig files define a menu entry. Define a menu item for hv too such that it becomes uniform with e.g. virtio for at least "make xconfig" and "make menuconfig" users. Signed-off-by: Bart Van Assche Cc: Greg Kroah-Hartman Cc: James Bottomley Cc: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 9fa09ac..70f5dde 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -1,3 +1,5 @@ +menu "Microsoft Hyper-V guest support" + config HYPERV tristate "Microsoft Hyper-V client drivers" depends on X86 && ACPI && PCI @@ -11,4 +13,4 @@ config HYPERV_UTILS help Select this option to enable the Hyper-V Utilities. - +endmenu -- cgit v0.10.2 From 5858441c95587c6869950314742d99e6a03a2d16 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 24 Nov 2011 10:22:08 +0300 Subject: debugfs: remove unneeded cast in debugfs_print_regs32() The cast here causes a Sparse warning: fs/debugfs/file.c:561:42: warning: cast removes address space of expression fs/debugfs/file.c:561:42: warning: incorrect type in argument 1 (different address spaces) fs/debugfs/file.c:561:42: expected void const volatile [noderef] *addr fs/debugfs/file.c:561:42: got void * It's redundant to cast it to a (void *) anyway when it is already a (void __iomem *). Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index e0a3a59..989f07f 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -558,7 +558,7 @@ int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs, if (prefix) ret += seq_printf(s, "%s", prefix); ret += seq_printf(s, "%s = 0x%08x\n", regs->name, - readl((void *)(base + regs->offset))); + readl(base + regs->offset)); } return ret; } -- cgit v0.10.2 From ccbc60d3e19a1b6ae66ca0d89b3da02dde62088b Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Thu, 24 Nov 2011 07:04:39 +0000 Subject: topology: Provide CPU topology in sysfs in !SMP configurations We should provide topology information to userland even if it's not very interesting. The current code appears to work properly for !SMP (tested on i386). Reference: http://bugs.debian.org/649216 Reported-by: Marcus Osdoba Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/Makefile b/drivers/base/Makefile index 99a375a..1334d89 100644 --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -3,7 +3,8 @@ obj-y := core.o sys.o bus.o dd.o syscore.o \ driver.o class.o platform.o \ cpu.o firmware.o init.o map.o devres.o \ - attribute_container.o transport_class.o + attribute_container.o transport_class.o \ + topology.o obj-$(CONFIG_DEVTMPFS) += devtmpfs.o obj-y += power/ obj-$(CONFIG_HAS_DMA) += dma-mapping.o @@ -12,7 +13,6 @@ obj-$(CONFIG_ISA) += isa.o obj-$(CONFIG_FW_LOADER) += firmware_class.o obj-$(CONFIG_NUMA) += node.o obj-$(CONFIG_MEMORY_HOTPLUG_SPARSE) += memory.o -obj-$(CONFIG_SMP) += topology.o ifeq ($(CONFIG_SYSFS),y) obj-$(CONFIG_MODULES) += module.o endif -- cgit v0.10.2 From 11e3123d9fdbe0aab1adf9ab5a5b1b28aa91daa7 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 26 Nov 2011 15:18:55 +0800 Subject: uio: convert drivers/uio/* to use module_platform_driver() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch converts the drivers in drivers/uio/* to use the module_platform_driver() macro which makes the code smaller and a bit simpler. Cc: Uwe Kleine-König Cc: Magnus Damm Cc: Amit Chatterjee Cc: Pratheesh Gangadhar Signed-off-by: Axel Lin Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c index ff50595..72d3646 100644 --- a/drivers/uio/uio_pdrv.c +++ b/drivers/uio/uio_pdrv.c @@ -104,17 +104,7 @@ static struct platform_driver uio_pdrv = { }, }; -static int __init uio_pdrv_init(void) -{ - return platform_driver_register(&uio_pdrv); -} - -static void __exit uio_pdrv_exit(void) -{ - platform_driver_unregister(&uio_pdrv); -} -module_init(uio_pdrv_init); -module_exit(uio_pdrv_exit); +module_platform_driver(uio_pdrv); MODULE_AUTHOR("Uwe Kleine-Koenig"); MODULE_DESCRIPTION("Userspace I/O platform driver"); diff --git a/drivers/uio/uio_pdrv_genirq.c b/drivers/uio/uio_pdrv_genirq.c index 25de302..b98371d 100644 --- a/drivers/uio/uio_pdrv_genirq.c +++ b/drivers/uio/uio_pdrv_genirq.c @@ -273,18 +273,7 @@ static struct platform_driver uio_pdrv_genirq = { }, }; -static int __init uio_pdrv_genirq_init(void) -{ - return platform_driver_register(&uio_pdrv_genirq); -} - -static void __exit uio_pdrv_genirq_exit(void) -{ - platform_driver_unregister(&uio_pdrv_genirq); -} - -module_init(uio_pdrv_genirq_init); -module_exit(uio_pdrv_genirq_exit); +module_platform_driver(uio_pdrv_genirq); MODULE_AUTHOR("Magnus Damm"); MODULE_DESCRIPTION("Userspace I/O platform driver with generic IRQ handling"); diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index e67b566..33a7a27 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c @@ -227,19 +227,7 @@ static struct platform_driver pruss_driver = { }, }; -static int __init pruss_init_module(void) -{ - return platform_driver_register(&pruss_driver); -} - -module_init(pruss_init_module); - -static void __exit pruss_exit_module(void) -{ - platform_driver_unregister(&pruss_driver); -} - -module_exit(pruss_exit_module); +module_platform_driver(pruss_driver); MODULE_LICENSE("GPL v2"); MODULE_VERSION(DRV_VERSION); -- cgit v0.10.2 From 5a3072be6ce00b10565c78da05ad78df41310045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 8 Dec 2011 22:53:29 +0100 Subject: drivers_base: make argument to platform_device_register_full const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit platform_device_register_full doesn't modify *pdevinfo so it can be marked as const without further adaptions. Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 7a24895..a7c0637 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -383,7 +383,7 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); * Returns &struct platform_device pointer on success, or ERR_PTR() on error. */ struct platform_device *platform_device_register_full( - struct platform_device_info *pdevinfo) + const struct platform_device_info *pdevinfo) { int ret = -ENOMEM; struct platform_device *pdev; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 165a8d1..5622fa2 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -63,7 +63,7 @@ struct platform_device_info { u64 dma_mask; }; extern struct platform_device *platform_device_register_full( - struct platform_device_info *pdevinfo); + const struct platform_device_info *pdevinfo); /** * platform_device_register_resndata - add a platform-level device with -- cgit v0.10.2 From d2554f50df9be3c53a13f7541a5f4d054bd56cc3 Mon Sep 17 00:00:00 2001 From: "Maxin B. John" Date: Thu, 1 Dec 2011 01:37:33 +0200 Subject: firmware: google: fix gsmi.c build warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use min_t() macro instead of min() to fix a build warning: CC drivers/firmware/google/gsmi.o drivers/firmware/google/gsmi.c: In function ‘gsmi_get_variable’: drivers/firmware/google/gsmi.c:348: warning: comparison of distinct pointer types lacks a cast Signed-off-by: Maxin B. John Acked-By: Mike Waychison Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index c4e7c59..91ddf0f 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -345,7 +345,8 @@ static efi_status_t gsmi_get_variable(efi_char16_t *name, memcpy(¶m, gsmi_dev.param_buf->start, sizeof(param)); /* The size reported is the min of all of our buffers */ - *data_size = min(*data_size, gsmi_dev.data_buf->length); + *data_size = min_t(unsigned long, *data_size, + gsmi_dev.data_buf->length); *data_size = min_t(unsigned long, *data_size, param.data_len); /* Copy data back to return buffer. */ -- cgit v0.10.2 From cf6a2eacbcb2593b5b91d0817915c4f0464bb534 Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 1 Dec 2011 09:59:34 -0800 Subject: drivers: hv: Don't OOPS when you cannot init vmbus The hv vmbus driver was causing an OOPS since it was trying to register drivers on top of the bus even if initialization of the bus has failed for some reason (such as the odd chance someone would run a hv enabled kernel in a non-hv environment). Signed-off-by: Sasha Levin Signed-off-by: K. Y. Srinivasan Cc: stable Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 7d3bccb3..40956d1 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -62,6 +62,14 @@ struct hv_device_info { struct hv_dev_port_info outbound; }; +static int vmbus_exists(void) +{ + if (hv_acpi_dev == NULL) + return -ENODEV; + + return 0; +} + static void get_channel_info(struct hv_device *device, struct hv_device_info *info) @@ -590,6 +598,10 @@ int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, c pr_info("registering driver %s\n", hv_driver->name); + ret = vmbus_exists(); + if (ret < 0) + return ret; + hv_driver->driver.name = hv_driver->name; hv_driver->driver.owner = owner; hv_driver->driver.mod_name = mod_name; @@ -614,6 +626,9 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver) { pr_info("unregistering driver %s\n", hv_driver->name); + if (!vmbus_exists()) + return; + driver_unregister(&hv_driver->driver); } @@ -776,6 +791,7 @@ static int __init hv_acpi_init(void) cleanup: acpi_bus_unregister_driver(&vmbus_acpi_driver); + hv_acpi_dev = NULL; return ret; } -- cgit v0.10.2 From 74099b18b8db0670484e0caeb3425fb29ff3144e Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Mon, 5 Dec 2011 19:12:47 +0100 Subject: driver-core: skip uevent generation when nobody is listening Most network namespaces unlikely have listeners to uevents, and should benefit from skipping all the string copies. Cc: Eric Biederman Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index ad72a03..e66e9b6 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -259,6 +259,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, struct sk_buff *skb; size_t len; + if (!netlink_has_listeners(uevent_sock, 1)) + continue; + /* allocate message with the maximum possible size */ len = strlen(action_string) + strlen(devpath) + 2; skb = alloc_skb(len + env->buflen, GFP_KERNEL); -- cgit v0.10.2 From c9cbf558e7793d312a4dd5d839ad7eae1aa8bd12 Mon Sep 17 00:00:00 2001 From: Evgeniy Polyakov Date: Sat, 10 Dec 2011 04:36:11 +0300 Subject: w1: add fast search for single slave bus This enables a much more efficient way of device searching. It uses the 1-wire read-rom operation which allows the direct reading of the slave address. BUT this works only with exactly one slave on the bus. Signed-off-by: Hubert Feurstein Acked-by: Evgeniy Polyakov index c374978..9761950 100644 Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index c374978..9761950 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -892,6 +892,16 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb break; } + /* Do fast search on single slave bus */ + if (dev->max_slave_count == 1) { + w1_write_8(dev, W1_READ_ROM); + + if (w1_read_block(dev, (u8 *)&rn, 8) == 8 && rn) + cb(dev, rn); + + break; + } + /* Start the search */ w1_write_8(dev, search_type); for (i = 0; i < 64; ++i) { -- cgit v0.10.2 From bc7a2f3abc636d7cab84258a48e77b08fb5fd3d6 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 9 Dec 2011 13:54:34 -0800 Subject: MAINTAINERS: stable: Update address The old address hasn't worked since the great intrusion of August 2011. Signed-off-by: Joe Perches Cc: stable Signed-off-by: Greg Kroah-Hartman diff --git a/MAINTAINERS b/MAINTAINERS index 4808256..a0f9fd1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6242,7 +6242,7 @@ F: arch/alpha/kernel/srm_env.c STABLE BRANCH M: Greg Kroah-Hartman -L: stable@kernel.org +L: stable@vger.kernel.org S: Maintained STAGING SUBSYSTEM -- cgit v0.10.2 From 2eb7f204db51969ea558802a6601d79c2fb273b9 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Fri, 9 Dec 2011 14:12:00 -0800 Subject: Documentation: Update stable address The Japanese/Korean/Chinese versions still need updating. Also, the stable kernel 2.6.x.y descriptions are out of date and should be updated as well. Signed-off-by: Joe Perches Cc: stable Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/HOWTO b/Documentation/HOWTO index 81bc1a9..f7ade3b 100644 --- a/Documentation/HOWTO +++ b/Documentation/HOWTO @@ -275,8 +275,8 @@ versions. If no 2.6.x.y kernel is available, then the highest numbered 2.6.x kernel is the current stable kernel. -2.6.x.y are maintained by the "stable" team , and are -released as needs dictate. The normal release period is approximately +2.6.x.y are maintained by the "stable" team , and +are released as needs dictate. The normal release period is approximately two weeks, but it can be longer if there are no pressing problems. A security-related problem, instead, can cause a release to happen almost instantly. diff --git a/Documentation/development-process/5.Posting b/Documentation/development-process/5.Posting index 903a254..8a48c9b 100644 --- a/Documentation/development-process/5.Posting +++ b/Documentation/development-process/5.Posting @@ -271,10 +271,10 @@ copies should go to: the linux-kernel list. - If you are fixing a bug, think about whether the fix should go into the - next stable update. If so, stable@kernel.org should get a copy of the - patch. Also add a "Cc: stable@kernel.org" to the tags within the patch - itself; that will cause the stable team to get a notification when your - fix goes into the mainline. + next stable update. If so, stable@vger.kernel.org should get a copy of + the patch. Also add a "Cc: stable@vger.kernel.org" to the tags within + the patch itself; that will cause the stable team to get a notification + when your fix goes into the mainline. When selecting recipients for a patch, it is good to have an idea of who you think will eventually accept the patch and get it merged. While it -- cgit v0.10.2 From 8b8ee6753154dd6cfe397e0d29fe7f90a8adb50b Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Mon, 12 Dec 2011 09:29:16 -0800 Subject: Drivers: hv: Fix a memory leak There was a memory leak in a failure path in vmbus_process_offer(). Fix it. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 12b85ff..b91af50 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -287,6 +287,7 @@ static void vmbus_process_offer(struct work_struct *work) spin_lock_irqsave(&vmbus_connection.channel_lock, flags); list_del(&newchannel->listentry); spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); + kfree(newchannel->device_obj); free_channel(newchannel); } else { -- cgit v0.10.2 From 93e5bd06a95343c701361fa009cdc5a653d6ec8e Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Mon, 12 Dec 2011 09:29:17 -0800 Subject: Drivers: hv: Make the vmbus driver unloadable It turns out that the vmbus driver can be made unloadable. Make it unloadable. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index b91af50..36484db 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -223,6 +223,17 @@ static void vmbus_process_rescind_offer(struct work_struct *work) vmbus_device_unregister(channel->device_obj); } +void vmbus_free_channels(void) +{ + struct vmbus_channel *channel; + + list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) { + vmbus_device_unregister(channel->device_obj); + kfree(channel->device_obj); + free_channel(channel); + } +} + /* * vmbus_process_offer - Process the offer by creating a channel/device * associated with this offer diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 0fb100e..f8a77d0 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -237,6 +237,9 @@ void hv_cleanup(void) { union hv_x64_msr_hypercall_contents hypercall_msr; + /* Reset our OS id */ + wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0); + kfree(hv_context.signal_event_buffer); hv_context.signal_event_buffer = NULL; hv_context.signal_event_param = NULL; diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 0aee112..6d7d286 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -611,6 +611,7 @@ void vmbus_device_unregister(struct hv_device *device_obj); struct vmbus_channel *relid2channel(u32 relid); +void vmbus_free_channels(void); /* Connection interface */ diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 40956d1..c3875f7 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -795,8 +795,19 @@ cleanup: return ret; } +static void __exit vmbus_exit(void) +{ + + free_irq(irq, hv_acpi_dev); + vmbus_free_channels(); + bus_unregister(&hv_bus); + hv_cleanup(); + acpi_bus_unregister_driver(&vmbus_acpi_driver); +} + MODULE_LICENSE("GPL"); MODULE_VERSION(HV_DRV_VERSION); subsys_initcall(hv_acpi_init); +module_exit(vmbus_exit); -- cgit v0.10.2 From 175cad266774d09c57a62c65baa6b4e1edafdf3a Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Mon, 12 Dec 2011 09:29:18 -0800 Subject: Drivers: hv: Get rid of an unnecessary check in hv.c In preparation for eventually supporting kexec in Linux VMs on Hyper-V, get rid of an unnecessary check in hv_init(). Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index f8a77d0..12aa97f 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -164,11 +164,6 @@ int hv_init(void) max_leaf = query_hypervisor_info(); - rdmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid); - - if (hv_context.guestid != 0) - goto cleanup; - /* Write our OS info */ wrmsrl(HV_X64_MSR_GUEST_OS_ID, HV_LINUX_GUEST_ID); hv_context.guestid = HV_LINUX_GUEST_ID; -- cgit v0.10.2 From 4af679cd7cbb0a0d8774b5cdb34bffcaa4e86e52 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 13 Dec 2011 10:36:20 +0100 Subject: kref: Inline all functions These are tiny functions, there's no point in having them out-of-line. Cc: Alexey Dobriyan Cc: Eric Dumazet Cc: Ingo Molnar Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-8eccvi2ur2fzgi00xdjlbf5z@git.kernel.org Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/kref.h b/include/linux/kref.h index d4a62ab..1cbae9f 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h @@ -16,15 +16,85 @@ #define _KREF_H_ #include +#include struct kref { atomic_t refcount; }; -void kref_init(struct kref *kref); -void kref_get(struct kref *kref); -int kref_put(struct kref *kref, void (*release) (struct kref *kref)); -int kref_sub(struct kref *kref, unsigned int count, - void (*release) (struct kref *kref)); +/** + * kref_init - initialize object. + * @kref: object in question. + */ +static inline void kref_init(struct kref *kref) +{ + atomic_set(&kref->refcount, 1); + smp_mb(); +} + +/** + * kref_get - increment refcount for object. + * @kref: object. + */ +static inline void kref_get(struct kref *kref) +{ + WARN_ON(!atomic_read(&kref->refcount)); + atomic_inc(&kref->refcount); + smp_mb__after_atomic_inc(); +} + +/** + * kref_put - decrement refcount for object. + * @kref: object. + * @release: pointer to the function that will clean up the object when the + * last reference to the object is released. + * This pointer is required, and it is not acceptable to pass kfree + * in as this function. + * + * Decrement the refcount, and if 0, call release(). + * Return 1 if the object was removed, otherwise return 0. Beware, if this + * function returns 0, you still can not count on the kref from remaining in + * memory. Only use the return value if you want to see if the kref is now + * gone, not present. + */ +static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) +{ + WARN_ON(release == NULL); + WARN_ON(release == (void (*)(struct kref *))kfree); + + if (atomic_dec_and_test(&kref->refcount)) { + release(kref); + return 1; + } + return 0; +} + + +/** + * kref_sub - subtract a number of refcounts for object. + * @kref: object. + * @count: Number of recounts to subtract. + * @release: pointer to the function that will clean up the object when the + * last reference to the object is released. + * This pointer is required, and it is not acceptable to pass kfree + * in as this function. + * + * Subtract @count from the refcount, and if 0, call release(). + * Return 1 if the object was removed, otherwise return 0. Beware, if this + * function returns 0, you still can not count on the kref from remaining in + * memory. Only use the return value if you want to see if the kref is now + * gone, not present. + */ +static inline int kref_sub(struct kref *kref, unsigned int count, + void (*release)(struct kref *kref)) +{ + WARN_ON(release == NULL); + WARN_ON(release == (void (*)(struct kref *))kfree); + if (atomic_sub_and_test((int) count, &kref->refcount)) { + release(kref); + return 1; + } + return 0; +} #endif /* _KREF_H_ */ diff --git a/lib/Makefile b/lib/Makefile index a4da283..6f195ff 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -17,7 +17,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ lib-$(CONFIG_MMU) += ioremap.o lib-$(CONFIG_SMP) += cpumask.o -lib-y += kobject.o kref.o klist.o +lib-y += kobject.o klist.o obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ diff --git a/lib/kref.c b/lib/kref.c deleted file mode 100644 index 3efb882..0000000 --- a/lib/kref.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * kref.c - library routines for handling generic reference counted objects - * - * Copyright (C) 2004 Greg Kroah-Hartman - * Copyright (C) 2004 IBM Corp. - * - * based on lib/kobject.c which was: - * Copyright (C) 2002-2003 Patrick Mochel - * - * This file is released under the GPLv2. - * - */ - -#include -#include -#include - -/** - * kref_init - initialize object. - * @kref: object in question. - */ -void kref_init(struct kref *kref) -{ - atomic_set(&kref->refcount, 1); - smp_mb(); -} - -/** - * kref_get - increment refcount for object. - * @kref: object. - */ -void kref_get(struct kref *kref) -{ - WARN_ON(!atomic_read(&kref->refcount)); - atomic_inc(&kref->refcount); - smp_mb__after_atomic_inc(); -} - -/** - * kref_put - decrement refcount for object. - * @kref: object. - * @release: pointer to the function that will clean up the object when the - * last reference to the object is released. - * This pointer is required, and it is not acceptable to pass kfree - * in as this function. - * - * Decrement the refcount, and if 0, call release(). - * Return 1 if the object was removed, otherwise return 0. Beware, if this - * function returns 0, you still can not count on the kref from remaining in - * memory. Only use the return value if you want to see if the kref is now - * gone, not present. - */ -int kref_put(struct kref *kref, void (*release)(struct kref *kref)) -{ - WARN_ON(release == NULL); - WARN_ON(release == (void (*)(struct kref *))kfree); - - if (atomic_dec_and_test(&kref->refcount)) { - release(kref); - return 1; - } - return 0; -} - - -/** - * kref_sub - subtract a number of refcounts for object. - * @kref: object. - * @count: Number of recounts to subtract. - * @release: pointer to the function that will clean up the object when the - * last reference to the object is released. - * This pointer is required, and it is not acceptable to pass kfree - * in as this function. - * - * Subtract @count from the refcount, and if 0, call release(). - * Return 1 if the object was removed, otherwise return 0. Beware, if this - * function returns 0, you still can not count on the kref from remaining in - * memory. Only use the return value if you want to see if the kref is now - * gone, not present. - */ -int kref_sub(struct kref *kref, unsigned int count, - void (*release)(struct kref *kref)) -{ - WARN_ON(release == NULL); - WARN_ON(release == (void (*)(struct kref *))kfree); - - if (atomic_sub_and_test((int) count, &kref->refcount)) { - release(kref); - return 1; - } - return 0; -} - -EXPORT_SYMBOL(kref_init); -EXPORT_SYMBOL(kref_get); -EXPORT_SYMBOL(kref_put); -EXPORT_SYMBOL(kref_sub); -- cgit v0.10.2 From 47dbd7d90ad80edb67822f327241edcab8f3f46f Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Sat, 10 Dec 2011 11:43:43 +0100 Subject: kref: Implement kref_put in terms of kref_sub Less lines of code is better. Cc: Alexey Dobriyan Cc: Eric Dumazet Cc: Ingo Molnar Signed-off-by: Peter Zijlstra Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/kref.h b/include/linux/kref.h index 1cbae9f..fa9907a 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h @@ -44,57 +44,49 @@ static inline void kref_get(struct kref *kref) } /** - * kref_put - decrement refcount for object. + * kref_sub - subtract a number of refcounts for object. * @kref: object. + * @count: Number of recounts to subtract. * @release: pointer to the function that will clean up the object when the * last reference to the object is released. * This pointer is required, and it is not acceptable to pass kfree * in as this function. * - * Decrement the refcount, and if 0, call release(). + * Subtract @count from the refcount, and if 0, call release(). * Return 1 if the object was removed, otherwise return 0. Beware, if this * function returns 0, you still can not count on the kref from remaining in * memory. Only use the return value if you want to see if the kref is now * gone, not present. */ -static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) +static inline int kref_sub(struct kref *kref, unsigned int count, + void (*release)(struct kref *kref)) { WARN_ON(release == NULL); WARN_ON(release == (void (*)(struct kref *))kfree); - if (atomic_dec_and_test(&kref->refcount)) { + if (atomic_sub_and_test((int) count, &kref->refcount)) { release(kref); return 1; } return 0; } - /** - * kref_sub - subtract a number of refcounts for object. + * kref_put - decrement refcount for object. * @kref: object. - * @count: Number of recounts to subtract. * @release: pointer to the function that will clean up the object when the * last reference to the object is released. * This pointer is required, and it is not acceptable to pass kfree * in as this function. * - * Subtract @count from the refcount, and if 0, call release(). + * Decrement the refcount, and if 0, call release(). * Return 1 if the object was removed, otherwise return 0. Beware, if this * function returns 0, you still can not count on the kref from remaining in * memory. Only use the return value if you want to see if the kref is now * gone, not present. */ -static inline int kref_sub(struct kref *kref, unsigned int count, - void (*release)(struct kref *kref)) +static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) { - WARN_ON(release == NULL); - WARN_ON(release == (void (*)(struct kref *))kfree); - - if (atomic_sub_and_test((int) count, &kref->refcount)) { - release(kref); - return 1; - } - return 0; + return kref_sub(kref, 1, release); } #endif /* _KREF_H_ */ -- cgit v0.10.2 From 3c8ed88974472b928489e3943616500ce2ad0cd8 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Sat, 10 Dec 2011 11:43:44 +0100 Subject: kref: Remove the memory barriers Commit 1b0b3b9980e ("kref: fix CPU ordering with respect to krefs") wrongly adds memory barriers to kref. It states: some atomic operations are only atomic, not ordered. Thus a CPU is allowed to reorder memory references to an object to before the reference is obtained. This fixes it. While true, it fails to show why this is a problem. I say it is not a problem because if there is a race with kref_put() such that we could end up referencing a free'd object without this memory barrier, we would still have that race with the memory barrier. The kref_put() in question could complete (and free the object) before the atomic_inc() and we'd still be up shit creek. The kref_init() case is even worse, if your object is published at this time you're so wrong the memory barrier won't make a difference what so ever. If its not published, the act of publishing should include the needed barriers/locks to make sure all writes prior to the act of publishing are complete such that others will only observe a complete object. Cc: Alexey Dobriyan Cc: Eric Dumazet Cc: Ingo Molnar Cc: Oliver Neukum Signed-off-by: Peter Zijlstra Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/kref.h b/include/linux/kref.h index fa9907a..d66c88a 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h @@ -29,7 +29,6 @@ struct kref { static inline void kref_init(struct kref *kref) { atomic_set(&kref->refcount, 1); - smp_mb(); } /** @@ -40,7 +39,6 @@ static inline void kref_get(struct kref *kref) { WARN_ON(!atomic_read(&kref->refcount)); atomic_inc(&kref->refcount); - smp_mb__after_atomic_inc(); } /** -- cgit v0.10.2 From 6261ddee70174372d6a75601f40719b7a5392f3f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 14 Dec 2011 11:19:07 -0800 Subject: kref: fix up the kfree build problems It turns out that some memory allocators use kobjects, which use krefs, and kref.h was wanting to figure out the address of kfree(), which ended up in a loop. kfree was only being needed for a warning to tell the caller that they were doing something stupid. Now we just move that warning into the comments for the functions, which results in a bit more fun as everyone enjoys digging for people to mock at times of boredom. So, remove the dependancy of slab.h on kref.h, and fix up the other include file as well (we really only need bug.h and atomic.h, not types.h). Reported-by: Stephen Rothwell Cc: Peter Zijlstra Cc: Alexey Dobriyan Cc: Eric Dumazet Cc: Ingo Molnar Cc: Oliver Neukum Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/kref.h b/include/linux/kref.h index d66c88a..abc0120 100644 --- a/include/linux/kref.h +++ b/include/linux/kref.h @@ -15,8 +15,8 @@ #ifndef _KREF_H_ #define _KREF_H_ -#include -#include +#include +#include struct kref { atomic_t refcount; @@ -48,7 +48,10 @@ static inline void kref_get(struct kref *kref) * @release: pointer to the function that will clean up the object when the * last reference to the object is released. * This pointer is required, and it is not acceptable to pass kfree - * in as this function. + * in as this function. If the caller does pass kfree to this + * function, you will be publicly mocked mercilessly by the kref + * maintainer, and anyone else who happens to notice it. You have + * been warned. * * Subtract @count from the refcount, and if 0, call release(). * Return 1 if the object was removed, otherwise return 0. Beware, if this @@ -60,7 +63,6 @@ static inline int kref_sub(struct kref *kref, unsigned int count, void (*release)(struct kref *kref)) { WARN_ON(release == NULL); - WARN_ON(release == (void (*)(struct kref *))kfree); if (atomic_sub_and_test((int) count, &kref->refcount)) { release(kref); @@ -75,7 +77,10 @@ static inline int kref_sub(struct kref *kref, unsigned int count, * @release: pointer to the function that will clean up the object when the * last reference to the object is released. * This pointer is required, and it is not acceptable to pass kfree - * in as this function. + * in as this function. If the caller does pass kfree to this + * function, you will be publicly mocked mercilessly by the kref + * maintainer, and anyone else who happens to notice it. You have + * been warned. * * Decrement the refcount, and if 0, call release(). * Return 1 if the object was removed, otherwise return 0. Beware, if this -- cgit v0.10.2 From ca22e56debc57b47c422b749c93217ba62644be2 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Dec 2011 14:29:38 -0800 Subject: driver-core: implement 'sysdev' functionality for regular devices and buses All sysdev classes and sysdev devices will converted to regular devices and buses to properly hook userspace into the event processing. There is no interesting difference between a 'sysdev' and 'device' which would justify to roll an entire own subsystem with different userspace export semantics. Userspace relies on events and generic sysfs subsystem infrastructure from sysdev devices, which are currently not properly available. Every converted sysdev class will create a regular device with the class name in /sys/devices/system and all registered devices will becom a children of theses devices. For compatibility reasons, the sysdev class-wide attributes are created at this parent device. (Do not copy that logic for anything new, subsystem- wide properties belong to the subsystem, not to some fake parent device created in /sys/devices.) Every sysdev driver is implemented as a simple subsystem interface now, and no longer called a driver. After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/base.h b/drivers/base/base.h index 21c1b96..7a6ae42 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -4,7 +4,9 @@ * struct subsys_private - structure to hold the private to the driver core portions of the bus_type/class structure. * * @subsys - the struct kset that defines this subsystem - * @devices_kset - the list of devices associated + * @devices_kset - the subsystem's 'devices' directory + * @interfaces - list of subsystem interfaces associated + * @mutex - protect the devices, and interfaces lists. * * @drivers_kset - the list of drivers associated * @klist_devices - the klist to iterate over the @devices_kset @@ -14,10 +16,8 @@ * @bus - pointer back to the struct bus_type that this structure is associated * with. * - * @class_interfaces - list of class_interfaces associated * @glue_dirs - "glue" directory to put in-between the parent device to * avoid namespace conflicts - * @class_mutex - mutex to protect the children, devices, and interfaces lists. * @class - pointer back to the struct class that this structure is associated * with. * @@ -28,6 +28,8 @@ struct subsys_private { struct kset subsys; struct kset *devices_kset; + struct list_head interfaces; + struct mutex mutex; struct kset *drivers_kset; struct klist klist_devices; @@ -36,9 +38,7 @@ struct subsys_private { unsigned int drivers_autoprobe:1; struct bus_type *bus; - struct list_head class_interfaces; struct kset glue_dirs; - struct mutex class_mutex; struct class *class; }; #define to_subsys_private(obj) container_of(obj, struct subsys_private, subsys.kobj) @@ -94,7 +94,6 @@ extern int hypervisor_init(void); static inline int hypervisor_init(void) { return 0; } #endif extern int platform_bus_init(void); -extern int system_bus_init(void); extern int cpu_dev_init(void); extern int bus_add_device(struct device *dev); @@ -116,6 +115,7 @@ extern char *make_class_name(const char *name, struct kobject *kobj); extern int devres_release_all(struct device *dev); +/* /sys/devices directory */ extern struct kset *devices_kset; #if defined(CONFIG_MODULES) && defined(CONFIG_SYSFS) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 000e7b2..99dc592 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -16,9 +16,14 @@ #include #include #include +#include #include "base.h" #include "power/power.h" +/* /sys/devices/system */ +/* FIXME: make static after drivers/base/sys.c is deleted */ +struct kset *system_kset; + #define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) /* @@ -360,6 +365,47 @@ struct device *bus_find_device_by_name(struct bus_type *bus, } EXPORT_SYMBOL_GPL(bus_find_device_by_name); +/** + * subsys_find_device_by_id - find a device with a specific enumeration number + * @subsys: subsystem + * @id: index 'id' in struct device + * @hint: device to check first + * + * Check the hint's next object and if it is a match return it directly, + * otherwise, fall back to a full list search. Either way a reference for + * the returned object is taken. + */ +struct device *subsys_find_device_by_id(struct bus_type *subsys, unsigned int id, + struct device *hint) +{ + struct klist_iter i; + struct device *dev; + + if (!subsys) + return NULL; + + if (hint) { + klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus); + dev = next_device(&i); + if (dev && dev->id == id && get_device(dev)) { + klist_iter_exit(&i); + return dev; + } + klist_iter_exit(&i); + } + + klist_iter_init_node(&subsys->p->klist_devices, &i, NULL); + while ((dev = next_device(&i))) { + if (dev->id == id && get_device(dev)) { + klist_iter_exit(&i); + return dev; + } + } + klist_iter_exit(&i); + return NULL; +} +EXPORT_SYMBOL_GPL(subsys_find_device_by_id); + static struct device_driver *next_driver(struct klist_iter *i) { struct klist_node *n = klist_next(i); @@ -487,38 +533,59 @@ out_put: void bus_probe_device(struct device *dev) { struct bus_type *bus = dev->bus; + struct subsys_interface *sif; int ret; - if (bus && bus->p->drivers_autoprobe) { + if (!bus) + return; + + if (bus->p->drivers_autoprobe) { ret = device_attach(dev); WARN_ON(ret < 0); } + + mutex_lock(&bus->p->mutex); + list_for_each_entry(sif, &bus->p->interfaces, node) + if (sif->add_dev) + sif->add_dev(dev, sif); + mutex_unlock(&bus->p->mutex); } /** * bus_remove_device - remove device from bus * @dev: device to be removed * - * - Remove symlink from bus's directory. + * - Remove device from all interfaces. + * - Remove symlink from bus' directory. * - Delete device from bus's list. * - Detach from its driver. * - Drop reference taken in bus_add_device(). */ void bus_remove_device(struct device *dev) { - if (dev->bus) { - sysfs_remove_link(&dev->kobj, "subsystem"); - sysfs_remove_link(&dev->bus->p->devices_kset->kobj, - dev_name(dev)); - device_remove_attrs(dev->bus, dev); - if (klist_node_attached(&dev->p->knode_bus)) - klist_del(&dev->p->knode_bus); - - pr_debug("bus: '%s': remove device %s\n", - dev->bus->name, dev_name(dev)); - device_release_driver(dev); - bus_put(dev->bus); - } + struct bus_type *bus = dev->bus; + struct subsys_interface *sif; + + if (!bus) + return; + + mutex_lock(&bus->p->mutex); + list_for_each_entry(sif, &bus->p->interfaces, node) + if (sif->remove_dev) + sif->remove_dev(dev, sif); + mutex_unlock(&bus->p->mutex); + + sysfs_remove_link(&dev->kobj, "subsystem"); + sysfs_remove_link(&dev->bus->p->devices_kset->kobj, + dev_name(dev)); + device_remove_attrs(dev->bus, dev); + if (klist_node_attached(&dev->p->knode_bus)) + klist_del(&dev->p->knode_bus); + + pr_debug("bus: '%s': remove device %s\n", + dev->bus->name, dev_name(dev)); + device_release_driver(dev); + bus_put(dev->bus); } static int driver_add_attrs(struct bus_type *bus, struct device_driver *drv) @@ -847,14 +914,14 @@ static ssize_t bus_uevent_store(struct bus_type *bus, static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); /** - * bus_register - register a bus with the system. + * __bus_register - register a driver-core subsystem * @bus: bus. * * Once we have that, we registered the bus with the kobject * infrastructure, then register the children subsystems it has: - * the devices and drivers that belong to the bus. + * the devices and drivers that belong to the subsystem. */ -int bus_register(struct bus_type *bus) +int __bus_register(struct bus_type *bus, struct lock_class_key *key) { int retval; struct subsys_private *priv; @@ -898,6 +965,8 @@ int bus_register(struct bus_type *bus) goto bus_drivers_fail; } + INIT_LIST_HEAD(&priv->interfaces); + __mutex_init(&priv->mutex, "subsys mutex", key); klist_init(&priv->klist_devices, klist_devices_get, klist_devices_put); klist_init(&priv->klist_drivers, NULL, NULL); @@ -927,7 +996,7 @@ out: bus->p = NULL; return retval; } -EXPORT_SYMBOL_GPL(bus_register); +EXPORT_SYMBOL_GPL(__bus_register); /** * bus_unregister - remove a bus from the system @@ -939,6 +1008,8 @@ EXPORT_SYMBOL_GPL(bus_register); void bus_unregister(struct bus_type *bus) { pr_debug("bus: '%s': unregistering\n", bus->name); + if (bus->dev_root) + device_unregister(bus->dev_root); bus_remove_attrs(bus); remove_probe_files(bus); kset_unregister(bus->p->drivers_kset); @@ -1028,10 +1099,194 @@ void bus_sort_breadthfirst(struct bus_type *bus, } EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); +/** + * subsys_dev_iter_init - initialize subsys device iterator + * @iter: subsys iterator to initialize + * @subsys: the subsys we wanna iterate over + * @start: the device to start iterating from, if any + * @type: device_type of the devices to iterate over, NULL for all + * + * Initialize subsys iterator @iter such that it iterates over devices + * of @subsys. If @start is set, the list iteration will start there, + * otherwise if it is NULL, the iteration starts at the beginning of + * the list. + */ +void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys, + struct device *start, const struct device_type *type) +{ + struct klist_node *start_knode = NULL; + + if (start) + start_knode = &start->p->knode_bus; + klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode); + iter->type = type; +} +EXPORT_SYMBOL_GPL(subsys_dev_iter_init); + +/** + * subsys_dev_iter_next - iterate to the next device + * @iter: subsys iterator to proceed + * + * Proceed @iter to the next device and return it. Returns NULL if + * iteration is complete. + * + * The returned device is referenced and won't be released till + * iterator is proceed to the next device or exited. The caller is + * free to do whatever it wants to do with the device including + * calling back into subsys code. + */ +struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter) +{ + struct klist_node *knode; + struct device *dev; + + for (;;) { + knode = klist_next(&iter->ki); + if (!knode) + return NULL; + dev = container_of(knode, struct device_private, knode_bus)->device; + if (!iter->type || iter->type == dev->type) + return dev; + } +} +EXPORT_SYMBOL_GPL(subsys_dev_iter_next); + +/** + * subsys_dev_iter_exit - finish iteration + * @iter: subsys iterator to finish + * + * Finish an iteration. Always call this function after iteration is + * complete whether the iteration ran till the end or not. + */ +void subsys_dev_iter_exit(struct subsys_dev_iter *iter) +{ + klist_iter_exit(&iter->ki); +} +EXPORT_SYMBOL_GPL(subsys_dev_iter_exit); + +int subsys_interface_register(struct subsys_interface *sif) +{ + struct bus_type *subsys; + struct subsys_dev_iter iter; + struct device *dev; + + if (!sif || !sif->subsys) + return -ENODEV; + + subsys = bus_get(sif->subsys); + if (!subsys) + return -EINVAL; + + mutex_lock(&subsys->p->mutex); + list_add_tail(&sif->node, &subsys->p->interfaces); + if (sif->add_dev) { + subsys_dev_iter_init(&iter, subsys, NULL, NULL); + while ((dev = subsys_dev_iter_next(&iter))) + sif->add_dev(dev, sif); + subsys_dev_iter_exit(&iter); + } + mutex_unlock(&subsys->p->mutex); + + return 0; +} +EXPORT_SYMBOL_GPL(subsys_interface_register); + +void subsys_interface_unregister(struct subsys_interface *sif) +{ + struct bus_type *subsys = sif->subsys; + struct subsys_dev_iter iter; + struct device *dev; + + if (!sif) + return; + + mutex_lock(&subsys->p->mutex); + list_del_init(&sif->node); + if (sif->remove_dev) { + subsys_dev_iter_init(&iter, subsys, NULL, NULL); + while ((dev = subsys_dev_iter_next(&iter))) + sif->remove_dev(dev, sif); + subsys_dev_iter_exit(&iter); + } + mutex_unlock(&subsys->p->mutex); + + bus_put(subsys); +} +EXPORT_SYMBOL_GPL(subsys_interface_unregister); + +static void system_root_device_release(struct device *dev) +{ + kfree(dev); +} +/** + * subsys_system_register - register a subsystem at /sys/devices/system/ + * @subsys - system subsystem + * @groups - default attributes for the root device + * + * All 'system' subsystems have a /sys/devices/system/ root device + * with the name of the subsystem. The root device can carry subsystem- + * wide attributes. All registered devices are below this single root + * device and are named after the subsystem with a simple enumeration + * number appended. The registered devices are not explicitely named; + * only 'id' in the device needs to be set. + * + * Do not use this interface for anything new, it exists for compatibility + * with bad ideas only. New subsystems should use plain subsystems; and + * add the subsystem-wide attributes should be added to the subsystem + * directory itself and not some create fake root-device placed in + * /sys/devices/system/. + */ +int subsys_system_register(struct bus_type *subsys, + const struct attribute_group **groups) +{ + struct device *dev; + int err; + + err = bus_register(subsys); + if (err < 0) + return err; + + dev = kzalloc(sizeof(struct device), GFP_KERNEL); + if (!dev) { + err = -ENOMEM; + goto err_dev; + } + + err = dev_set_name(dev, "%s", subsys->name); + if (err < 0) + goto err_name; + + dev->kobj.parent = &system_kset->kobj; + dev->groups = groups; + dev->release = system_root_device_release; + + err = device_register(dev); + if (err < 0) + goto err_dev_reg; + + subsys->dev_root = dev; + return 0; + +err_dev_reg: + put_device(dev); + dev = NULL; +err_name: + kfree(dev); +err_dev: + bus_unregister(subsys); + return err; +} +EXPORT_SYMBOL_GPL(subsys_system_register); + int __init buses_init(void) { bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); if (!bus_kset) return -ENOMEM; + + system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj); + if (!system_kset) + return -ENOMEM; + return 0; } diff --git a/drivers/base/class.c b/drivers/base/class.c index b80d91c..03243d4 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -184,9 +184,9 @@ int __class_register(struct class *cls, struct lock_class_key *key) if (!cp) return -ENOMEM; klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put); - INIT_LIST_HEAD(&cp->class_interfaces); + INIT_LIST_HEAD(&cp->interfaces); kset_init(&cp->glue_dirs); - __mutex_init(&cp->class_mutex, "struct class mutex", key); + __mutex_init(&cp->mutex, "subsys mutex", key); error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); if (error) { kfree(cp); @@ -460,15 +460,15 @@ int class_interface_register(struct class_interface *class_intf) if (!parent) return -EINVAL; - mutex_lock(&parent->p->class_mutex); - list_add_tail(&class_intf->node, &parent->p->class_interfaces); + mutex_lock(&parent->p->mutex); + list_add_tail(&class_intf->node, &parent->p->interfaces); if (class_intf->add_dev) { class_dev_iter_init(&iter, parent, NULL, NULL); while ((dev = class_dev_iter_next(&iter))) class_intf->add_dev(dev, class_intf); class_dev_iter_exit(&iter); } - mutex_unlock(&parent->p->class_mutex); + mutex_unlock(&parent->p->mutex); return 0; } @@ -482,7 +482,7 @@ void class_interface_unregister(struct class_interface *class_intf) if (!parent) return; - mutex_lock(&parent->p->class_mutex); + mutex_lock(&parent->p->mutex); list_del_init(&class_intf->node); if (class_intf->remove_dev) { class_dev_iter_init(&iter, parent, NULL, NULL); @@ -490,7 +490,7 @@ void class_interface_unregister(struct class_interface *class_intf) class_intf->remove_dev(dev, class_intf); class_dev_iter_exit(&iter); } - mutex_unlock(&parent->p->class_mutex); + mutex_unlock(&parent->p->mutex); class_put(parent); } diff --git a/drivers/base/core.c b/drivers/base/core.c index 82c86545..a31ea19 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -117,6 +117,56 @@ static const struct sysfs_ops dev_sysfs_ops = { .store = dev_attr_store, }; +#define to_ext_attr(x) container_of(x, struct dev_ext_attribute, attr) + +ssize_t device_store_ulong(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + struct dev_ext_attribute *ea = to_ext_attr(attr); + char *end; + unsigned long new = simple_strtoul(buf, &end, 0); + if (end == buf) + return -EINVAL; + *(unsigned long *)(ea->var) = new; + /* Always return full write size even if we didn't consume all */ + return size; +} +EXPORT_SYMBOL_GPL(device_store_ulong); + +ssize_t device_show_ulong(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct dev_ext_attribute *ea = to_ext_attr(attr); + return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var)); +} +EXPORT_SYMBOL_GPL(device_show_ulong); + +ssize_t device_store_int(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + struct dev_ext_attribute *ea = to_ext_attr(attr); + char *end; + long new = simple_strtol(buf, &end, 0); + if (end == buf || new > INT_MAX || new < INT_MIN) + return -EINVAL; + *(int *)(ea->var) = new; + /* Always return full write size even if we didn't consume all */ + return size; +} +EXPORT_SYMBOL_GPL(device_store_int); + +ssize_t device_show_int(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct dev_ext_attribute *ea = to_ext_attr(attr); + + return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var)); +} +EXPORT_SYMBOL_GPL(device_show_int); /** * device_release - free device structure. @@ -463,7 +513,7 @@ static ssize_t show_dev(struct device *dev, struct device_attribute *attr, static struct device_attribute devt_attr = __ATTR(dev, S_IRUGO, show_dev, NULL); -/* kset to create /sys/devices/ */ +/* /sys/devices/ */ struct kset *devices_kset; /** @@ -710,6 +760,10 @@ static struct kobject *get_device_parent(struct device *dev, return k; } + /* subsystems can specify a default root directory for their devices */ + if (!parent && dev->bus && dev->bus->dev_root) + return &dev->bus->dev_root->kobj; + if (parent) return &parent->kobj; return NULL; @@ -730,14 +784,6 @@ static void cleanup_device_parent(struct device *dev) cleanup_glue_dir(dev, dev->kobj.parent); } -static void setup_parent(struct device *dev, struct device *parent) -{ - struct kobject *kobj; - kobj = get_device_parent(dev, parent); - if (kobj) - dev->kobj.parent = kobj; -} - static int device_add_class_symlinks(struct device *dev) { int error; @@ -890,6 +936,7 @@ int device_private_init(struct device *dev) int device_add(struct device *dev) { struct device *parent = NULL; + struct kobject *kobj; struct class_interface *class_intf; int error = -EINVAL; @@ -913,6 +960,10 @@ int device_add(struct device *dev) dev->init_name = NULL; } + /* subsystems can specify simple device enumeration */ + if (!dev_name(dev) && dev->bus && dev->bus->dev_name) + dev_set_name(dev, "%s%u", dev->bus->dev_name, dev->id); + if (!dev_name(dev)) { error = -EINVAL; goto name_error; @@ -921,7 +972,9 @@ int device_add(struct device *dev) pr_debug("device: '%s': %s\n", dev_name(dev), __func__); parent = get_device(dev->parent); - setup_parent(dev, parent); + kobj = get_device_parent(dev, parent); + if (kobj) + dev->kobj.parent = kobj; /* use parent numa_node */ if (parent) @@ -981,17 +1034,17 @@ int device_add(struct device *dev) &parent->p->klist_children); if (dev->class) { - mutex_lock(&dev->class->p->class_mutex); + mutex_lock(&dev->class->p->mutex); /* tie the class to the device */ klist_add_tail(&dev->knode_class, &dev->class->p->klist_devices); /* notify any interfaces that the device is here */ list_for_each_entry(class_intf, - &dev->class->p->class_interfaces, node) + &dev->class->p->interfaces, node) if (class_intf->add_dev) class_intf->add_dev(dev, class_intf); - mutex_unlock(&dev->class->p->class_mutex); + mutex_unlock(&dev->class->p->mutex); } done: put_device(dev); @@ -1106,15 +1159,15 @@ void device_del(struct device *dev) if (dev->class) { device_remove_class_symlinks(dev); - mutex_lock(&dev->class->p->class_mutex); + mutex_lock(&dev->class->p->mutex); /* notify any interfaces that the device is now gone */ list_for_each_entry(class_intf, - &dev->class->p->class_interfaces, node) + &dev->class->p->interfaces, node) if (class_intf->remove_dev) class_intf->remove_dev(dev, class_intf); /* remove the device from the class list */ klist_del(&dev->knode_class); - mutex_unlock(&dev->class->p->class_mutex); + mutex_unlock(&dev->class->p->mutex); } device_remove_file(dev, &uevent_attr); device_remove_attrs(dev); diff --git a/drivers/base/init.c b/drivers/base/init.c index c8a934e..c16f0b8 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c @@ -31,7 +31,6 @@ void __init driver_init(void) * core core pieces. */ platform_bus_init(); - system_bus_init(); cpu_dev_init(); memory_dev_init(); } diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 9dff77b..409f5ce 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c @@ -126,7 +126,7 @@ void sysdev_class_remove_file(struct sysdev_class *c, } EXPORT_SYMBOL_GPL(sysdev_class_remove_file); -static struct kset *system_kset; +extern struct kset *system_kset; int sysdev_class_register(struct sysdev_class *cls) { @@ -331,14 +331,6 @@ void sysdev_unregister(struct sys_device *sysdev) EXPORT_SYMBOL_GPL(sysdev_register); EXPORT_SYMBOL_GPL(sysdev_unregister); -int __init system_bus_init(void) -{ - system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj); - if (!system_kset) - return -ENOMEM; - return 0; -} - #define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr) ssize_t sysdev_store_ulong(struct sys_device *sysdev, diff --git a/include/linux/device.h b/include/linux/device.h index 341fb74..7f9fc15 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -53,6 +53,8 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); * struct bus_type - The bus type of the device * * @name: The name of the bus. + * @dev_name: Used for subsystems to enumerate devices like ("foo%u", dev->id). + * @dev_root: Default device to use as the parent. * @bus_attrs: Default attributes of the bus. * @dev_attrs: Default attributes of the devices on the bus. * @drv_attrs: Default attributes of the device drivers on the bus. @@ -86,6 +88,8 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); */ struct bus_type { const char *name; + const char *dev_name; + struct device *dev_root; struct bus_attribute *bus_attrs; struct device_attribute *dev_attrs; struct driver_attribute *drv_attrs; @@ -106,12 +110,30 @@ struct bus_type { struct subsys_private *p; }; -extern int __must_check bus_register(struct bus_type *bus); +/* This is a #define to keep the compiler from merging different + * instances of the __key variable */ +#define bus_register(subsys) \ +({ \ + static struct lock_class_key __key; \ + __bus_register(subsys, &__key); \ +}) +extern int __must_check __bus_register(struct bus_type *bus, + struct lock_class_key *key); extern void bus_unregister(struct bus_type *bus); extern int __must_check bus_rescan_devices(struct bus_type *bus); /* iterator helpers for buses */ +struct subsys_dev_iter { + struct klist_iter ki; + const struct device_type *type; +}; +void subsys_dev_iter_init(struct subsys_dev_iter *iter, + struct bus_type *subsys, + struct device *start, + const struct device_type *type); +struct device *subsys_dev_iter_next(struct subsys_dev_iter *iter); +void subsys_dev_iter_exit(struct subsys_dev_iter *iter); int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data, int (*fn)(struct device *dev, void *data)); @@ -121,10 +143,10 @@ struct device *bus_find_device(struct bus_type *bus, struct device *start, struct device *bus_find_device_by_name(struct bus_type *bus, struct device *start, const char *name); - +struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id, + struct device *hint); int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, void *data, int (*fn)(struct device_driver *, void *)); - void bus_sort_breadthfirst(struct bus_type *bus, int (*compare)(const struct device *a, const struct device *b)); @@ -256,6 +278,33 @@ struct device *driver_find_device(struct device_driver *drv, int (*match)(struct device *dev, void *data)); /** + * struct subsys_interface - interfaces to device functions + * @name name of the device function + * @subsystem subsytem of the devices to attach to + * @node the list of functions registered at the subsystem + * @add device hookup to device function handler + * @remove device hookup to device function handler + * + * Simple interfaces attached to a subsystem. Multiple interfaces can + * attach to a subsystem and its devices. Unlike drivers, they do not + * exclusively claim or control devices. Interfaces usually represent + * a specific functionality of a subsystem/class of devices. + */ +struct subsys_interface { + const char *name; + struct bus_type *subsys; + struct list_head node; + int (*add_dev)(struct device *dev, struct subsys_interface *sif); + int (*remove_dev)(struct device *dev, struct subsys_interface *sif); +}; + +int subsys_interface_register(struct subsys_interface *sif); +void subsys_interface_unregister(struct subsys_interface *sif); + +int subsys_system_register(struct bus_type *subsys, + const struct attribute_group **groups); + +/** * struct class - device classes * @name: Name of the class. * @owner: The module owner. @@ -438,8 +487,28 @@ struct device_attribute { const char *buf, size_t count); }; +struct dev_ext_attribute { + struct device_attribute attr; + void *var; +}; + +ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr, + char *buf); +ssize_t device_store_ulong(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +ssize_t device_show_int(struct device *dev, struct device_attribute *attr, + char *buf); +ssize_t device_store_int(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); + #define DEVICE_ATTR(_name, _mode, _show, _store) \ -struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) + struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define DEVICE_ULONG_ATTR(_name, _mode, _var) \ + struct dev_ext_attribute dev_attr_##_name = \ + { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } +#define DEVICE_INT_ATTR(_name, _mode, _var) \ + struct dev_ext_attribute dev_attr_##_name = \ + { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } extern int __must_check device_create_file(struct device *device, const struct device_attribute *entry); @@ -603,6 +672,7 @@ struct device { struct device_node *of_node; /* associated device tree node */ dev_t devt; /* dev_t, creates the sysfs "dev" */ + u32 id; /* device instance */ spinlock_t devres_lock; struct list_head devres_head; -- cgit v0.10.2 From 997d3eaf02cad6fdb54bd6085c9a7c48ddd68a2d Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Dec 2011 14:54:22 -0800 Subject: rtmutex-tester: convert sysdev_class to a regular subsystem After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Cc: Thomas Gleixner Cc: Paul Gortmaker Cc: Arnd Bergmann Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c index 3d9f31c..98ec494 100644 --- a/kernel/rtmutex-tester.c +++ b/kernel/rtmutex-tester.c @@ -6,11 +6,11 @@ * Copyright (C) 2006, Timesys Corp., Thomas Gleixner * */ +#include #include #include #include #include -#include #include #include @@ -27,7 +27,7 @@ struct test_thread_data { int opdata; int mutexes[MAX_RT_TEST_MUTEXES]; int event; - struct sys_device sysdev; + struct device dev; }; static struct test_thread_data thread_data[MAX_RT_TEST_THREADS]; @@ -271,7 +271,7 @@ static int test_func(void *data) * * opcode:data */ -static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr, +static ssize_t sysfs_test_command(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct sched_param schedpar; @@ -279,8 +279,8 @@ static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribut char cmdbuf[32]; int op, dat, tid, ret; - td = container_of(dev, struct test_thread_data, sysdev); - tid = td->sysdev.id; + td = container_of(dev, struct test_thread_data, dev); + tid = td->dev.id; /* strings from sysfs write are not 0 terminated! */ if (count >= sizeof(cmdbuf)) @@ -334,7 +334,7 @@ static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribut * @dev: thread to query * @buf: char buffer to be filled with thread status info */ -static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr, +static ssize_t sysfs_test_status(struct device *dev, struct device_attribute *attr, char *buf) { struct test_thread_data *td; @@ -342,8 +342,8 @@ static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute char *curr = buf; int i; - td = container_of(dev, struct test_thread_data, sysdev); - tsk = threads[td->sysdev.id]; + td = container_of(dev, struct test_thread_data, dev); + tsk = threads[td->dev.id]; spin_lock(&rttest_lock); @@ -360,28 +360,29 @@ static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute spin_unlock(&rttest_lock); curr += sprintf(curr, ", T: %p, R: %p\n", tsk, - mutexes[td->sysdev.id].owner); + mutexes[td->dev.id].owner); return curr - buf; } -static SYSDEV_ATTR(status, 0600, sysfs_test_status, NULL); -static SYSDEV_ATTR(command, 0600, NULL, sysfs_test_command); +static DEVICE_ATTR(status, 0600, sysfs_test_status, NULL); +static DEVICE_ATTR(command, 0600, NULL, sysfs_test_command); -static struct sysdev_class rttest_sysclass = { +static struct bus_type rttest_subsys = { .name = "rttest", + .dev_name = "rttest", }; static int init_test_thread(int id) { - thread_data[id].sysdev.cls = &rttest_sysclass; - thread_data[id].sysdev.id = id; + thread_data[id].dev.bus = &rttest_subsys; + thread_data[id].dev.id = id; threads[id] = kthread_run(test_func, &thread_data[id], "rt-test-%d", id); if (IS_ERR(threads[id])) return PTR_ERR(threads[id]); - return sysdev_register(&thread_data[id].sysdev); + return device_register(&thread_data[id].dev); } static int init_rttest(void) @@ -393,7 +394,7 @@ static int init_rttest(void) for (i = 0; i < MAX_RT_TEST_MUTEXES; i++) rt_mutex_init(&mutexes[i]); - ret = sysdev_class_register(&rttest_sysclass); + ret = subsys_system_register(&rttest_subsys, NULL); if (ret) return ret; @@ -401,10 +402,10 @@ static int init_rttest(void) ret = init_test_thread(i); if (ret) break; - ret = sysdev_create_file(&thread_data[i].sysdev, &attr_status); + ret = device_create_file(&thread_data[i].dev, &dev_attr_status); if (ret) break; - ret = sysdev_create_file(&thread_data[i].sysdev, &attr_command); + ret = device_create_file(&thread_data[i].dev, &dev_attr_command); if (ret) break; } -- cgit v0.10.2 From fe5ff8b84c8b03348a2f64ea9d884348faec2217 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Dec 2011 15:21:07 -0800 Subject: edac: convert sysdev_class to a regular subsystem After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Cc: Doug Thompson Cc: Paul Gortmaker Cc: Lucas De Marchi Cc: Borislav Petkov Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h index fe90cd4..e48ab31 100644 --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -243,8 +242,8 @@ struct edac_device_ctl_info { */ struct edac_dev_sysfs_attribute *sysfs_attributes; - /* pointer to main 'edac' class in sysfs */ - struct sysdev_class *edac_class; + /* pointer to main 'edac' subsys in sysfs */ + struct bus_type *edac_subsys; /* the internal state of this controller instance */ int op_state; @@ -342,7 +341,7 @@ struct edac_pci_ctl_info { int pci_idx; - struct sysdev_class *edac_class; /* pointer to class */ + struct bus_type *edac_subsys; /* pointer to subsystem */ /* the internal state of this controller instance */ int op_state; diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c index c3f6743..4b15459 100644 --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 86649df..b4ea185 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c @@ -1,5 +1,5 @@ /* - * file for managing the edac_device class of devices for EDAC + * file for managing the edac_device subsystem of devices for EDAC * * (C) 2007 SoftwareBitMaker * @@ -230,21 +230,21 @@ static struct kobj_type ktype_device_ctrl = { */ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) { - struct sysdev_class *edac_class; + struct bus_type *edac_subsys; int err; debugf1("%s()\n", __func__); /* get the /sys/devices/system/edac reference */ - edac_class = edac_get_sysfs_class(); - if (edac_class == NULL) { - debugf1("%s() no edac_class error\n", __func__); + edac_subsys = edac_get_sysfs_subsys(); + if (edac_subsys == NULL) { + debugf1("%s() no edac_subsys error\n", __func__); err = -ENODEV; goto err_out; } - /* Point to the 'edac_class' this instance 'reports' to */ - edac_dev->edac_class = edac_class; + /* Point to the 'edac_subsys' this instance 'reports' to */ + edac_dev->edac_subsys = edac_subsys; /* Init the devices's kobject */ memset(&edac_dev->kobj, 0, sizeof(struct kobject)); @@ -261,7 +261,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) /* register */ err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, - &edac_class->kset.kobj, + &edac_subsys->dev_root->kobj, "%s", edac_dev->name); if (err) { debugf1("%s()Failed to register '.../edac/%s'\n", @@ -284,7 +284,7 @@ err_kobj_reg: module_put(edac_dev->owner); err_mod_get: - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); err_out: return err; @@ -308,7 +308,7 @@ void edac_device_unregister_sysfs_main_kobj(struct edac_device_ctl_info *dev) * b) 'kfree' the memory */ kobject_put(&dev->kobj); - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); } /* edac_dev -> instance information */ diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c index d69144a..ca6c04d 100644 --- a/drivers/edac/edac_mc.c +++ b/drivers/edac/edac_mc.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 29ffa35..d56e634 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c @@ -1021,19 +1021,19 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) int edac_sysfs_setup_mc_kset(void) { int err = -EINVAL; - struct sysdev_class *edac_class; + struct bus_type *edac_subsys; debugf1("%s()\n", __func__); - /* get the /sys/devices/system/edac class reference */ - edac_class = edac_get_sysfs_class(); - if (edac_class == NULL) { - debugf1("%s() no edac_class error=%d\n", __func__, err); + /* get the /sys/devices/system/edac subsys reference */ + edac_subsys = edac_get_sysfs_subsys(); + if (edac_subsys == NULL) { + debugf1("%s() no edac_subsys error=%d\n", __func__, err); goto fail_out; } /* Init the MC's kobject */ - mc_kset = kset_create_and_add("mc", NULL, &edac_class->kset.kobj); + mc_kset = kset_create_and_add("mc", NULL, &edac_subsys->dev_root->kobj); if (!mc_kset) { err = -ENOMEM; debugf1("%s() Failed to register '.../edac/mc'\n", __func__); @@ -1045,7 +1045,7 @@ int edac_sysfs_setup_mc_kset(void) return 0; fail_kset: - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); fail_out: return err; @@ -1059,6 +1059,6 @@ fail_out: void edac_sysfs_teardown_mc_kset(void) { kset_unregister(mc_kset); - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); } diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index 17aabb7..00f81b4 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h @@ -10,8 +10,6 @@ #ifndef __EDAC_MODULE_H__ #define __EDAC_MODULE_H__ -#include - #include "edac_core.h" /* diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c index 2b378207..63af1c5 100644 --- a/drivers/edac/edac_pci.c +++ b/drivers/edac/edac_pci.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c index 495198a..97f5064 100644 --- a/drivers/edac/edac_pci_sysfs.c +++ b/drivers/edac/edac_pci_sysfs.c @@ -338,12 +338,12 @@ static struct kobj_type ktype_edac_pci_main_kobj = { * edac_pci_main_kobj_setup() * * setup the sysfs for EDAC PCI attributes - * assumes edac_class has already been initialized + * assumes edac_subsys has already been initialized */ static int edac_pci_main_kobj_setup(void) { int err; - struct sysdev_class *edac_class; + struct bus_type *edac_subsys; debugf0("%s()\n", __func__); @@ -354,9 +354,9 @@ static int edac_pci_main_kobj_setup(void) /* First time, so create the main kobject and its * controls and attributes */ - edac_class = edac_get_sysfs_class(); - if (edac_class == NULL) { - debugf1("%s() no edac_class\n", __func__); + edac_subsys = edac_get_sysfs_subsys(); + if (edac_subsys == NULL) { + debugf1("%s() no edac_subsys\n", __func__); err = -ENODEV; goto decrement_count_fail; } @@ -381,7 +381,7 @@ static int edac_pci_main_kobj_setup(void) /* Instanstiate the pci object */ err = kobject_init_and_add(edac_pci_top_main_kobj, &ktype_edac_pci_main_kobj, - &edac_class->kset.kobj, "pci"); + &edac_subsys->dev_root->kobj, "pci"); if (err) { debugf1("Failed to register '.../edac/pci'\n"); goto kobject_init_and_add_fail; @@ -404,7 +404,7 @@ kzalloc_fail: module_put(THIS_MODULE); mod_get_fail: - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); decrement_count_fail: /* if are on this error exit, nothing to tear down */ @@ -432,7 +432,7 @@ static void edac_pci_main_kobj_teardown(void) __func__); kobject_put(edac_pci_top_main_kobj); } - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); } /* diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c index 86ad2ee..670c448 100644 --- a/drivers/edac/edac_stub.c +++ b/drivers/edac/edac_stub.c @@ -26,7 +26,7 @@ EXPORT_SYMBOL_GPL(edac_handlers); int edac_err_assert = 0; EXPORT_SYMBOL_GPL(edac_err_assert); -static atomic_t edac_class_valid = ATOMIC_INIT(0); +static atomic_t edac_subsys_valid = ATOMIC_INIT(0); /* * called to determine if there is an EDAC driver interested in @@ -54,36 +54,37 @@ EXPORT_SYMBOL_GPL(edac_atomic_assert_error); * sysfs object: /sys/devices/system/edac * need to export to other files */ -struct sysdev_class edac_class = { +struct bus_type edac_subsys = { .name = "edac", + .dev_name = "edac", }; -EXPORT_SYMBOL_GPL(edac_class); +EXPORT_SYMBOL_GPL(edac_subsys); /* return pointer to the 'edac' node in sysfs */ -struct sysdev_class *edac_get_sysfs_class(void) +struct bus_type *edac_get_sysfs_subsys(void) { int err = 0; - if (atomic_read(&edac_class_valid)) + if (atomic_read(&edac_subsys_valid)) goto out; /* create the /sys/devices/system/edac directory */ - err = sysdev_class_register(&edac_class); + err = subsys_system_register(&edac_subsys, NULL); if (err) { printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n"); return NULL; } out: - atomic_inc(&edac_class_valid); - return &edac_class; + atomic_inc(&edac_subsys_valid); + return &edac_subsys; } -EXPORT_SYMBOL_GPL(edac_get_sysfs_class); +EXPORT_SYMBOL_GPL(edac_get_sysfs_subsys); -void edac_put_sysfs_class(void) +void edac_put_sysfs_subsys(void) { /* last user unregisters it */ - if (atomic_dec_and_test(&edac_class_valid)) - sysdev_class_unregister(&edac_class); + if (atomic_dec_and_test(&edac_subsys_valid)) + bus_unregister(&edac_subsys); } -EXPORT_SYMBOL_GPL(edac_put_sysfs_class); +EXPORT_SYMBOL_GPL(edac_put_sysfs_subsys); diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c index 73c3e26..885e8ad 100644 --- a/drivers/edac/mce_amd_inj.c +++ b/drivers/edac/mce_amd_inj.c @@ -11,7 +11,6 @@ */ #include -#include #include #include #include @@ -116,14 +115,14 @@ static struct edac_mce_attr *sysfs_attrs[] = { &mce_attr_status, &mce_attr_misc, static int __init edac_init_mce_inject(void) { - struct sysdev_class *edac_class = NULL; + struct bus_type *edac_subsys = NULL; int i, err = 0; - edac_class = edac_get_sysfs_class(); - if (!edac_class) + edac_subsys = edac_get_sysfs_subsys(); + if (!edac_subsys) return -EINVAL; - mce_kobj = kobject_create_and_add("mce", &edac_class->kset.kobj); + mce_kobj = kobject_create_and_add("mce", &edac_subsys->dev_root->kobj); if (!mce_kobj) { printk(KERN_ERR "Error creating a mce kset.\n"); err = -ENOMEM; @@ -147,7 +146,7 @@ err_sysfs_create: kobject_del(mce_kobj); err_mce_kobj: - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); return err; } @@ -161,7 +160,7 @@ static void __exit edac_exit_mce_inject(void) kobject_del(mce_kobj); - edac_put_sysfs_class(); + edac_put_sysfs_subsys(); } module_init(edac_init_mce_inject); diff --git a/include/linux/edac.h b/include/linux/edac.h index 055b248..1cd3947 100644 --- a/include/linux/edac.h +++ b/include/linux/edac.h @@ -13,7 +13,7 @@ #define _LINUX_EDAC_H_ #include -#include +#include #define EDAC_OPSTATE_INVAL -1 #define EDAC_OPSTATE_POLL 0 @@ -23,12 +23,12 @@ extern int edac_op_state; extern int edac_err_assert; extern atomic_t edac_handlers; -extern struct sysdev_class edac_class; +extern struct bus_type edac_subsys; extern int edac_handler_set(void); extern void edac_atomic_assert_error(void); -extern struct sysdev_class *edac_get_sysfs_class(void); -extern void edac_put_sysfs_class(void); +extern struct bus_type *edac_get_sysfs_subsys(void); +extern void edac_put_sysfs_subsys(void); static inline void opstate_init(void) { -- cgit v0.10.2 From 15916a123e59b84d2fdfcccac84c99d1777f2a45 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Dec 2011 15:26:15 -0800 Subject: ibm_rtl: convert sysdev_class to a regular subsystem After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Cc: Matthew Garrett Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c index 811d436..42a7d60 100644 --- a/drivers/platform/x86/ibm_rtl.c +++ b/drivers/platform/x86/ibm_rtl.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -165,22 +164,22 @@ static int ibm_rtl_write(u8 value) return ret; } -static ssize_t rtl_show_version(struct sysdev_class * dev, - struct sysdev_class_attribute *attr, +static ssize_t rtl_show_version(struct device *dev, + struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", (int)ioread8(&rtl_table->version)); } -static ssize_t rtl_show_state(struct sysdev_class *dev, - struct sysdev_class_attribute *attr, +static ssize_t rtl_show_state(struct device *dev, + struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", ioread8(&rtl_table->rt_status)); } -static ssize_t rtl_set_state(struct sysdev_class *dev, - struct sysdev_class_attribute *attr, +static ssize_t rtl_set_state(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -205,27 +204,28 @@ static ssize_t rtl_set_state(struct sysdev_class *dev, return ret; } -static struct sysdev_class class_rtl = { +static struct bus_type rtl_subsys = { .name = "ibm_rtl", + .dev_name = "ibm_rtl", }; -static SYSDEV_CLASS_ATTR(version, S_IRUGO, rtl_show_version, NULL); -static SYSDEV_CLASS_ATTR(state, 0600, rtl_show_state, rtl_set_state); +static DEVICE_ATTR(version, S_IRUGO, rtl_show_version, NULL); +static DEVICE_ATTR(state, 0600, rtl_show_state, rtl_set_state); -static struct sysdev_class_attribute *rtl_attributes[] = { - &attr_version, - &attr_state, +static struct device_attribute *rtl_attributes[] = { + &dev_attr_version, + &dev_attr_state, NULL }; static int rtl_setup_sysfs(void) { int ret, i; - ret = sysdev_class_register(&class_rtl); + ret = subsys_system_register(&rtl_subsys, NULL); if (!ret) { for (i = 0; rtl_attributes[i]; i ++) - sysdev_class_create_file(&class_rtl, rtl_attributes[i]); + device_create_file(rtl_subsys.dev_root, rtl_attributes[i]); } return ret; } @@ -233,8 +233,8 @@ static int rtl_setup_sysfs(void) { static void rtl_teardown_sysfs(void) { int i; for (i = 0; rtl_attributes[i]; i ++) - sysdev_class_remove_file(&class_rtl, rtl_attributes[i]); - sysdev_class_unregister(&class_rtl); + device_remove_file(rtl_subsys.dev_root, rtl_attributes[i]); + bus_unregister(&rtl_subsys); } -- cgit v0.10.2 From d369a5d8fc70710236ae2d06a0e42dce483712df Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Dec 2011 15:28:51 -0800 Subject: clocksource: convert sysdev_class to a regular subsystem After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Cc: John Stultz Cc: Thomas Gleixner Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index cf52fda..3f5c851 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -23,8 +23,8 @@ * o Allow clocksource drivers to be unregistered */ +#include #include -#include #include #include #include /* for spin_unlock_irq() using preempt_count() m68k */ @@ -754,8 +754,8 @@ EXPORT_SYMBOL(clocksource_unregister); * Provides sysfs interface for listing current clocksource. */ static ssize_t -sysfs_show_current_clocksources(struct sys_device *dev, - struct sysdev_attribute *attr, char *buf) +sysfs_show_current_clocksources(struct device *dev, + struct device_attribute *attr, char *buf) { ssize_t count = 0; @@ -775,8 +775,8 @@ sysfs_show_current_clocksources(struct sys_device *dev, * Takes input from sysfs interface for manually overriding the default * clocksource selection. */ -static ssize_t sysfs_override_clocksource(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t sysfs_override_clocksource(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { size_t ret = count; @@ -809,8 +809,8 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev, * Provides sysfs interface for listing registered clocksources */ static ssize_t -sysfs_show_available_clocksources(struct sys_device *dev, - struct sysdev_attribute *attr, +sysfs_show_available_clocksources(struct device *dev, + struct device_attribute *attr, char *buf) { struct clocksource *src; @@ -839,35 +839,36 @@ sysfs_show_available_clocksources(struct sys_device *dev, /* * Sysfs setup bits: */ -static SYSDEV_ATTR(current_clocksource, 0644, sysfs_show_current_clocksources, +static DEVICE_ATTR(current_clocksource, 0644, sysfs_show_current_clocksources, sysfs_override_clocksource); -static SYSDEV_ATTR(available_clocksource, 0444, +static DEVICE_ATTR(available_clocksource, 0444, sysfs_show_available_clocksources, NULL); -static struct sysdev_class clocksource_sysclass = { +static struct bus_type clocksource_subsys = { .name = "clocksource", + .dev_name = "clocksource", }; -static struct sys_device device_clocksource = { +static struct device device_clocksource = { .id = 0, - .cls = &clocksource_sysclass, + .bus = &clocksource_subsys, }; static int __init init_clocksource_sysfs(void) { - int error = sysdev_class_register(&clocksource_sysclass); + int error = subsys_system_register(&clocksource_subsys, NULL); if (!error) - error = sysdev_register(&device_clocksource); + error = device_register(&device_clocksource); if (!error) - error = sysdev_create_file( + error = device_create_file( &device_clocksource, - &attr_current_clocksource); + &dev_attr_current_clocksource); if (!error) - error = sysdev_create_file( + error = device_create_file( &device_clocksource, - &attr_available_clocksource); + &dev_attr_available_clocksource); return error; } -- cgit v0.10.2 From 070680218379e15c1901f4bf21b98e3cbf12b527 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 14 Dec 2011 15:32:50 -0800 Subject: xen-balloon: convert sysdev_class to a regular subsystem After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Cc: Jeremy Fitzhardinge Cc: Konrad Rzeszutek Wilk Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index 9cc2259..3832e30 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -46,9 +45,9 @@ #define BALLOON_CLASS_NAME "xen_memory" -static struct sys_device balloon_sysdev; +static struct device balloon_dev; -static int register_balloon(struct sys_device *sysdev); +static int register_balloon(struct device *dev); /* React to a change in the target key */ static void watch_target(struct xenbus_watch *watch, @@ -98,9 +97,9 @@ static int __init balloon_init(void) pr_info("xen-balloon: Initialising balloon driver.\n"); - register_balloon(&balloon_sysdev); + register_balloon(&balloon_dev); - register_xen_selfballooning(&balloon_sysdev); + register_xen_selfballooning(&balloon_dev); register_xenstore_notifier(&xenstore_notifier); @@ -117,31 +116,31 @@ static void balloon_exit(void) module_exit(balloon_exit); #define BALLOON_SHOW(name, format, args...) \ - static ssize_t show_##name(struct sys_device *dev, \ - struct sysdev_attribute *attr, \ + static ssize_t show_##name(struct device *dev, \ + struct device_attribute *attr, \ char *buf) \ { \ return sprintf(buf, format, ##args); \ } \ - static SYSDEV_ATTR(name, S_IRUGO, show_##name, NULL) + static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages)); BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low)); BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high)); -static SYSDEV_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); -static SYSDEV_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); -static SYSDEV_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); -static SYSDEV_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); +static DEVICE_ULONG_ATTR(schedule_delay, 0444, balloon_stats.schedule_delay); +static DEVICE_ULONG_ATTR(max_schedule_delay, 0644, balloon_stats.max_schedule_delay); +static DEVICE_ULONG_ATTR(retry_count, 0444, balloon_stats.retry_count); +static DEVICE_ULONG_ATTR(max_retry_count, 0644, balloon_stats.max_retry_count); -static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr, +static ssize_t show_target_kb(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%lu\n", PAGES2KB(balloon_stats.target_pages)); } -static ssize_t store_target_kb(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_target_kb(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -158,11 +157,11 @@ static ssize_t store_target_kb(struct sys_device *dev, return count; } -static SYSDEV_ATTR(target_kb, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(target_kb, S_IRUGO | S_IWUSR, show_target_kb, store_target_kb); -static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr, +static ssize_t show_target(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%llu\n", @@ -170,8 +169,8 @@ static ssize_t show_target(struct sys_device *dev, struct sysdev_attribute *attr << PAGE_SHIFT); } -static ssize_t store_target(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_target(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -188,23 +187,23 @@ static ssize_t store_target(struct sys_device *dev, return count; } -static SYSDEV_ATTR(target, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(target, S_IRUGO | S_IWUSR, show_target, store_target); -static struct sysdev_attribute *balloon_attrs[] = { - &attr_target_kb, - &attr_target, - &attr_schedule_delay.attr, - &attr_max_schedule_delay.attr, - &attr_retry_count.attr, - &attr_max_retry_count.attr +static struct device_attribute *balloon_attrs[] = { + &dev_attr_target_kb, + &dev_attr_target, + &dev_attr_schedule_delay.attr, + &dev_attr_max_schedule_delay.attr, + &dev_attr_retry_count.attr, + &dev_attr_max_retry_count.attr }; static struct attribute *balloon_info_attrs[] = { - &attr_current_kb.attr, - &attr_low_kb.attr, - &attr_high_kb.attr, + &dev_attr_current_kb.attr, + &dev_attr_low_kb.attr, + &dev_attr_high_kb.attr, NULL }; @@ -213,34 +212,35 @@ static struct attribute_group balloon_info_group = { .attrs = balloon_info_attrs }; -static struct sysdev_class balloon_sysdev_class = { - .name = BALLOON_CLASS_NAME +static struct bus_type balloon_subsys = { + .name = BALLOON_CLASS_NAME, + .dev_name = BALLOON_CLASS_NAME, }; -static int register_balloon(struct sys_device *sysdev) +static int register_balloon(struct device *dev) { int i, error; - error = sysdev_class_register(&balloon_sysdev_class); + error = bus_register(&balloon_subsys); if (error) return error; - sysdev->id = 0; - sysdev->cls = &balloon_sysdev_class; + dev->id = 0; + dev->bus = &balloon_subsys; - error = sysdev_register(sysdev); + error = device_register(dev); if (error) { - sysdev_class_unregister(&balloon_sysdev_class); + bus_unregister(&balloon_subsys); return error; } for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) { - error = sysdev_create_file(sysdev, balloon_attrs[i]); + error = device_create_file(dev, balloon_attrs[i]); if (error) goto fail; } - error = sysfs_create_group(&sysdev->kobj, &balloon_info_group); + error = sysfs_create_group(&dev->kobj, &balloon_info_group); if (error) goto fail; @@ -248,9 +248,9 @@ static int register_balloon(struct sys_device *sysdev) fail: while (--i >= 0) - sysdev_remove_file(sysdev, balloon_attrs[i]); - sysdev_unregister(sysdev); - sysdev_class_unregister(&balloon_sysdev_class); + device_remove_file(dev, balloon_attrs[i]); + device_unregister(dev); + bus_unregister(&balloon_subsys); return error; } diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c index d93c708..b7b9e95 100644 --- a/drivers/xen/xen-selfballoon.c +++ b/drivers/xen/xen-selfballoon.c @@ -266,21 +266,20 @@ static void selfballoon_process(struct work_struct *work) #ifdef CONFIG_SYSFS -#include #include #define SELFBALLOON_SHOW(name, format, args...) \ - static ssize_t show_##name(struct sys_device *dev, \ - struct sysdev_attribute *attr, \ - char *buf) \ + static ssize_t show_##name(struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ { \ return sprintf(buf, format, ##args); \ } SELFBALLOON_SHOW(selfballooning, "%d\n", xen_selfballooning_enabled); -static ssize_t store_selfballooning(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_selfballooning(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -303,13 +302,13 @@ static ssize_t store_selfballooning(struct sys_device *dev, return count; } -static SYSDEV_ATTR(selfballooning, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(selfballooning, S_IRUGO | S_IWUSR, show_selfballooning, store_selfballooning); SELFBALLOON_SHOW(selfballoon_interval, "%d\n", selfballoon_interval); -static ssize_t store_selfballoon_interval(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_selfballoon_interval(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -325,13 +324,13 @@ static ssize_t store_selfballoon_interval(struct sys_device *dev, return count; } -static SYSDEV_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(selfballoon_interval, S_IRUGO | S_IWUSR, show_selfballoon_interval, store_selfballoon_interval); SELFBALLOON_SHOW(selfballoon_downhys, "%d\n", selfballoon_downhysteresis); -static ssize_t store_selfballoon_downhys(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_selfballoon_downhys(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -347,14 +346,14 @@ static ssize_t store_selfballoon_downhys(struct sys_device *dev, return count; } -static SYSDEV_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(selfballoon_downhysteresis, S_IRUGO | S_IWUSR, show_selfballoon_downhys, store_selfballoon_downhys); SELFBALLOON_SHOW(selfballoon_uphys, "%d\n", selfballoon_uphysteresis); -static ssize_t store_selfballoon_uphys(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_selfballoon_uphys(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -370,14 +369,14 @@ static ssize_t store_selfballoon_uphys(struct sys_device *dev, return count; } -static SYSDEV_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(selfballoon_uphysteresis, S_IRUGO | S_IWUSR, show_selfballoon_uphys, store_selfballoon_uphys); SELFBALLOON_SHOW(selfballoon_min_usable_mb, "%d\n", selfballoon_min_usable_mb); -static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_selfballoon_min_usable_mb(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -393,7 +392,7 @@ static ssize_t store_selfballoon_min_usable_mb(struct sys_device *dev, return count; } -static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR, show_selfballoon_min_usable_mb, store_selfballoon_min_usable_mb); @@ -401,8 +400,8 @@ static SYSDEV_ATTR(selfballoon_min_usable_mb, S_IRUGO | S_IWUSR, #ifdef CONFIG_FRONTSWAP SELFBALLOON_SHOW(frontswap_selfshrinking, "%d\n", frontswap_selfshrinking); -static ssize_t store_frontswap_selfshrinking(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_frontswap_selfshrinking(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -424,13 +423,13 @@ static ssize_t store_frontswap_selfshrinking(struct sys_device *dev, return count; } -static SYSDEV_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(frontswap_selfshrinking, S_IRUGO | S_IWUSR, show_frontswap_selfshrinking, store_frontswap_selfshrinking); SELFBALLOON_SHOW(frontswap_inertia, "%d\n", frontswap_inertia); -static ssize_t store_frontswap_inertia(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_frontswap_inertia(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -447,13 +446,13 @@ static ssize_t store_frontswap_inertia(struct sys_device *dev, return count; } -static SYSDEV_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(frontswap_inertia, S_IRUGO | S_IWUSR, show_frontswap_inertia, store_frontswap_inertia); SELFBALLOON_SHOW(frontswap_hysteresis, "%d\n", frontswap_hysteresis); -static ssize_t store_frontswap_hysteresis(struct sys_device *dev, - struct sysdev_attribute *attr, +static ssize_t store_frontswap_hysteresis(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { @@ -469,21 +468,21 @@ static ssize_t store_frontswap_hysteresis(struct sys_device *dev, return count; } -static SYSDEV_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR, +static DEVICE_ATTR(frontswap_hysteresis, S_IRUGO | S_IWUSR, show_frontswap_hysteresis, store_frontswap_hysteresis); #endif /* CONFIG_FRONTSWAP */ static struct attribute *selfballoon_attrs[] = { - &attr_selfballooning.attr, - &attr_selfballoon_interval.attr, - &attr_selfballoon_downhysteresis.attr, - &attr_selfballoon_uphysteresis.attr, - &attr_selfballoon_min_usable_mb.attr, + &dev_attr_selfballooning.attr, + &dev_attr_selfballoon_interval.attr, + &dev_attr_selfballoon_downhysteresis.attr, + &dev_attr_selfballoon_uphysteresis.attr, + &dev_attr_selfballoon_min_usable_mb.attr, #ifdef CONFIG_FRONTSWAP - &attr_frontswap_selfshrinking.attr, - &attr_frontswap_hysteresis.attr, - &attr_frontswap_inertia.attr, + &dev_attr_frontswap_selfshrinking.attr, + &dev_attr_frontswap_hysteresis.attr, + &dev_attr_frontswap_inertia.attr, #endif NULL }; @@ -494,12 +493,12 @@ static struct attribute_group selfballoon_group = { }; #endif -int register_xen_selfballooning(struct sys_device *sysdev) +int register_xen_selfballooning(struct device *dev) { int error = -1; #ifdef CONFIG_SYSFS - error = sysfs_create_group(&sysdev->kobj, &selfballoon_group); + error = sysfs_create_group(&dev->kobj, &selfballoon_group); #endif return error; } diff --git a/include/xen/balloon.h b/include/xen/balloon.h index d29c153..cc2e1a7 100644 --- a/include/xen/balloon.h +++ b/include/xen/balloon.h @@ -29,11 +29,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem); void free_xenballooned_pages(int nr_pages, struct page **pages); -struct sys_device; +struct device; #ifdef CONFIG_XEN_SELFBALLOONING -extern int register_xen_selfballooning(struct sys_device *sysdev); +extern int register_xen_selfballooning(struct device *dev); #else -static inline int register_xen_selfballooning(struct sys_device *sysdev) +static inline int register_xen_selfballooning(struct device *dev) { return -ENOSYS; } -- cgit v0.10.2