mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Alexander Shiyan" <shc_work@mail.ru>
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re[2]: [PATCH] Extend device_platform_driver macro
Date: Sat, 09 Mar 2013 19:19:31 +0400	[thread overview]
Message-ID: <1362842371.794592639@f291.mail.ru> (raw)
In-Reply-To: <20130309151230.GK1906@pengutronix.de>

> Hi Alexander,
> 
> On Fri, Mar 08, 2013 at 01:05:14PM +0400, Alexander Shiyan wrote:
> > This patch extends device_platform_driver macro, so now we allow
> > use it with various init levels and subsystems.
> > 
> > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> > ---
> >  include/driver.h | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/driver.h b/include/driver.h
> > index 46c56c0..b891f80 100644
> > --- a/include/driver.h
> > +++ b/include/driver.h
> > @@ -395,16 +395,19 @@ 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
> > +/* register_driver_macro() - 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 drv ## _register(void)	\
> > -	{						\
> > -		return platform_driver_register(&drv);	\
> > -	}						\
> > -	device_initcall(drv ## _register)
> > +#define register_driver_macro(level,subsystem,drv)		\
> > +	static int __init drv##_register(void)			\
> > +	{							\
> > +		return subsystem##_driver_register(&drv);	\
> > +	}							\
> > +	level##_initcall(drv##_register)
> 
> So the usage would look like:
> 
> register_driver_macro(device, i2c, &mc_driver)
> 
> ?
> 
> I'm not sure if I like this. I'm a bit concerned about being able
> to grep for for example i2c_register_driver. This would become
> 
> wcgrep register_driver_macro | grep i2c
> 
> or similar.

You are skip 2 important lines:
#define device_platform_driver(drv) \
 register_driver_macro(device,platform,drv)

For i2c we can define new macro like this:
#define device_i2c_driver(drv) \
 register_driver_macro(device,i2c,drv)

then use device_i2c_driver(&foo) in the driver.

---
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-03-09 15:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-08  9:05 Alexander Shiyan
2013-03-09 15:12 ` Sascha Hauer
2013-03-09 15:19   ` Alexander Shiyan [this message]
2013-03-09 20:46     ` Uwe Kleine-König
2013-03-09 21:10       ` Re[2]: " Alexander Shiyan
2013-03-09 18:36   ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1362842371.794592639@f291.mail.ru \
    --to=shc_work@mail.ru \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox