Commit ca5d2485 authored by Andrew F. Davis's avatar Andrew F. Davis Committed by Mark Brown

spi: Add THIS_MODULE to spi_driver in SPI core

Add spi_register_driver helper macro that adds THIS_MODULE to
spi_driver for the registering driver. We rename and modify
the existing spi_register_driver to enable this.
Signed-off-by: default avatarAndrew F. Davis <afd@ti.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6ff33f39
...@@ -305,12 +305,13 @@ static void spi_drv_shutdown(struct device *dev) ...@@ -305,12 +305,13 @@ static void spi_drv_shutdown(struct device *dev)
} }
/** /**
* spi_register_driver - register a SPI driver * __spi_register_driver - register a SPI driver
* @sdrv: the driver to register * @sdrv: the driver to register
* Context: can sleep * Context: can sleep
*/ */
int spi_register_driver(struct spi_driver *sdrv) int __spi_register_driver(struct module *owner, struct spi_driver *sdrv)
{ {
sdrv->driver.owner = owner;
sdrv->driver.bus = &spi_bus_type; sdrv->driver.bus = &spi_bus_type;
if (sdrv->probe) if (sdrv->probe)
sdrv->driver.probe = spi_drv_probe; sdrv->driver.probe = spi_drv_probe;
...@@ -320,7 +321,7 @@ int spi_register_driver(struct spi_driver *sdrv) ...@@ -320,7 +321,7 @@ int spi_register_driver(struct spi_driver *sdrv)
sdrv->driver.shutdown = spi_drv_shutdown; sdrv->driver.shutdown = spi_drv_shutdown;
return driver_register(&sdrv->driver); return driver_register(&sdrv->driver);
} }
EXPORT_SYMBOL_GPL(spi_register_driver); EXPORT_SYMBOL_GPL(__spi_register_driver);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
...@@ -250,7 +250,7 @@ static inline struct spi_driver *to_spi_driver(struct device_driver *drv) ...@@ -250,7 +250,7 @@ static inline struct spi_driver *to_spi_driver(struct device_driver *drv)
return drv ? container_of(drv, struct spi_driver, driver) : NULL; return drv ? container_of(drv, struct spi_driver, driver) : NULL;
} }
extern int spi_register_driver(struct spi_driver *sdrv); extern int __spi_register_driver(struct module *owner, struct spi_driver *sdrv);
/** /**
* spi_unregister_driver - reverse effect of spi_register_driver * spi_unregister_driver - reverse effect of spi_register_driver
...@@ -263,6 +263,10 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) ...@@ -263,6 +263,10 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
driver_unregister(&sdrv->driver); driver_unregister(&sdrv->driver);
} }
/* use a define to avoid include chaining to get THIS_MODULE */
#define spi_register_driver(driver) \
__spi_register_driver(THIS_MODULE, driver)
/** /**
* module_spi_driver() - Helper macro for registering a SPI driver * module_spi_driver() - Helper macro for registering a SPI driver
* @__spi_driver: spi_driver struct * @__spi_driver: spi_driver struct
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment