mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions
@ 2011-02-16 22:23 Marc Kleine-Budde
  2011-02-16 22:56 ` Greg KH
  2011-02-17  8:47 ` Uwe Kleine-König
  0 siblings, 2 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2011-02-16 22:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel, Greg Kroah-Hartman, Andrew Morton, Marc Kleine-Budde

This patch converts the macros for platform_{get,set}_drvdata to
static inline functions to add typechecking.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Changes since v1:
- remove ugly macro magic, use static inline functions instead

 include/linux/platform_device.h |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 2e700ec..d96db98 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -130,8 +130,15 @@ extern void platform_driver_unregister(struct platform_driver *);
 extern int platform_driver_probe(struct platform_driver *driver,
 		int (*probe)(struct platform_device *));
 
-#define platform_get_drvdata(_dev)	dev_get_drvdata(&(_dev)->dev)
-#define platform_set_drvdata(_dev,data)	dev_set_drvdata(&(_dev)->dev, (data))
+static inline void *platform_get_drvdata(const struct platform_device *pdev)
+{
+	return dev_get_drvdata(&pdev->dev);
+}
+
+static inline void platform_set_drvdata(struct platform_device *pdev, void *data)
+{
+	dev_set_drvdata(&pdev->dev, data);
+}
 
 extern struct platform_device *platform_create_bundle(struct platform_driver *driver,
 					int (*probe)(struct platform_device *),
-- 
1.7.2.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions
  2011-02-16 22:23 [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions Marc Kleine-Budde
@ 2011-02-16 22:56 ` Greg KH
  2011-02-17  8:47 ` Uwe Kleine-König
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-02-16 22:56 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-kernel, kernel, Andrew Morton

On Wed, Feb 16, 2011 at 11:23:27PM +0100, Marc Kleine-Budde wrote:
> This patch converts the macros for platform_{get,set}_drvdata to
> static inline functions to add typechecking.
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Much better, I'll add this to my queue.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions
  2011-02-16 22:23 [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions Marc Kleine-Budde
  2011-02-16 22:56 ` Greg KH
@ 2011-02-17  8:47 ` Uwe Kleine-König
  2011-02-18 16:15   ` Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2011-02-17  8:47 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: linux-kernel, kernel, Greg Kroah-Hartman, Andrew Morton

Hello,

On Wed, Feb 16, 2011 at 11:23:27PM +0100, Marc Kleine-Budde wrote:
> This patch converts the macros for platform_{get,set}_drvdata to
> static inline functions to add typechecking.
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
> Changes since v1:
> - remove ugly macro magic, use static inline functions instead
> 
>  include/linux/platform_device.h |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> index 2e700ec..d96db98 100644
> --- a/include/linux/platform_device.h
> +++ b/include/linux/platform_device.h
> @@ -130,8 +130,15 @@ extern void platform_driver_unregister(struct platform_driver *);
>  extern int platform_driver_probe(struct platform_driver *driver,
>  		int (*probe)(struct platform_device *));
>  
> -#define platform_get_drvdata(_dev)	dev_get_drvdata(&(_dev)->dev)
> -#define platform_set_drvdata(_dev,data)	dev_set_drvdata(&(_dev)->dev, (data))
> +static inline void *platform_get_drvdata(const struct platform_device *pdev)
> +{
> +	return dev_get_drvdata(&pdev->dev);
> +}
> +
> +static inline void platform_set_drvdata(struct platform_device *pdev, void *data)
> +{
> +	dev_set_drvdata(&pdev->dev, data);
> +}
Another improvement would be to make dev_set_drvdata and
platform_set_drvdata return an int (as dev_set_drvdata can fail) (and
then maybe mark it __must_check).

Other than that,

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions
  2011-02-17  8:47 ` Uwe Kleine-König
@ 2011-02-18 16:15   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-02-18 16:15 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Marc Kleine-Budde, linux-kernel, kernel, Greg Kroah-Hartman,
	Andrew Morton

On Thu, Feb 17, 2011 at 09:47:05AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Feb 16, 2011 at 11:23:27PM +0100, Marc Kleine-Budde wrote:
> > This patch converts the macros for platform_{get,set}_drvdata to
> > static inline functions to add typechecking.
> > 
> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > ---
> > Changes since v1:
> > - remove ugly macro magic, use static inline functions instead
> > 
> >  include/linux/platform_device.h |   11 +++++++++--
> >  1 files changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
> > index 2e700ec..d96db98 100644
> > --- a/include/linux/platform_device.h
> > +++ b/include/linux/platform_device.h
> > @@ -130,8 +130,15 @@ extern void platform_driver_unregister(struct platform_driver *);
> >  extern int platform_driver_probe(struct platform_driver *driver,
> >  		int (*probe)(struct platform_device *));
> >  
> > -#define platform_get_drvdata(_dev)	dev_get_drvdata(&(_dev)->dev)
> > -#define platform_set_drvdata(_dev,data)	dev_set_drvdata(&(_dev)->dev, (data))
> > +static inline void *platform_get_drvdata(const struct platform_device *pdev)
> > +{
> > +	return dev_get_drvdata(&pdev->dev);
> > +}
> > +
> > +static inline void platform_set_drvdata(struct platform_device *pdev, void *data)
> > +{
> > +	dev_set_drvdata(&pdev->dev, data);
> > +}
> Another improvement would be to make dev_set_drvdata and
> platform_set_drvdata return an int (as dev_set_drvdata can fail) (and
> then maybe mark it __must_check).

But dev_set_drvdata() does not return anything, so you would also have
to change that function first.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-18 16:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 22:23 [PATCH v2] Driver core: convert platform_{get,set}_drvdata to static inline functions Marc Kleine-Budde
2011-02-16 22:56 ` Greg KH
2011-02-17  8:47 ` Uwe Kleine-König
2011-02-18 16:15   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome