linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] backlight: platform_lcd: introduce probe callback
@ 2013-04-11 18:36 Andrew Bresticker
  2013-04-11 19:14 ` Doug Anderson
  2013-04-11 20:24 ` [PATCH v2] " Andrew Bresticker
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Bresticker @ 2013-04-11 18:36 UTC (permalink / raw)
  To: linux-fbdev
  Cc: Richard Purdie, Florian Tobias Schandinat, linux-kernel,
	Doug Anderson, Andrew Bresticker

Platform LCD devices may need to do some device-specific
initialization before they can be used (regulator or GPIO setup,
for example), but currently the driver does not support any way of
doing this.  This patch adds a probe() callback to plat_lcd_data
which platform LCD devices can set to indicate that device-specific
initialization is needed.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/video/backlight/platform_lcd.c | 8 ++++++++
 include/video/platform_lcd.h           | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
index 54d94de..2fb24a1 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -86,6 +86,14 @@ static int platform_lcd_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	if (pdata->probe) {
+		err = pdata->probe(pdata);
+		if (err) {
+			dev_err(dev, "platform probe failed: %d\n", err);
+			return err;
+		}
+	}
+
 	plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
 			    GFP_KERNEL);
 	if (!plcd) {
diff --git a/include/video/platform_lcd.h b/include/video/platform_lcd.h
index ad3bdfe..23864b2 100644
--- a/include/video/platform_lcd.h
+++ b/include/video/platform_lcd.h
@@ -15,6 +15,7 @@ struct plat_lcd_data;
 struct fb_info;
 
 struct plat_lcd_data {
+	int	(*probe)(struct plat_lcd_data *);
 	void	(*set_power)(struct plat_lcd_data *, unsigned int power);
 	int	(*match_fb)(struct plat_lcd_data *, struct fb_info *);
 };
-- 
1.8.1.3


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

* Re: [PATCH] backlight: platform_lcd: introduce probe callback
  2013-04-11 18:36 [PATCH] backlight: platform_lcd: introduce probe callback Andrew Bresticker
@ 2013-04-11 19:14 ` Doug Anderson
  2013-04-11 20:17   ` Andrew Bresticker
  2013-04-11 20:24 ` [PATCH v2] " Andrew Bresticker
  1 sibling, 1 reply; 8+ messages in thread
From: Doug Anderson @ 2013-04-11 19:14 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: linux-fbdev, Richard Purdie, Florian Tobias Schandinat,
	linux-kernel@vger.kernel.org

Andrew,

On Thu, Apr 11, 2013 at 11:36 AM, Andrew Bresticker
<abrestic@chromium.org> wrote:
> +       if (pdata->probe) {
> +               err = pdata->probe(pdata);
> +               if (err) {
> +                       dev_err(dev, "platform probe failed: %d\n", err);

It would probably be good not to print in the case of -EPROBE_DEFER?

Otherwise this looks good to me.

-Doug

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

* Re: [PATCH] backlight: platform_lcd: introduce probe callback
  2013-04-11 19:14 ` Doug Anderson
@ 2013-04-11 20:17   ` Andrew Bresticker
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Bresticker @ 2013-04-11 20:17 UTC (permalink / raw)
  To: Doug Anderson
  Cc: linux-fbdev, Richard Purdie, Florian Tobias Schandinat,
	linux-kernel@vger.kernel.org

> It would probably be good not to print in the case of -EPROBE_DEFER?

Actually, I think I'll just kill the print all together since the
caller will print something anyways.

-Andrew

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

* [PATCH v2] backlight: platform_lcd: introduce probe callback
  2013-04-11 18:36 [PATCH] backlight: platform_lcd: introduce probe callback Andrew Bresticker
  2013-04-11 19:14 ` Doug Anderson
@ 2013-04-11 20:24 ` Andrew Bresticker
  2013-04-11 20:30   ` Doug Anderson
                     ` (2 more replies)
  1 sibling, 3 replies; 8+ messages in thread
From: Andrew Bresticker @ 2013-04-11 20:24 UTC (permalink / raw)
  To: linux-fbdev
  Cc: Richard Purdie, Florian Tobias Schandinat, linux-kernel,
	Doug Anderson, Andrew Bresticker

Platform LCD devices may need to do some device-specific
initialization before they can be used (regulator or GPIO setup,
for example), but currently the driver does not support any way of
doing this.  This patch adds a probe() callback to plat_lcd_data
which platform LCD devices can set to indicate that device-specific
initialization is needed.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/video/backlight/platform_lcd.c | 6 ++++++
 include/video/platform_lcd.h           | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
index 17a6b83..f46180e 100644
--- a/drivers/video/backlight/platform_lcd.c
+++ b/drivers/video/backlight/platform_lcd.c
@@ -86,6 +86,12 @@ static int platform_lcd_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	if (pdata->probe) {
+		err = pdata->probe(pdata);
+		if (err)
+			return err;
+	}
+
 	plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
 			    GFP_KERNEL);
 	if (!plcd) {
diff --git a/include/video/platform_lcd.h b/include/video/platform_lcd.h
index ad3bdfe..23864b2 100644
--- a/include/video/platform_lcd.h
+++ b/include/video/platform_lcd.h
@@ -15,6 +15,7 @@ struct plat_lcd_data;
 struct fb_info;
 
 struct plat_lcd_data {
+	int	(*probe)(struct plat_lcd_data *);
 	void	(*set_power)(struct plat_lcd_data *, unsigned int power);
 	int	(*match_fb)(struct plat_lcd_data *, struct fb_info *);
 };
-- 
1.8.1.3


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

* Re: [PATCH v2] backlight: platform_lcd: introduce probe callback
  2013-04-11 20:24 ` [PATCH v2] " Andrew Bresticker
@ 2013-04-11 20:30   ` Doug Anderson
  2013-04-15  1:47   ` Jingoo Han
  2013-04-15 23:06   ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Doug Anderson @ 2013-04-11 20:30 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: linux-fbdev, Richard Purdie, Florian Tobias Schandinat,
	linux-kernel@vger.kernel.org

Andrew,

On Thu, Apr 11, 2013 at 1:24 PM, Andrew Bresticker
<abrestic@chromium.org> wrote:
> Platform LCD devices may need to do some device-specific
> initialization before they can be used (regulator or GPIO setup,
> for example), but currently the driver does not support any way of
> doing this.  This patch adds a probe() callback to plat_lcd_data
> which platform LCD devices can set to indicate that device-specific
> initialization is needed.
>
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> ---
>  drivers/video/backlight/platform_lcd.c | 6 ++++++
>  include/video/platform_lcd.h           | 1 +
>  2 files changed, 7 insertions(+)

Reviewed-by: Doug Anderson <dianders@chromium.org>

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

* Re: [PATCH v2] backlight: platform_lcd: introduce probe callback
  2013-04-11 20:24 ` [PATCH v2] " Andrew Bresticker
  2013-04-11 20:30   ` Doug Anderson
@ 2013-04-15  1:47   ` Jingoo Han
  2013-04-15 23:06   ` Andrew Morton
  2 siblings, 0 replies; 8+ messages in thread
From: Jingoo Han @ 2013-04-15  1:47 UTC (permalink / raw)
  To: 'Andrew Bresticker', 'Andrew Morton'
  Cc: linux-fbdev, 'Richard Purdie',
	'Florian Tobias Schandinat', linux-kernel,
	'Doug Anderson', 'Jingoo Han'

On Friday, April 12, 2013 5:25 AM, Andrew Bresticker wrote:
> 
> Platform LCD devices may need to do some device-specific
> initialization before they can be used (regulator or GPIO setup,
> for example), but currently the driver does not support any way of
> doing this.  This patch adds a probe() callback to plat_lcd_data
> which platform LCD devices can set to indicate that device-specific
> initialization is needed.
> 
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

CC'ed Andrew Morton,

It looks good.
Acked-by: Jingoo Han <jg1.han@samsung.com>

Best regards,
Jingoo Han


> ---
>  drivers/video/backlight/platform_lcd.c | 6 ++++++
>  include/video/platform_lcd.h           | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/video/backlight/platform_lcd.c b/drivers/video/backlight/platform_lcd.c
> index 17a6b83..f46180e 100644
> --- a/drivers/video/backlight/platform_lcd.c
> +++ b/drivers/video/backlight/platform_lcd.c
> @@ -86,6 +86,12 @@ static int platform_lcd_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
> 
> +	if (pdata->probe) {
> +		err = pdata->probe(pdata);
> +		if (err)
> +			return err;
> +	}
> +
>  	plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
>  			    GFP_KERNEL);
>  	if (!plcd) {
> diff --git a/include/video/platform_lcd.h b/include/video/platform_lcd.h
> index ad3bdfe..23864b2 100644
> --- a/include/video/platform_lcd.h
> +++ b/include/video/platform_lcd.h
> @@ -15,6 +15,7 @@ struct plat_lcd_data;
>  struct fb_info;
> 
>  struct plat_lcd_data {
> +	int	(*probe)(struct plat_lcd_data *);
>  	void	(*set_power)(struct plat_lcd_data *, unsigned int power);
>  	int	(*match_fb)(struct plat_lcd_data *, struct fb_info *);
>  };
> --
> 1.8.1.3
> 



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

* Re: [PATCH v2] backlight: platform_lcd: introduce probe callback
  2013-04-11 20:24 ` [PATCH v2] " Andrew Bresticker
  2013-04-11 20:30   ` Doug Anderson
  2013-04-15  1:47   ` Jingoo Han
@ 2013-04-15 23:06   ` Andrew Morton
  2013-04-16  0:53     ` Jingoo Han
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2013-04-15 23:06 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: linux-fbdev, Richard Purdie, Florian Tobias Schandinat,
	linux-kernel, Doug Anderson

On Thu, 11 Apr 2013 13:24:50 -0700 Andrew Bresticker <abrestic@chromium.org> wrote:

> Platform LCD devices may need to do some device-specific
> initialization before they can be used (regulator or GPIO setup,
> for example), but currently the driver does not support any way of
> doing this.  This patch adds a probe() callback to plat_lcd_data
> which platform LCD devices can set to indicate that device-specific
> initialization is needed.
> 
> index 17a6b83..f46180e 100644
> --- a/drivers/video/backlight/platform_lcd.c
> +++ b/drivers/video/backlight/platform_lcd.c
> @@ -86,6 +86,12 @@ static int platform_lcd_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> +	if (pdata->probe) {
> +		err = pdata->probe(pdata);
> +		if (err)
> +			return err;
> +	}
> +
>  	plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
>  			    GFP_KERNEL);
>  	if (!plcd) {
> diff --git a/include/video/platform_lcd.h b/include/video/platform_lcd.h
> index ad3bdfe..23864b2 100644
> --- a/include/video/platform_lcd.h
> +++ b/include/video/platform_lcd.h
> @@ -15,6 +15,7 @@ struct plat_lcd_data;
>  struct fb_info;
>  
>  struct plat_lcd_data {
> +	int	(*probe)(struct plat_lcd_data *);
>  	void	(*set_power)(struct plat_lcd_data *, unsigned int power);
>  	int	(*match_fb)(struct plat_lcd_data *, struct fb_info *);
>  };

Sigh.  I see that this entire interface has been lovingly undocumented.
It's an invitation for us to grow bugs, incompatibilities, leaks, etc.

Possible example: what happens if pdata->probe does some resource
allocation or device initialisation which should be backed out if, say,
platform_lcd_probe() later fails?


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

* Re: [PATCH v2] backlight: platform_lcd: introduce probe callback
  2013-04-15 23:06   ` Andrew Morton
@ 2013-04-16  0:53     ` Jingoo Han
  0 siblings, 0 replies; 8+ messages in thread
From: Jingoo Han @ 2013-04-16  0:53 UTC (permalink / raw)
  To: 'Andrew Morton', 'Andrew Bresticker'
  Cc: linux-fbdev, 'Richard Purdie',
	'Florian Tobias Schandinat', linux-kernel,
	'Doug Anderson', 'Jingoo Han'

On Tuesday, April 16, 2013 8:07 AM, Andrew Morton wrote:
> 
> On Thu, 11 Apr 2013 13:24:50 -0700 Andrew Bresticker <abrestic@chromium.org> wrote:
> 
> > Platform LCD devices may need to do some device-specific
> > initialization before they can be used (regulator or GPIO setup,
> > for example), but currently the driver does not support any way of
> > doing this.  This patch adds a probe() callback to plat_lcd_data
> > which platform LCD devices can set to indicate that device-specific
> > initialization is needed.
> >
> > index 17a6b83..f46180e 100644
> > --- a/drivers/video/backlight/platform_lcd.c
> > +++ b/drivers/video/backlight/platform_lcd.c
> > @@ -86,6 +86,12 @@ static int platform_lcd_probe(struct platform_device *pdev)
> >  		return -EINVAL;
> >  	}
> >
> > +	if (pdata->probe) {
> > +		err = pdata->probe(pdata);
> > +		if (err)
> > +			return err;
> > +	}
> > +
> >  	plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
> >  			    GFP_KERNEL);
> >  	if (!plcd) {
> > diff --git a/include/video/platform_lcd.h b/include/video/platform_lcd.h
> > index ad3bdfe..23864b2 100644
> > --- a/include/video/platform_lcd.h
> > +++ b/include/video/platform_lcd.h
> > @@ -15,6 +15,7 @@ struct plat_lcd_data;
> >  struct fb_info;
> >
> >  struct plat_lcd_data {
> > +	int	(*probe)(struct plat_lcd_data *);
> >  	void	(*set_power)(struct plat_lcd_data *, unsigned int power);
> >  	int	(*match_fb)(struct plat_lcd_data *, struct fb_info *);
> >  };
> 
> Sigh.  I see that this entire interface has been lovingly undocumented.
> It's an invitation for us to grow bugs, incompatibilities, leaks, etc.
> 
> Possible example: what happens if pdata->probe does some resource
> allocation or device initialisation which should be backed out if, say,
> platform_lcd_probe() later fails?

Hi Andrew,

I agree with you.
Indeed, the documentation is necessary.

Andrew Bresticker,
Would you make the document?
It would be very helpful.

Best regards,
Jingoo Han



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

end of thread, other threads:[~2013-04-16  0:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11 18:36 [PATCH] backlight: platform_lcd: introduce probe callback Andrew Bresticker
2013-04-11 19:14 ` Doug Anderson
2013-04-11 20:17   ` Andrew Bresticker
2013-04-11 20:24 ` [PATCH v2] " Andrew Bresticker
2013-04-11 20:30   ` Doug Anderson
2013-04-15  1:47   ` Jingoo Han
2013-04-15 23:06   ` Andrew Morton
2013-04-16  0:53     ` Jingoo Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).