i2c-core.c: make some code static
PATCH 1/1 i2c-core.c: make some code static
This patch makes some needlessly global code static.
---
drivers/i2c/i2c-core.c | 79 ++++++++++++++++++++--------------------- include/linux/i2c.h | 2 - 2 files changed, 39 insertions(+), 42 deletions(-)
include/linux/i2c.h renamed from include/linux/i2c.h.old +0 -2
@@ -134,8 +134,6 @@ };#define to_i2c_driver (d) container_of(d, struct i2c_driver, driver) -extern struct bus_type i2c_bus_type; -#define I2C_NAME_SIZE 50/*
drivers/i2c/i2c-core.c renamed from drivers/i2c/i2c-core.c.old +39 -40
119 lines not on this page · raw message
Hi Adrian,
Quoted 77 lines
This patch makes some needlessly global code static. (...)
drivers/i2c/i2c-core.c renamed from drivers/i2c/i2c-core.c.old +31
-25@@ -38,12 +38,43 @@static DECLARE_MUTEX (core_lists);static DEFINE_IDR (i2c_adapter_idr); -int i2c_device_probe(struct device *dev) +/* match always succeeds, as we want the probe() to tell if we really accept this match */ +static int i2c_device_match(struct device *dev, struct device_driver *drv) +{ +return 1 ; +} + +static int i2c_bus_suspend (struct device * dev,pm_message_t state) +{ +int rc =0 ; + +if (dev->driver && dev->driver->suspend) + rc = dev->driver->suspend (dev,state,0 ); +return rc; +} + +static int i2c_bus_resume (struct device * dev) +{ +int rc =0 ; + +if (dev->driver && dev->driver->resume) + rc = dev->driver->resume (dev,0 ); +return rc; +} + +static struct bus_type i2c_bus_type = { + .name ="i2c" , + .match = i2c_device_match, + .suspend = i2c_bus_suspend, + .resume = i2c_bus_resume, +}; + +static int i2c_device_probe (struct device *dev) {return -ENODEV ; } -int i2c_device_remove (struct device *dev) +static int i2c_device_remove (struct device *dev) {return 0 ; }@@ -523,38 +554,6 @@up(&adap->clist_lock); } - -/* match always succeeds, as we want the probe() to tell if we really accept this match */ -static int i2c_device_match(struct device *dev, struct device_driver *drv) -{ -return 1 ; -} - -static int i2c_bus_suspend (struct device * dev,pm_message_t state) -{ -int rc =0 ; - -if (dev->driver && dev->driver->suspend) - rc = dev->driver->suspend (dev,state,0 ); -return rc; -} - -static int i2c_bus_resume (struct device * dev) -{ -int rc =0 ; - -if (dev->driver && dev->driver->resume) - rc = dev->driver->resume (dev,0 ); -return rc; -} -
drivers/i2c/i2c-core.c line 559
Quoted 10 lines
drivers/i2c/i2c-core.c renamed from drivers/i2c/i2c-core.c.old +0
-7-struct bus_type i2c_bus_type = { - .name ="i2c" , - .match = i2c_device_match, - .suspend = i2c_bus_suspend, - .resume = i2c_bus_resume, -}; -static int __init i2c_init (void ) {int retval;
Is moving that code around really necessary? Looks to me like only the i2c_bus_type structure needs to be moved.
Thanks,
Signature · 1 line
Jean Delvare
Quoted 1 line · Jean Delvare
Hi Adrian,
Hi Jean,
Quoted 30 lines
...
Quoted 29 lines
-/* match always succeeds, as we want the
probe()to tell if we really accept this match */ -static inti2c_device_match(struct device *dev, struct device_driver *drv)-{drivers/i2c/i2c-core.c renamed from drivers/i2c/i2c-core.c.old +0
-26-return 1 ; -} - -static int i2c_bus_suspend (struct device * dev,pm_message_t state) -{ -int rc =0 ; - -if (dev->driver && dev->driver->suspend) - rc = dev->driver->suspend (dev,state,0 ); -return rc; -} - -static int i2c_bus_resume (struct device * dev) -{ -int rc =0 ; - -if (dev->driver && dev->driver->resume) - rc = dev->driver->resume (dev,0 ); -return rc; -} - -struct bus_type i2c_bus_type = { - .name ="i2c" , - .match = i2c_device_match, - .suspend = i2c_bus_suspend, - .resume = i2c_bus_resume,
Quoted 8 lines
drivers/i2c/i2c-core.c line 559
Quoted 5 lines
drivers/i2c/i2c-core.c renamed from drivers/i2c/i2c-core.c.old +0
-2-}; -static int __init i2c_init (void ) {int retval;Is moving that code around really necessary? Looks to me like only the
i2c_bus_typestructure needs to be moved.
i2c_bus_type requires i2c_device_match, i2c_bus_suspend and i2c_bus_resume...
Quoted 2 lines
Thanks,
Jean Delvare
cu
Adrian
Signature · 4 lines
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon SeedHi Adrian,
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/i2c/i2c-core.c renamed from drivers/i2c/i2c-core.c.old +0
-6-struct bus_type i2c_bus_type = { - .name ="i2c" , - .match = i2c_device_match, - .suspend = i2c_bus_suspend, - .resume = i2c_bus_resume, -};(...)
Quoted 5 lines
Quoted 2 lines
Is moving that code around really necessary? Looks to me like only the
i2c_bus_typestructure needs to be moved.
i2c_bus_typerequiresi2c_device_match,i2c_bus_suspendandi2c_bus_resume...
Oops, seems I missed the obvious here :/
Sorry for the noise. I guess I better get some sleep now...
Signature · 1 line
Jean Delvare
Greg KH
AppliedQuoted 3 lines · Adrian Bunk
This patch makes some needlessly global code static.
Signed-off-by Adrian Bunk <[email protected]>
Applied, thanks.
greg k-h