[PATCH 1/2] Introduce device_platform_driver() macro

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 11 04:38:38 EST 2013


On Fri, Feb 08, 2013 at 10:07:01PM +0400, Alexander Shiyan wrote:
> device_platform_driver() - Helper macro for drivers that don't do
> anything special in module registration. This eliminates a lot of
> boilerplate. Driver registration will called on device_initcall.
> 
> Signed-off-by: Alexander Shiyan <shc_work at mail.ru>

Good move ;)

> ---
>  include/driver.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/driver.h b/include/driver.h
> index 31f5d69..d8ac66c 100644
> --- a/include/driver.h
> +++ b/include/driver.h
> @@ -390,6 +390,18 @@ extern struct list_head bus_list;
>  extern struct bus_type platform_bus;
>  
>  int platform_driver_register(struct driver_d *drv);
> +
> +/* device_platform_driver() - Helper macro for drivers that don't do
> + * anything special in module registration. This eliminates a lot of
> + * boilerplate. Each module may only use this macro once.
> + */
> +#define device_platform_driver(drv)				\
> +	static int __init device_platform_driver_init(void)	\
> +	{							\
> +		return platform_driver_register(&drv);		\
> +	}							\
> +	device_initcall(device_platform_driver_init)
> +

Can we use drv##_init as name for the function instead? This way the
driver name is in the function name and objdumps and backtraces would
have a bit more context.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list