[kernel] r19662 - in dists/sid/linux/debian/patches: . features/all

Ben Hutchings benh at alioth.debian.org
Sat Dec 29 13:04:22 UTC 2012


Author: benh
Date: Sat Dec 29 13:04:21 2012
New Revision: 19662

Log:
Add some macros to aid backporting drivers

Added:
   dists/sid/linux/debian/patches/features/all/I2C-Add-helper-macro-for-i2c_driver-boilerplate.patch
   dists/sid/linux/debian/patches/features/all/PCI-Add-helper-macro-for-pci_register_driver-boilerp.patch
   dists/sid/linux/debian/patches/features/all/USB-Add-helper-macro-for-usb_driver-boilerplate.patch
   dists/sid/linux/debian/patches/features/all/drivercore-Generalize-module_platform_driver.patch
Modified:
   dists/sid/linux/debian/patches/series

Added: dists/sid/linux/debian/patches/features/all/I2C-Add-helper-macro-for-i2c_driver-boilerplate.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux/debian/patches/features/all/I2C-Add-helper-macro-for-i2c_driver-boilerplate.patch	Sat Dec 29 13:04:21 2012	(r19662)
@@ -0,0 +1,46 @@
+From: Lars-Peter Clausen <lars at metafoo.de>
+Date: Wed, 16 Nov 2011 10:13:36 +0100
+Subject: I2C: Add helper macro for i2c_driver boilerplate
+
+commit 7c92784a546d2945b6d6973a30f7134be78eb7a4 upstream.
+
+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 <lars at metafoo.de>
+Acked-by: Grant Likely <grant.likely at secretlab.ca>
+Acked-by: Jonathan Cameron <jic23 at cam.ac.uk>
+Acked-by: Wolfram Sang <w.sang at pengutronix.de>
+Acked-by: Jean Delvare <khali at linux-fr.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
+---
+ include/linux/i2c.h |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+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__ */
+ 

Added: dists/sid/linux/debian/patches/features/all/PCI-Add-helper-macro-for-pci_register_driver-boilerp.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux/debian/patches/features/all/PCI-Add-helper-macro-for-pci_register_driver-boilerp.patch	Sat Dec 29 13:04:21 2012	(r19662)
@@ -0,0 +1,47 @@
+From: Greg Kroah-Hartman <gregkh at suse.de>
+Date: Fri, 18 Nov 2011 10:12:49 -0800
+Subject: PCI: Add helper macro for pci_register_driver boilerplate
+
+commit aad4f4000cecec9c80b5f9aff91043dc104d61a0 upstream.
+
+This patch introduces the module_pci_driver macro which is a convenience
+macro for PCI 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 PCI driver. By using this macro it is possible
+to eliminate a few lines of boilerplate code per PCI driver.
+
+Based on work done by Lars-Peter Clausen <lars at metafoo.de> for other
+busses (i2c and spi).
+
+Cc: Lars-Peter Clausen <lars at metafoo.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
+Acked-by: Jesse Barnes <jbarnes at virtuousgeek.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
+---
+ include/linux/pci.h |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/include/linux/pci.h b/include/linux/pci.h
+index a16b1df..d4afd70 100644
+--- a/include/linux/pci.h
++++ b/include/linux/pci.h
+@@ -946,6 +946,19 @@ int __must_check __pci_register_driver(struct pci_driver *, struct module *,
+ 	__pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
+ 
+ void pci_unregister_driver(struct pci_driver *dev);
++
++/**
++ * module_pci_driver() - Helper macro for registering a PCI driver
++ * @__pci_driver: pci_driver struct
++ *
++ * Helper macro for PCI 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_pci_driver(__pci_driver) \
++	module_driver(__pci_driver, pci_register_driver, \
++		       pci_unregister_driver)
++
+ void pci_remove_behind_bridge(struct pci_dev *dev);
+ struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
+ int pci_add_dynid(struct pci_driver *drv,

Added: dists/sid/linux/debian/patches/features/all/USB-Add-helper-macro-for-usb_driver-boilerplate.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux/debian/patches/features/all/USB-Add-helper-macro-for-usb_driver-boilerplate.patch	Sat Dec 29 13:04:21 2012	(r19662)
@@ -0,0 +1,44 @@
+From: Greg Kroah-Hartman <gregkh at suse.de>
+Date: Thu, 17 Nov 2011 14:38:33 -0800
+Subject: USB: Add helper macro for usb_driver boilerplate
+
+commit f3a6a4b6cfc80e57bf16bb12f9425bec1a5731a9 upstream.
+
+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 <lars at metafoo.de> for other
+busses (i2c and spi).
+
+Cc: Lars-Peter Clausen <lars at metafoo.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
+---
+ include/linux/usb.h |   12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+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 *);

Added: dists/sid/linux/debian/patches/features/all/drivercore-Generalize-module_platform_driver.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux/debian/patches/features/all/drivercore-Generalize-module_platform_driver.patch	Sat Dec 29 13:04:21 2012	(r19662)
@@ -0,0 +1,80 @@
+From: Lars-Peter Clausen <lars at metafoo.de>
+Date: Wed, 16 Nov 2011 10:13:35 +0100
+Subject: drivercore: Generalize module_platform_driver
+
+commit 907d0ed1c84114d4e8dafd66af982515d3739c90 upstream.
+
+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 <lars at metafoo.de>
+Acked-by: Grant Likely <grant.likely at secretlab.ca>
+Acked-by: Jonathan Cameron <jic23 at kernel.org>
+Acked-by: Wolfram Sang <w.sang at pengutronix.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
+---
+ include/linux/device.h          |   21 +++++++++++++++++++++
+ include/linux/platform_device.h |   12 ++----------
+ 2 files changed, 23 insertions(+), 10 deletions(-)
+
+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 *),

Modified: dists/sid/linux/debian/patches/series
==============================================================================
--- dists/sid/linux/debian/patches/series	Sat Dec 29 13:02:12 2012	(r19661)
+++ dists/sid/linux/debian/patches/series	Sat Dec 29 13:04:21 2012	(r19662)
@@ -434,3 +434,9 @@
 bugfix/all/megaraid_sas-fix-memory-leak-if-SGL-has-zero-length-entries.patch
 debian/audit-increase-AUDIT_NAMES.patch
 features/all/asix-Adds-support-for-Lenovo-10-100-USB-dongle.patch
+
+# Add macros to aid backporting drivers
+features/all/drivercore-Generalize-module_platform_driver.patch
+features/all/I2C-Add-helper-macro-for-i2c_driver-boilerplate.patch
+features/all/USB-Add-helper-macro-for-usb_driver-boilerplate.patch
+features/all/PCI-Add-helper-macro-for-pci_register_driver-boilerp.patch



More information about the Kernel-svn-changes mailing list