Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* Re: [PATCH] video: backlight: jornada720_lcd.c:  Cleaning up variable that is never used
From: Lee Jones @ 2014-07-09 16:30 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Jingoo Han, Bryan Wu, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, linux-fbdev, linux-kernel
In-Reply-To: <1404763270-24932-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

On Mon, 07 Jul 2014, Rickard Strandqvist wrote:

> Variable ar assigned a value that is never used.
> I have also removed all the code that thereby serves no purpose,
> and made same change to clarify the similarities in function.
> 
> This was found using a static code analysis program called cppcheck
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/video/backlight/jornada720_lcd.c |   31 ++++++++++++++----------------
>  1 file changed, 14 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c
> index da3876c..d16abcf 100644
> --- a/drivers/video/backlight/jornada720_lcd.c
> +++ b/drivers/video/backlight/jornada720_lcd.c
> @@ -36,44 +36,41 @@ static int jornada_lcd_get_power(struct lcd_device *ld)
>  
>  static int jornada_lcd_get_contrast(struct lcd_device *ld)
>  {
> -	int ret;
> +	int ret = -ETIMEDOUT;
>  
>  	if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
>  		return 0;
>  
>  	jornada_ssp_start();
>  
> -	if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
> +	if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY)
>  		dev_err(&ld->dev, "get contrast failed\n");
> -		jornada_ssp_end();
> -		return -ETIMEDOUT;
> -	} else {
> +	else
>  		ret = jornada_ssp_byte(TXDUMMY);
> -		jornada_ssp_end();
> -		return ret;
> -	}
> +
> +	jornada_ssp_end();
> +
> +	return ret;
>  }
>  
>  static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
>  {
> -	int ret;
> +	int ret = -ETIMEDOUT;
>  
>  	jornada_ssp_start();
>  
>  	/* start by sending our set contrast cmd to mcu */
> -	ret = jornada_ssp_byte(SETCONTRAST);
> -
> +	if (jornada_ssp_byte(SETCONTRAST) != TXDUMMY)
> +		dev_err(&ld->dev, "set contrast failed\n");
>  	/* push the new value */
> -	if (jornada_ssp_byte(value) != TXDUMMY) {
> +	else if (jornada_ssp_byte(value) != TXDUMMY)
>  		dev_err(&ld->dev, "set contrast failed\n");
> -		jornada_ssp_end();
> -		return -ETIMEDOUT;
> -	}
> +	else /* if we get here we can assume everything went well */
> +		ret = 0;
>  
> -	/* if we get here we can assume everything went well */
>  	jornada_ssp_end();
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int jornada_lcd_set_power(struct lcd_device *ld, int power)

Counter suggestion.

What do you think, I think this looks cleaner:

static int jornada_lcd_get_contrast(struct lcd_device *ld)
{
	int ret;

	if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
		return 0;

	jornada_ssp_start();

	if (jornada_ssp_byte(GETCONTRAST) = TXDUMMY) {
		ret = jornada_ssp_byte(TXDUMMY);
		goto success;
	}

	dev_err(&ld->dev, "failed to set contrast\n");
	ret = -ETIMEDOUT;

success:
	jornada_ssp_end();
	return ret;
}

static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
{
	int ret = 0;

	jornada_ssp_start();

	/* start by sending our set contrast cmd to mcu */
	if (jornada_ssp_byte(SETCONTRAST) = TXDUMMY) {
		/* if successful, push the new value */
		if (jornada_ssp_byte(value) = TXDUMMY)
			goto success;
	}

	dev_err(&ld->dev, "failed to set contrast\n");
	ret = -ETIMEDOUT;

success:
	jornada_ssp_end();
	return ret;
}

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply

* Re: [PATCH] video: backlight: jornada720_lcd.c: Cleaning up variable that is never used
From: Rickard Strandqvist @ 2014-07-09 22:08 UTC (permalink / raw)
  To: Lee Jones
  Cc: Jingoo Han, Bryan Wu, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, Linux Fbdev development list,
	linux-kernel@vger.kernel.org
In-Reply-To: <20140709163050.GM2635@lee--X1>

2014-07-09 18:30 GMT+02:00 Lee Jones <lee.jones@linaro.org>:
> On Mon, 07 Jul 2014, Rickard Strandqvist wrote:
>
>> Variable ar assigned a value that is never used.
>> I have also removed all the code that thereby serves no purpose,
>> and made same change to clarify the similarities in function.
>>
>> This was found using a static code analysis program called cppcheck
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>>  drivers/video/backlight/jornada720_lcd.c |   31 ++++++++++++++----------------
>>  1 file changed, 14 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c
>> index da3876c..d16abcf 100644
>> --- a/drivers/video/backlight/jornada720_lcd.c
>> +++ b/drivers/video/backlight/jornada720_lcd.c
>> @@ -36,44 +36,41 @@ static int jornada_lcd_get_power(struct lcd_device *ld)
>>
>>  static int jornada_lcd_get_contrast(struct lcd_device *ld)
>>  {
>> -     int ret;
>> +     int ret = -ETIMEDOUT;
>>
>>       if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
>>               return 0;
>>
>>       jornada_ssp_start();
>>
>> -     if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
>> +     if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY)
>>               dev_err(&ld->dev, "get contrast failed\n");
>> -             jornada_ssp_end();
>> -             return -ETIMEDOUT;
>> -     } else {
>> +     else
>>               ret = jornada_ssp_byte(TXDUMMY);
>> -             jornada_ssp_end();
>> -             return ret;
>> -     }
>> +
>> +     jornada_ssp_end();
>> +
>> +     return ret;
>>  }
>>
>>  static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
>>  {
>> -     int ret;
>> +     int ret = -ETIMEDOUT;
>>
>>       jornada_ssp_start();
>>
>>       /* start by sending our set contrast cmd to mcu */
>> -     ret = jornada_ssp_byte(SETCONTRAST);
>> -
>> +     if (jornada_ssp_byte(SETCONTRAST) != TXDUMMY)
>> +             dev_err(&ld->dev, "set contrast failed\n");
>>       /* push the new value */
>> -     if (jornada_ssp_byte(value) != TXDUMMY) {
>> +     else if (jornada_ssp_byte(value) != TXDUMMY)
>>               dev_err(&ld->dev, "set contrast failed\n");
>> -             jornada_ssp_end();
>> -             return -ETIMEDOUT;
>> -     }
>> +     else /* if we get here we can assume everything went well */
>> +             ret = 0;
>>
>> -     /* if we get here we can assume everything went well */
>>       jornada_ssp_end();
>>
>> -     return 0;
>> +     return ret;
>>  }
>>
>>  static int jornada_lcd_set_power(struct lcd_device *ld, int power)
>
> Counter suggestion.
>
> What do you think, I think this looks cleaner:
>
> static int jornada_lcd_get_contrast(struct lcd_device *ld)
> {
>         int ret;
>
>         if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
>                 return 0;
>
>         jornada_ssp_start();
>
>         if (jornada_ssp_byte(GETCONTRAST) = TXDUMMY) {
>                 ret = jornada_ssp_byte(TXDUMMY);
>                 goto success;
>         }
>
>         dev_err(&ld->dev, "failed to set contrast\n");
>         ret = -ETIMEDOUT;
>
> success:
>         jornada_ssp_end();
>         return ret;
> }
>
> static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> {
>         int ret = 0;
>
>         jornada_ssp_start();
>
>         /* start by sending our set contrast cmd to mcu */
>         if (jornada_ssp_byte(SETCONTRAST) = TXDUMMY) {
>                 /* if successful, push the new value */
>                 if (jornada_ssp_byte(value) = TXDUMMY)
>                         goto success;
>         }
>
>         dev_err(&ld->dev, "failed to set contrast\n");
>         ret = -ETIMEDOUT;
>
> success:
>         jornada_ssp_end();
>         return ret;
> }


Hi Lee!

Yes, I agree!
Both are clean without so much repetition of code, which was what annoyd me.
But yours is clearer when things go good or bad, nice 1 ;)

I do not know what I can/may do, but I'll try. Remove what is not ok :-)

Reviewed-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>


Kind regards
Rickard Strandqvist

^ permalink raw reply

* Re: [PATCH] video: backlight: jornada720_lcd.c: Cleaning up variable that is never used
From: Jingoo Han @ 2014-07-10  2:28 UTC (permalink / raw)
  To: 'Rickard Strandqvist', 'Lee Jones'
  Cc: 'Bryan Wu', 'Jean-Christophe Plagniol-Villard',
	'Tomi Valkeinen', 'Linux Fbdev development list',
	linux-kernel, 'Jingoo Han'
In-Reply-To: <CAFo99gYErPZo_f-5kZkDqZ0YSPirE1fLn2F1odMPSjuUdLUQ8A@mail.gmail.com>

On Thursday, July 10, 2014 7:08 AM, Rickard Strandqvist wrote:
> 2014-07-09 18:30 GMT+02:00 Lee Jones <lee.jones@linaro.org>:
> > On Mon, 07 Jul 2014, Rickard Strandqvist wrote:
> >
> >> Variable ar assigned a value that is never used.
> >> I have also removed all the code that thereby serves no purpose,
> >> and made same change to clarify the similarities in function.
> >>
> >> This was found using a static code analysis program called cppcheck
> >>
> >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> >> ---
> >>  drivers/video/backlight/jornada720_lcd.c |   31 ++++++++++++++----------------
> >>  1 file changed, 14 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c
> >> index da3876c..d16abcf 100644
> >> --- a/drivers/video/backlight/jornada720_lcd.c
> >> +++ b/drivers/video/backlight/jornada720_lcd.c
> >> @@ -36,44 +36,41 @@ static int jornada_lcd_get_power(struct lcd_device *ld)
> >>
> >>  static int jornada_lcd_get_contrast(struct lcd_device *ld)
> >>  {
> >> -     int ret;
> >> +     int ret = -ETIMEDOUT;
> >>
> >>       if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
> >>               return 0;
> >>
> >>       jornada_ssp_start();
> >>
> >> -     if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
> >> +     if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY)
> >>               dev_err(&ld->dev, "get contrast failed\n");
> >> -             jornada_ssp_end();
> >> -             return -ETIMEDOUT;
> >> -     } else {
> >> +     else
> >>               ret = jornada_ssp_byte(TXDUMMY);
> >> -             jornada_ssp_end();
> >> -             return ret;
> >> -     }
> >> +
> >> +     jornada_ssp_end();
> >> +
> >> +     return ret;
> >>  }
> >>
> >>  static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> >>  {
> >> -     int ret;
> >> +     int ret = -ETIMEDOUT;
> >>
> >>       jornada_ssp_start();
> >>
> >>       /* start by sending our set contrast cmd to mcu */
> >> -     ret = jornada_ssp_byte(SETCONTRAST);
> >> -
> >> +     if (jornada_ssp_byte(SETCONTRAST) != TXDUMMY)
> >> +             dev_err(&ld->dev, "set contrast failed\n");
> >>       /* push the new value */
> >> -     if (jornada_ssp_byte(value) != TXDUMMY) {
> >> +     else if (jornada_ssp_byte(value) != TXDUMMY)
> >>               dev_err(&ld->dev, "set contrast failed\n");
> >> -             jornada_ssp_end();
> >> -             return -ETIMEDOUT;
> >> -     }
> >> +     else /* if we get here we can assume everything went well */
> >> +             ret = 0;
> >>
> >> -     /* if we get here we can assume everything went well */
> >>       jornada_ssp_end();
> >>
> >> -     return 0;
> >> +     return ret;
> >>  }
> >>
> >>  static int jornada_lcd_set_power(struct lcd_device *ld, int power)
> >
> > Counter suggestion.
> >
> > What do you think, I think this looks cleaner:
> >
> > static int jornada_lcd_get_contrast(struct lcd_device *ld)
> > {
> >         int ret;
> >
> >         if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
> >                 return 0;
> >
> >         jornada_ssp_start();
> >
> >         if (jornada_ssp_byte(GETCONTRAST) = TXDUMMY) {
> >                 ret = jornada_ssp_byte(TXDUMMY);
> >                 goto success;
> >         }
> >
> >         dev_err(&ld->dev, "failed to set contrast\n");
> >         ret = -ETIMEDOUT;
> >
> > success:
> >         jornada_ssp_end();
> >         return ret;
> > }
> >
> > static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> > {
> >         int ret = 0;
> >
> >         jornada_ssp_start();
> >
> >         /* start by sending our set contrast cmd to mcu */
> >         if (jornada_ssp_byte(SETCONTRAST) = TXDUMMY) {
> >                 /* if successful, push the new value */
> >                 if (jornada_ssp_byte(value) = TXDUMMY)
> >                         goto success;
> >         }
> >
> >         dev_err(&ld->dev, "failed to set contrast\n");
> >         ret = -ETIMEDOUT;
> >
> > success:
> >         jornada_ssp_end();
> >         return ret;
> > }
> 
> 
> Hi Lee!
> 
> Yes, I agree!
> Both are clean without so much repetition of code, which was what annoyd me.
> But yours is clearer when things go good or bad, nice 1 ;)

Hi Rickard Strandqvist,

I would liked to prefer Lee Jones's code. It looks cleaner.

> 
> I do not know what I can/may do, but I'll try. Remove what is not ok :-)
> 
> Reviewed-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>

I suggest the following.

Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Cc: Bryan Wu <cooloney@gmail.com>

Best regards,
Jingoo Han

> 
> 
> Kind regards
> Rickard Strandqvist


^ permalink raw reply

* Re: [PATCH] video: backlight: jornada720_lcd.c: Cleaning up variable that is never used
From: Lee Jones @ 2014-07-10  7:40 UTC (permalink / raw)
  To: Jingoo Han
  Cc: 'Rickard Strandqvist', 'Bryan Wu',
	'Jean-Christophe Plagniol-Villard',
	'Tomi Valkeinen', 'Linux Fbdev development list',
	linux-kernel
In-Reply-To: <003001cf9be6$b45cfcd0$1d16f670$%han@samsung.com>

On Thu, 10 Jul 2014, Jingoo Han wrote:

> On Thursday, July 10, 2014 7:08 AM, Rickard Strandqvist wrote:
> > 2014-07-09 18:30 GMT+02:00 Lee Jones <lee.jones@linaro.org>:
> > > On Mon, 07 Jul 2014, Rickard Strandqvist wrote:
> > >
> > >> Variable ar assigned a value that is never used.
> > >> I have also removed all the code that thereby serves no purpose,
> > >> and made same change to clarify the similarities in function.
> > >>
> > >> This was found using a static code analysis program called cppcheck
> > >>
> > >> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> > >> ---
> > >>  drivers/video/backlight/jornada720_lcd.c |   31 ++++++++++++++----------------
> > >>  1 file changed, 14 insertions(+), 17 deletions(-)
> > >>
> > >> diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c
> > >> index da3876c..d16abcf 100644
> > >> --- a/drivers/video/backlight/jornada720_lcd.c
> > >> +++ b/drivers/video/backlight/jornada720_lcd.c
> > >> @@ -36,44 +36,41 @@ static int jornada_lcd_get_power(struct lcd_device *ld)
> > >>
> > >>  static int jornada_lcd_get_contrast(struct lcd_device *ld)
> > >>  {
> > >> -     int ret;
> > >> +     int ret = -ETIMEDOUT;
> > >>
> > >>       if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
> > >>               return 0;
> > >>
> > >>       jornada_ssp_start();
> > >>
> > >> -     if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
> > >> +     if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY)
> > >>               dev_err(&ld->dev, "get contrast failed\n");
> > >> -             jornada_ssp_end();
> > >> -             return -ETIMEDOUT;
> > >> -     } else {
> > >> +     else
> > >>               ret = jornada_ssp_byte(TXDUMMY);
> > >> -             jornada_ssp_end();
> > >> -             return ret;
> > >> -     }
> > >> +
> > >> +     jornada_ssp_end();
> > >> +
> > >> +     return ret;
> > >>  }
> > >>
> > >>  static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> > >>  {
> > >> -     int ret;
> > >> +     int ret = -ETIMEDOUT;
> > >>
> > >>       jornada_ssp_start();
> > >>
> > >>       /* start by sending our set contrast cmd to mcu */
> > >> -     ret = jornada_ssp_byte(SETCONTRAST);
> > >> -
> > >> +     if (jornada_ssp_byte(SETCONTRAST) != TXDUMMY)
> > >> +             dev_err(&ld->dev, "set contrast failed\n");
> > >>       /* push the new value */
> > >> -     if (jornada_ssp_byte(value) != TXDUMMY) {
> > >> +     else if (jornada_ssp_byte(value) != TXDUMMY)
> > >>               dev_err(&ld->dev, "set contrast failed\n");
> > >> -             jornada_ssp_end();
> > >> -             return -ETIMEDOUT;
> > >> -     }
> > >> +     else /* if we get here we can assume everything went well */
> > >> +             ret = 0;
> > >>
> > >> -     /* if we get here we can assume everything went well */
> > >>       jornada_ssp_end();
> > >>
> > >> -     return 0;
> > >> +     return ret;
> > >>  }
> > >>
> > >>  static int jornada_lcd_set_power(struct lcd_device *ld, int power)
> > >
> > > Counter suggestion.
> > >
> > > What do you think, I think this looks cleaner:
> > >
> > > static int jornada_lcd_get_contrast(struct lcd_device *ld)
> > > {
> > >         int ret;
> > >
> > >         if (jornada_lcd_get_power(ld) != FB_BLANK_UNBLANK)
> > >                 return 0;
> > >
> > >         jornada_ssp_start();
> > >
> > >         if (jornada_ssp_byte(GETCONTRAST) = TXDUMMY) {
> > >                 ret = jornada_ssp_byte(TXDUMMY);
> > >                 goto success;
> > >         }
> > >
> > >         dev_err(&ld->dev, "failed to set contrast\n");
> > >         ret = -ETIMEDOUT;
> > >
> > > success:
> > >         jornada_ssp_end();
> > >         return ret;
> > > }
> > >
> > > static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
> > > {
> > >         int ret = 0;
> > >
> > >         jornada_ssp_start();
> > >
> > >         /* start by sending our set contrast cmd to mcu */
> > >         if (jornada_ssp_byte(SETCONTRAST) = TXDUMMY) {
> > >                 /* if successful, push the new value */
> > >                 if (jornada_ssp_byte(value) = TXDUMMY)
> > >                         goto success;
> > >         }
> > >
> > >         dev_err(&ld->dev, "failed to set contrast\n");
> > >         ret = -ETIMEDOUT;
> > >
> > > success:
> > >         jornada_ssp_end();
> > >         return ret;
> > > }
> > 
> > 
> > Hi Lee!
> > 
> > Yes, I agree!
> > Both are clean without so much repetition of code, which was what annoyd me.
> > But yours is clearer when things go good or bad, nice 1 ;)
> 
> Hi Rickard Strandqvist,
> 
> I would liked to prefer Lee Jones's code. It looks cleaner.
> 
> > 
> > I do not know what I can/may do, but I'll try. Remove what is not ok :-)
> > 
> > Reviewed-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> > Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> 
> I suggest the following.
> 
> Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Acked-by: Jingoo Han <jg1.han@samsung.com>
> Cc: Bryan Wu <cooloney@gmail.com>

Very well, I will submit as a patch with Jingoo's Ack and Rickard's
Suggested-by and Reviewed-by.  Is anyone able to test this patch?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply

* [patch] video: of: display_timing: double free on error
From: Dan Carpenter @ 2014-07-11  9:21 UTC (permalink / raw)
  To: linux-fbdev

The display_timings_release() function frees "disp" and we free it
again on the next line.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c
index 987edf1..5c098d5 100644
--- a/drivers/video/of_display_timing.c
+++ b/drivers/video/of_display_timing.c
@@ -236,6 +236,7 @@ timingfail:
 	if (native_mode)
 		of_node_put(native_mode);
 	display_timings_release(disp);
+	disp = NULL;
 entryfail:
 	kfree(disp);
 dispfail:

^ permalink raw reply related

* [PATCH v2 trivial 5/6] video: mx3fb: Update comment for dmaengine_prep_slave_sg() API
From: Geert Uytterhoeven @ 2014-07-11 16:13 UTC (permalink / raw)
  To: Vinod Koul, Dan Williams
  Cc: dmaengine, linux-kernel, Geert Uytterhoeven,
	Jean-Christophe Plagniol-Villard, Tomi Valkeinen, Jiri Kosina,
	linux-fbdev
In-Reply-To: <1405095208-14642-1-git-send-email-geert+renesas@glider.be>

Commit 16052827d98fbc13c31ebad560af4bd53e2b4dd5 ("dmaengine/dma_slave:
introduce inline wrappers") changed the code to use the new API, but forgot
to update a comment.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Jiri Kosina <trivial@kernel.org>
Cc: linux-fbdev@vger.kernel.org
--
v2:
  - New
---
 drivers/video/fbdev/mx3fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/mx3fb.c b/drivers/video/fbdev/mx3fb.c
index c645a0a0c341..5e97baf92721 100644
--- a/drivers/video/fbdev/mx3fb.c
+++ b/drivers/video/fbdev/mx3fb.c
@@ -1179,7 +1179,7 @@ static int mx3fb_pan_display(struct fb_var_screeninfo *var,
 
 	/*
 	 * We enable the End of Frame interrupt, which will free a tx-descriptor,
-	 * which we will need for the next device_prep_slave_sg(). The
+	 * which we will need for the next dmaengine_prep_slave_sg(). The
 	 * IRQ-handler will disable the IRQ again.
 	 */
 	init_completion(&mx3_fbi->flip_cmpl);
-- 
1.9.1


^ permalink raw reply related

* PATCH] video: fix up versatile CLCD helper move
From: Arnd Bergmann @ 2014-07-15  8:39 UTC (permalink / raw)
  To: linux-arm-kernel

commit 11c32d7b6274cb0f ("video: move Versatile CLCD helpers")
moved files out of the plat-versatile directory but in the process
got a few of the dependencies wrong:

- If CONFIG_FB is not set, the file no longer gets built, resulting
  in a link error
- If CONFIG_FB or CONFIG_FB_ARMCLCD are disabled, we also get a
  Kconfig warning for incorrect dependencies due to the symbol
  being 'select'ed from the platform Kconfig.
- When the file is not built, we also get a link error for missing
  symbols.

This patch should fix all three, by removing the 'select' statements,
changing the Kconfig description of the symbol to be enabled in
exactly the right configurations, and adding inline stub functions
for the case when the framebuffer driver is disabled.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index fceb014c54a1..76e0d6752bd8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -336,7 +336,6 @@ config ARCH_VERSATILE
 	select HAVE_MACH_CLKDEV
 	select ICST
 	select PLAT_VERSATILE
-	select PLAT_VERSATILE_CLCD
 	select PLAT_VERSATILE_CLOCK
 	select VERSATILE_FPGA_IRQ
 	help
diff --git a/arch/arm/mach-realview/Kconfig b/arch/arm/mach-realview/Kconfig
index 3b02ba4e7094..4b7649d59bf6 100644
--- a/arch/arm/mach-realview/Kconfig
+++ b/arch/arm/mach-realview/Kconfig
@@ -9,7 +9,6 @@ config ARCH_REALVIEW
 	select GPIO_PL061 if GPIOLIB
 	select ICST
 	select PLAT_VERSATILE
-	select PLAT_VERSATILE_CLCD
 	help
 	  This enables support for ARM Ltd RealView boards.
 
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index d8b9330f896a..e9166dfc4756 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -13,7 +13,6 @@ menuconfig ARCH_VEXPRESS
 	select ICST
 	select NO_IOPORT_MAP
 	select PLAT_VERSATILE
-	select PLAT_VERSATILE_CLCD
 	select POWER_RESET
 	select POWER_RESET_VEXPRESS
 	select POWER_SUPPLY
diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index e2dd9b493580..a16efe729988 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -292,10 +292,8 @@ config FB_ARMCLCD
 
 # Helper logic selected only by the ARM Versatile platform family.
 config PLAT_VERSATILE_CLCD
-	depends on FB_ARMCLCD
-	depends on (PLAT_VERSATILE || ARCH_INTEGRATOR)
-	default y
-	bool
+	def_bool ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS
+	depends on FB_ARMCLCD && FB=y
 
 config FB_ACORN
 	bool "Acorn VIDC support"
diff --git a/include/linux/platform_data/video-clcd-versatile.h b/include/linux/platform_data/video-clcd-versatile.h
index 6bb6a1d2019b..09ccf182af4d 100644
--- a/include/linux/platform_data/video-clcd-versatile.h
+++ b/include/linux/platform_data/video-clcd-versatile.h
@@ -1,9 +1,27 @@
 #ifndef PLAT_CLCD_H
 #define PLAT_CLCD_H
 
+#ifdef CONFIG_PLAT_VERSATILE_CLCD
 struct clcd_panel *versatile_clcd_get_panel(const char *);
 int versatile_clcd_setup_dma(struct clcd_fb *, unsigned long);
 int versatile_clcd_mmap_dma(struct clcd_fb *, struct vm_area_struct *);
 void versatile_clcd_remove_dma(struct clcd_fb *);
+#else
+static inline struct clcd_panel *versatile_clcd_get_panel(const char *s)
+{
+	return NULL;
+}
+static inline int versatile_clcd_setup_dma(struct clcd_fb *fb, unsigned long framesize)
+{
+	return -ENODEV;
+}
+static inline int versatile_clcd_mmap_dma(struct clcd_fb *fb, struct vm_area_struct *vm)
+{
+	return -ENODEV;
+}
+static inline void versatile_clcd_remove_dma(struct clcd_fb *fb)
+{
+}
+#endif
 
 #endif


^ permalink raw reply related

* [RFC v5 0/2]  backlight: add new tps611xx backlight driver
From: Daniel Jeong @ 2014-07-15 10:09 UTC (permalink / raw)
  To: Jingoo Han, Bryan Wu, Lee Jones, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, Grant Likely, Rob Herring, Randy Dunlap
  Cc: Daniel Jeong, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-fbdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Daniel Jeong

This driver a general version for tps611xx backlgiht chips of TI.
It supports tps61158, tps61161, tps61163 and tps61165 backlight driver
based on EasyScale protocol.

Daniel Jeong (2):
  [RFC v5 1/2] backlight: add new tps611xx backlight driver
  [RFC v5 2/2] backlight: device tree: add new tps611xx backlight binding

 .../video/backlight/tps611xx-backlight.txt         |   26 ++
 drivers/video/backlight/Kconfig                    |    7 +
 drivers/video/backlight/Makefile                   |    1 +
 drivers/video/backlight/tps611xx_bl.c              |  479 ++++++++++++++++++++
 include/linux/platform_data/tps611xx_bl.h          |   31 ++
 5 files changed, 544 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/backlight/tps611xx-backlight.txt
 create mode 100644 drivers/video/backlight/tps611xx_bl.c
 create mode 100644 include/linux/platform_data/tps611xx_bl.h

-- 
1.7.9.5


^ permalink raw reply

* [RFC v5 1/2] backlight: add new tps611xx backlight driver
From: Daniel Jeong @ 2014-07-15 10:09 UTC (permalink / raw)
  To: Jingoo Han, Bryan Wu, Lee Jones, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, Grant Likely, Rob Herring, Randy Dunlap
  Cc: Daniel Jeong, linux-kernel, linux-fbdev, devicetree, linux-doc,
	Daniel Jeong
In-Reply-To: <1405418958-7596-1-git-send-email-gshark.jeong@gmail.com>

This driver is a general version for tps611xx backlgiht chips of TI.
It supports tps61158, tps61161, tps61163 and tps61165 backlight driver
based on EasyScale protocol(1-Wire Control Interface).

EasyScale
EasyScale is a simple but flexible one pin interface to configure the current.
The interface is based on a master-slave structure, where the master is
typically a microcontroller or application processor and the IC is the slave.
The advantage of EasyScale compared with other one pin interfaces is that
its bit detection is in a large extent independent from the bit transmission
rate. It can automatically detect bit rates between 1.7kBit/sec and up
to 160kBit/sec.

EasyScale on TPS61163
A command consists of 24 bits, including an 8-bit device address byte and
a 16-bit data byte. All of the 24 bits should be transmitted together each
time, and the LSB bit should be transmitted first. The device address byte
A7(MSB)~A0(LSB) is fixed to 0x8F.
The data byte includes 9 bits D8(MSB)~D0(LSB) for brightness information
and an RFA bit. The RFA bit set to "1" indicates the Request for Acknowledge
condition. The Acknowledge condition is only applied when the protocol is
received correctly.
Bit sream : D0-D8 | 0 | RFA | 00000 | A0-A7
Please refer to the links below  for more details.
http://www.ti.com/lit/ds/symlink/tps61163.pdf

EasyScale on TPS61158/61/65
A command consists of 16 bits, including an 8-bit device address byte
and a 8-bit data byte. All of the 16 bits should be transmitted together
each time, and the MSB bit should be transmitted first. The device address
byte A7(MSB)~A0(LSB) is fixed (tps61158 0x58 tps61161 and tps61165 0x72).
The data byte includes an RFA bit.
The RFA bit set to "1" indicates the Request for Acknowledge condition.
The Acknowledge condition is only applied when the protocol is received
correctly.
Bit sream : A7-A0 | RFA | 00 | D4-D0
Please refer to the links below  for more details.
http://www.ti.com/lit/ds/symlink/tps61158.pdf
http://www.ti.com.cn/cn/lit/ds/symlink/tps61161-q1.pdf
http://www.ti.com/lit/ds/symlink/tps61165.pdf

Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com>
---
dt document was changed.
---
 drivers/video/backlight/Kconfig           |    7 +
 drivers/video/backlight/Makefile          |    1 +
 drivers/video/backlight/tps611xx_bl.c     |  479 +++++++++++++++++++++++++++++
 include/linux/platform_data/tps611xx_bl.h |   31 ++
 4 files changed, 518 insertions(+)
 create mode 100644 drivers/video/backlight/tps611xx_bl.c
 create mode 100644 include/linux/platform_data/tps611xx_bl.h

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 5a3eb2e..c779a85 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -418,6 +418,13 @@ config BACKLIGHT_TPS65217
 	  If you have a Texas Instruments TPS65217 say Y to enable the
 	  backlight driver.
 
+config BACKLIGHT_TPS611xx
+	tristate "TPS611xx Backlight"
+	depends on BACKLIGHT_CLASS_DEVICE && GPIOLIB
+	help
+	  This supports TI TPS61158,TPS61161, TPS61163 and TPS61165
+	  backlight driver based on EasyScale Protocol.
+
 config BACKLIGHT_AS3711
 	tristate "AS3711 Backlight"
 	depends on BACKLIGHT_CLASS_DEVICE && MFD_AS3711
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index bb82002..5c39945 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -51,5 +51,6 @@ obj-$(CONFIG_BACKLIGHT_PCF50633)	+= pcf50633-backlight.o
 obj-$(CONFIG_BACKLIGHT_PWM)		+= pwm_bl.o
 obj-$(CONFIG_BACKLIGHT_SAHARA)		+= kb3886_bl.o
 obj-$(CONFIG_BACKLIGHT_TOSA)		+= tosa_bl.o
+obj-$(CONFIG_BACKLIGHT_TPS611xx)	+= tps611xx_bl.o
 obj-$(CONFIG_BACKLIGHT_TPS65217)	+= tps65217_bl.o
 obj-$(CONFIG_BACKLIGHT_WM831X)		+= wm831x_bl.o
diff --git a/drivers/video/backlight/tps611xx_bl.c b/drivers/video/backlight/tps611xx_bl.c
new file mode 100644
index 0000000..6c485ff
--- /dev/null
+++ b/drivers/video/backlight/tps611xx_bl.c
@@ -0,0 +1,479 @@
+/*
+ * Simple driver for Texas Instruments TPS611XX Backlight driver chip
+ *        using EasyScale Interface. It supports TPS61158, TPS61161,
+ *        TPS61163 and TPS61165.
+ *
+ * Copyright (C) 2014 Texas Instruments
+ * Author: Daniel Jeong  <gshark.jeong@gmail.com>
+ *	       Ldd Mlp <ldd-mlp@list.ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/backlight.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/fb.h>
+#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_data/tps611xx_bl.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define CMD_FORWARD 0
+#define CMD_BACKWARD 1
+
+enum tps611xx_id {
+	TPS61158_ID = 0,
+	TPS61161_ID,
+	TPS61163_ID,
+	TPS61165_ID,
+};
+
+/*
+ * easyscale time spec
+ * @es_delay : es delay time(ns)
+ * @es_det   : es detection time(ns)
+ * @start    : start time of data stream(ns)
+ * @eos      : end time of data stream(ns)
+ * @reset    : ic shutdown time(ms)
+ * @logic_1_low : low time high bit(ns)
+ * @logic_0_low : low time low bit(ns)
+ * @ackn        : duation of ack condistion(ns)
+ * @ack_poll    : ack polling duration(ns)
+ */
+struct tps611xx_time {
+	unsigned int es_delay;
+	unsigned int es_det;
+	unsigned int start;
+	unsigned int eos;
+	unsigned int reset;
+	unsigned int logic_1_low;
+	unsigned int logic_0_low;
+	unsigned int ackn;
+	unsigned int ack_poll;
+};
+
+/*
+ * @seq : sequence of data transfer
+ * @size: size of data
+ * @brt_max : max brightness
+ * @brt_bmask : bit mask of dimming bits
+ * @rfa_bmask : bit mask of RFA(Request for Acknowledge condition)
+ */
+struct tps611xx_command {
+	int seq;
+	int size;
+	int brt_max;
+	int brt_bmask;
+	int rfa_bmask;
+};
+
+/*
+ * @id : product id
+ * @name : product name
+ * @addr : device address
+ * @cmd  : es command info
+ * @time : es time info
+ */
+struct tps611xx_esdata {
+	enum tps611xx_id id;
+	char *name;
+	int addr;
+	struct tps611xx_command cmd;
+	struct tps611xx_time time;
+};
+
+struct tps611xx_bl_data {
+	struct device *dev;
+	struct backlight_device *bled;
+	struct tps611xx_platform_data *pdata;
+
+	/*
+	 * @rfa_en : RFA enable (Request for Acknowledge condition)
+	 * @en_gpio: enable pin gpio no.
+	 * @esdata : easyscale data
+	 */
+	int rfa_en;
+	unsigned int en_gpio;
+	const struct tps611xx_esdata *esdata;
+};
+
+static struct tps611xx_esdata tps611xx_info[] = {
+	[TPS61158_ID] = {
+		.id = TPS61158_ID,
+		.name = "tps61158",
+		.addr = 0x5800,
+		.cmd = {
+			.seq = CMD_FORWARD,
+			.size = 16,
+			.brt_max = 31,
+			.brt_bmask = 0x1f,
+			.rfa_bmask = 0x80
+		},
+		.time = {
+			.es_delay = 100000,
+			.es_det = 450000,
+			.start = 3500,
+			.eos = 3500,
+			.reset = 4,
+			.logic_1_low = 5000,
+			.logic_0_low = 15000,
+			.ackn = 900000,
+			.ack_poll = 2000
+		},
+	},
+
+	[TPS61161_ID] = {
+		.id = TPS61161_ID,
+		.name = "tps61161",
+		.addr = 0x7200,
+		.cmd = {
+			.seq = CMD_FORWARD,
+			.size = 16,
+			.brt_max = 31,
+			.brt_bmask = 0x1f,
+			.rfa_bmask = 0x80
+		},
+		.time = {
+			.es_delay = 120000,
+			.es_det = 280000,
+			.start = 2000,
+			.eos = 2000,
+			.reset = 3,
+			.logic_1_low = 3000,
+			.logic_0_low = 7000,
+			.ackn = 512000,
+			.ack_poll = 2000
+		},
+	},
+
+	[TPS61163_ID] = {
+		.id = TPS61163_ID,
+		.name = "tps61163",
+		.addr = 0x8F0000,
+		.cmd = {
+			.seq = CMD_BACKWARD,
+			.size = 24,
+			.brt_max = 511,
+			.brt_bmask = 0x1ff,
+			.rfa_bmask = 0x400
+		},
+		.time = {
+			.es_delay = 100000,
+			.es_det = 260000,
+			.start = 2000,
+			.eos = 2000,
+			.reset = 3,
+			.logic_1_low = 3000,
+			.logic_0_low = 7000,
+			.ackn = 512000,
+			.ack_poll = 2000
+		},
+	},
+
+	[TPS61165_ID] = {
+		.id = TPS61165_ID,
+		.name = "tps61165",
+		.addr = 0x7200,
+		.cmd = {
+			.seq = CMD_FORWARD,
+			.size = 16,
+			.brt_max = 31,
+			.brt_bmask = 0x1f,
+			.rfa_bmask = 0x80
+		},
+		.time = {
+			.es_delay = 120000,
+			.es_det = 280000,
+			.start = 4000,
+			.eos = 4000,
+			.reset = 3,
+			.logic_1_low = 3000,
+			.logic_0_low = 7000,
+			.ackn = 512000,
+			.ack_poll = 2000
+		},
+	},
+};
+
+static int tps611xx_bl_update_status(struct backlight_device *bl)
+{
+	struct tps611xx_bl_data *pchip = bl_get_data(bl);
+	const struct tps611xx_esdata *esdata = pchip->esdata;
+	int data_in, t_low, t_logic, max_bmask;
+	unsigned long flags;
+
+	data_in = esdata->addr | (bl->props.brightness & esdata->cmd.brt_bmask);
+	if (pchip->rfa_en)
+		data_in |= esdata->cmd.rfa_bmask;
+
+	max_bmask = 0x1 << esdata->cmd.size;
+	t_logic = esdata->time.logic_1_low + esdata->time.logic_0_low;
+
+	local_irq_save(flags);
+	/* t_start : 2us high before data byte */
+	gpio_direction_output(pchip->en_gpio, 1);
+	ndelay(esdata->time.start);
+
+	/* forward command transfer */
+	if (esdata->cmd.seq = CMD_FORWARD) {
+		int addr_bmask = max_bmask >> 8;
+
+		for (max_bmask >>= 1; max_bmask > 0x0; max_bmask >>= 1) {
+			if (data_in & max_bmask)
+				t_low = esdata->time.logic_1_low;
+			else
+				t_low = esdata->time.logic_0_low;
+
+			gpio_direction_output(pchip->en_gpio, 0);
+			ndelay(t_low);
+			gpio_direction_output(pchip->en_gpio, 1);
+			ndelay(t_logic - t_low);
+
+			if (max_bmask = addr_bmask) {
+				gpio_direction_output(pchip->en_gpio, 0);
+				/* t_eos : low after address byte */
+				ndelay(esdata->time.eos);
+				gpio_direction_output(pchip->en_gpio, 1);
+				/* t_start : high before data byte */
+				ndelay(esdata->time.start);
+			}
+		}
+	} else {
+		/* backward command tansfer */
+		int bmask;
+
+		for (bmask = 0x01; bmask < max_bmask; bmask <<= 1) {
+			if (data_in & bmask)
+				t_low = esdata->time.logic_1_low;
+			else
+				t_low = esdata->time.logic_0_low;
+
+			gpio_direction_output(pchip->en_gpio, 0);
+			ndelay(t_low);
+			gpio_direction_output(pchip->en_gpio, 1);
+			ndelay(t_logic - t_low);
+		}
+	}
+
+	/*
+	 * t_eos : low after address byte
+	 * t_ackVal is also t_eos
+	 */
+	gpio_direction_output(pchip->en_gpio, 0);
+	ndelay(esdata->time.eos);
+
+	/* RFA management  */
+	if (pchip->rfa_en) {
+		int max_ack_time = esdata->time.ackn;
+		/* set input */
+		gpio_direction_input(pchip->en_gpio);
+		/* read acknowledge from chip */
+		while (max_ack_time > 0) {
+			if (gpio_get_value(pchip->en_gpio) = 0)
+				break;
+			max_ack_time -= esdata->time.ack_poll;
+		}
+		if (max_ack_time <= 0)
+			dev_err(pchip->dev,
+				"easyscale : no ack from %s\n", esdata->name);
+		else
+			ndelay(max_ack_time);
+	}
+	gpio_direction_output(pchip->en_gpio, 1);
+	local_irq_restore(flags);
+
+	return bl->props.brightness;
+}
+
+static const struct backlight_ops tps611xx_bl_ops = {
+	.update_status = tps611xx_bl_update_status,
+};
+
+static ssize_t tps611xx_enable_store(struct device *dev,
+				     struct device_attribute *devAttr,
+				     const char *buf, size_t size)
+{
+	struct tps611xx_bl_data *pchip = dev_get_drvdata(dev);
+	const struct tps611xx_esdata *esdata = pchip->esdata;
+	unsigned long flags;
+	unsigned int input;
+	int ret;
+
+	ret = kstrtouint(buf, 10, &input);
+	if (ret)
+		return -EINVAL;
+
+	local_irq_save(flags);
+	if (input = 0) {
+		/* chip disable */
+		gpio_direction_output(pchip->en_gpio, 0);
+		/* low more than reset ms to reset */
+		mdelay(esdata->time.reset);
+	} else {
+		/* easyscale detection window */
+		gpio_direction_output(pchip->en_gpio, 1);
+		ndelay(esdata->time.es_delay);
+		gpio_direction_output(pchip->en_gpio, 0);
+		ndelay(esdata->time.es_det);
+		gpio_direction_output(pchip->en_gpio, 1);
+	}
+	local_irq_restore(flags);
+
+	return size;
+}
+
+static DEVICE_ATTR(enable, S_IWUSR, NULL, tps611xx_enable_store);
+
+#ifdef CONFIG_OF
+static const struct of_device_id tps611xx_backlight_of_match[] = {
+	{.compatible = "ti,tps61158", .data = &tps611xx_info[TPS61158_ID]},
+	{.compatible = "ti,tps61161", .data = &tps611xx_info[TPS61161_ID]},
+	{.compatible = "ti,tps61163", .data = &tps611xx_info[TPS61163_ID]},
+	{.compatible = "ti,tps61165", .data = &tps611xx_info[TPS61165_ID]},
+	{}
+};
+
+MODULE_DEVICE_TABLE(of, tps611xx_backlight_of_match);
+
+static int tps611xx_backlight_parse_dt(struct tps611xx_bl_data *pchip)
+{
+	struct device *dev = pchip->dev;
+	struct device_node *node = dev->of_node;
+	const struct of_device_id *of_id +	    of_match_device(tps611xx_backlight_of_match, dev);
+
+	if (!node)
+		return -ENODEV;
+
+	if (!of_id || !of_id->data) {
+		dev_err(dev, "Failed to find tps611xx chip id\n");
+		return -EFAULT;
+	}
+	pchip->esdata = of_id->data;
+	pchip->rfa_en = of_property_read_bool(node, "rfa-enable");
+	pchip->en_gpio = of_get_named_gpio(node, "es-gpio", 0);
+
+	return 0;
+}
+#else
+static int tps611xx_backlight_parse_dt(struct tps611xx_bl_data *pchip)
+{
+	return -ENODEV;
+}
+#endif
+
+static int tps611xx_backlight_probe(struct platform_device *pdev)
+{
+	struct tps611xx_bl_data *pchip;
+	struct backlight_properties props;
+	const struct tps611xx_esdata *esdata;
+	struct tps611xx_platform_data *pdata = dev_get_platdata(&pdev->dev);
+	unsigned long flags;
+	int ret;
+
+	pchip = devm_kzalloc(&pdev->dev,
+			     sizeof(struct tps611xx_bl_data), GFP_KERNEL);
+	if (pchip = NULL)
+		return -ENOMEM;
+	pchip->dev = &pdev->dev;
+
+	if (pdata = NULL) {
+		ret = tps611xx_backlight_parse_dt(pchip);
+		if (ret < 0)
+			return ret;
+	} else {
+		pchip->rfa_en = pdata->rfa_en;
+		pchip->en_gpio = pdata->en_gpio_num;
+		pchip->esdata = (const struct tps611xx_esdata *)
+		    platform_get_device_id(pdev)->driver_data;
+	}
+	esdata = pchip->esdata;
+
+	memset(&props, 0, sizeof(struct backlight_properties));
+	props.brightness = esdata->cmd.brt_max;
+	props.max_brightness = esdata->cmd.brt_max;
+	props.type = BACKLIGHT_RAW;
+	pchip->bled +	    devm_backlight_device_register(pchip->dev, TPS611XX_NAME,
+					   pchip->dev, pchip,
+					   &tps611xx_bl_ops, &props);
+	if (IS_ERR(pchip->bled))
+		return PTR_ERR(pchip->bled);
+
+	/* for enable/disable */
+	ret = device_create_file(&(pchip->bled->dev), &dev_attr_enable);
+	if (ret < 0) {
+		dev_err(pchip->dev, "failed : add sysfs entries\n");
+		return ret;
+	}
+	platform_set_drvdata(pdev, pchip);
+
+	/* EasyScale init */
+	ret = gpio_request_one(pchip->en_gpio, GPIOF_OUT_INIT_HIGH, "tps611xx");
+	if (ret) {
+		device_remove_file(&(pchip->bled->dev), &dev_attr_enable);
+		dev_err(pchip->dev, "failed : get gpio %d\n", pchip->en_gpio);
+		return ret;
+	}
+
+	/*
+	 * ES Detection Window
+	 *   - ES detect delay
+	 *   - ES detect time
+	 */
+	local_irq_save(flags);
+	gpio_direction_output(pchip->en_gpio, 1);
+	ndelay(esdata->time.es_delay);
+	gpio_direction_output(pchip->en_gpio, 0);
+	ndelay(esdata->time.es_det);
+	gpio_direction_output(pchip->en_gpio, 1);
+	local_irq_restore(flags);
+	dev_info(pchip->dev,
+		 "%s EasyScale is initialized\n", pchip->esdata->name);
+	return 0;
+}
+
+static int tps611xx_backlight_remove(struct platform_device *pdev)
+{
+	struct tps611xx_bl_data *pchip = platform_get_drvdata(pdev);
+	const struct tps611xx_esdata *esdata = pchip->esdata;
+
+	device_remove_file(&(pchip->bled->dev), &dev_attr_enable);
+	gpio_direction_output(pchip->en_gpio, 0);
+	mdelay(esdata->time.reset);
+	return 0;
+}
+
+static const struct platform_device_id tps611xx_id_table[] = {
+	{TPS61158_NAME, (unsigned long)&tps611xx_info[TPS61158_ID]},
+	{TPS61161_NAME, (unsigned long)&tps611xx_info[TPS61161_ID]},
+	{TPS61163_NAME, (unsigned long)&tps611xx_info[TPS61163_ID]},
+	{TPS61165_NAME, (unsigned long)&tps611xx_info[TPS61165_ID]},
+	{}
+};
+
+static struct platform_driver tps611xx_backlight_driver = {
+	.driver = {
+		.name = TPS611XX_NAME,
+		.owner = THIS_MODULE,
+		.of_match_table = of_match_ptr(tps611xx_backlight_of_match),
+	},
+	.probe = tps611xx_backlight_probe,
+	.remove = tps611xx_backlight_remove,
+	.id_table = tps611xx_id_table,
+};
+
+module_platform_driver(tps611xx_backlight_driver);
+
+MODULE_DESCRIPTION("EasyScale based tps611xx Backlight Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:tps611xx_bl");
diff --git a/include/linux/platform_data/tps611xx_bl.h b/include/linux/platform_data/tps611xx_bl.h
new file mode 100644
index 0000000..f16b43b
--- /dev/null
+++ b/include/linux/platform_data/tps611xx_bl.h
@@ -0,0 +1,31 @@
+/*
+ * Simple driver for Texas Instruments TPS611xx Backlight driver chip
+ * Copyright (C) 2014 Texas Instruments
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __TPS611XX_H
+#define __TPS611XX_H
+
+#define TPS611XX_NAME "tps611xx"
+#define TPS61158_NAME "tps61158"
+#define TPS61161_NAME "tps61161"
+#define TPS61163_NAME "tps61163"
+#define TPS61165_NAME "tps61165"
+
+/*
+ * struct tps611xx platform data
+ * @rfa_en : request for acknowledge
+ * @en_gpio_num : gpio number for en_pin
+ */
+struct tps611xx_platform_data {
+
+	int rfa_en;
+	unsigned int en_gpio_num;
+};
+
+#endif /* __TPS611XX_H */
-- 
1.7.9.5


^ permalink raw reply related

* [RFC v5 2/2] backlight: device tree: add new tps611xx backlight binding
From: Daniel Jeong @ 2014-07-15 10:09 UTC (permalink / raw)
  To: Jingoo Han, Bryan Wu, Lee Jones, Jean-Christophe Plagniol-Villard,
	Tomi Valkeinen, Grant Likely, Rob Herring, Randy Dunlap
  Cc: Daniel Jeong, linux-kernel, linux-fbdev, devicetree, linux-doc,
	Daniel Jeong
In-Reply-To: <1405418958-7596-1-git-send-email-gshark.jeong@gmail.com>

This commit is about tps611xx device tree documentation.

Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com>
---
 .../video/backlight/tps611xx-backlight.txt         |   26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/backlight/tps611xx-backlight.txt

diff --git a/Documentation/devicetree/bindings/video/backlight/tps611xx-backlight.txt b/Documentation/devicetree/bindings/video/backlight/tps611xx-backlight.txt
new file mode 100644
index 0000000..905c61b
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/backlight/tps611xx-backlight.txt
@@ -0,0 +1,26 @@
+TPS611xx family of backlight driver based on EasyScale.
+
+EasyScale is a simple but flexible one pin interface to configure the current.
+
+Required properties:
+- compatible: should contain at least one of
+  "ti,tps61158"
+  "ti,tps61161"
+  "ti,tps61163"
+  "ti,tps61165"
+- es-gpio : GPIO for easy-scale communication.(see GPIO binding[0])
+
+Optional properties:
+- rfa-enable: enable request for acknowledge.
+  If RFA is enabled, the data byte includes the RFA bit and device will wait
+  and check acknowledge from device.
+
+[0]: Documentation/devicetree/bindings/gpio/gpio.txt
+
+Example:
+
+	backlight {
+		compatible = "ti,tps61163";
+		es-gpio = <&gpio 45 0>;
+		rfa-enable;
+	};
-- 
1.7.9.5


^ permalink raw reply related

* Re: [RFC v5 1/2] backlight: add new tps611xx backlight driver
From: Varka Bhadram @ 2014-07-15 10:37 UTC (permalink / raw)
  To: Daniel Jeong, Jingoo Han, Bryan Wu, Lee Jones,
	Jean-Christophe Plagniol-Villard, Tomi Valkeinen, Grant Likely,
	Rob Herring, Randy Dunlap
  Cc: Daniel Jeong, linux-kernel, linux-fbdev, devicetree, linux-doc
In-Reply-To: <1405418958-7596-2-git-send-email-gshark.jeong@gmail.com>

On 07/15/2014 03:39 PM, Daniel Jeong wrote:
(...)

> +
> +static int tps611xx_backlight_remove(struct platform_device *pdev)
> +{
> +	struct tps611xx_bl_data *pchip = platform_get_drvdata(pdev);
> +	const struct tps611xx_esdata *esdata = pchip->esdata;
> +
> +	device_remove_file(&(pchip->bled->dev), &dev_attr_enable);
> +	gpio_direction_output(pchip->en_gpio, 0);
> +	mdelay(esdata->time.reset);
> +	return 0;
> +}
> +

Better to move the of_device_ids also here... We can see of_match_table directly...

> +static const struct platform_device_id tps611xx_id_table[] = {
> +	{TPS61158_NAME, (unsigned long)&tps611xx_info[TPS61158_ID]},
> +	{TPS61161_NAME, (unsigned long)&tps611xx_info[TPS61161_ID]},
> +	{TPS61163_NAME, (unsigned long)&tps611xx_info[TPS61163_ID]},
> +	{TPS61165_NAME, (unsigned long)&tps611xx_info[TPS61165_ID]},
> +	{}
> +};
> +
> +static struct platform_driver tps611xx_backlight_driver = {
> +	.driver = {
> +		.name = TPS611XX_NAME,
> +		.owner = THIS_MODULE,

No need to update .owner

see:http://lxr.free-electrons.com/source/include/linux/platform_device.h#L190

-- 
Regards,
Varka Bhadram.


^ permalink raw reply

* Re: [PATCH 01/12] ARM: OMAP2+: Remove non working OMAP HDMI audio initialization
From: Jyri Sarha @ 2014-07-15 19:25 UTC (permalink / raw)
  To: Tony Lindgren, Peter Ujfalusi
  Cc: alsa-devel, linux-fbdev, linux-omap, broonie, liam.r.girdwood,
	tomi.valkeinen, detheridge, jyri.sarha
In-Reply-To: <20140708080945.GZ28884@atomide.com>

On 07/08/2014 11:09 AM, Tony Lindgren wrote:
> * Peter Ujfalusi <peter.ujfalusi@ti.com> [140708 00:32]:
>> Hi Tony,
>>
>> On 07/07/2014 02:46 PM, Tony Lindgren wrote:
>>> * Jyri Sarha <jsarha@ti.com> [140626 12:26]:
>>>> This code is not working currently and it can be removed. There is a
>>>> conflict in sharing resources with the actual HDMI driver and with
>>>> the ASoC HDMI audio DAI driver.
>>>
>>> Is this OK to queue for v3.17 or do we need this for v3.16-rc series?
>>
>> Jyri is away currently, but I think it would be great if this patch goes in
>> for 3.16. The patch does not introduce regression since the OMAP4/5 HDMI is in
>> non working state in the kernel so removing the platform device right now will
>> ease up the merger of the new and working code.
>
> OK, will apply it into omap-for-v3.16/fixes as it just removes broken code.
>

Thanks Tony and Peter!



^ permalink raw reply

* [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: Benoit Taine @ 2014-07-18 15:26 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-mips, linux-fbdev, linux-mmc, dri-devel, linux-kernel,
	benoit.taine, ath5k-devel, linux-acenic, linux-scsi, linux-rdma,
	ath10k, linux-hippi, industrypack-devel, xen-devel,
	MPT-FusionLinux.pdl, virtualization, ath9k-devel, wil6210,
	linux-pcmcia, linux-can, platform-driver-x86, netdev,
	linux-wireless, users, e1000-devel, linux-crypto, devel

We should prefer `const struct pci_device_id` over
`DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
This issue was reported by checkpatch.

A simplified version of the semantic patch that makes this change is as
follows (http://coccinelle.lip6.fr/):

// <smpl>

@@
identifier i;
declarer name DEFINE_PCI_DEVICE_TABLE;
initializer z;
@@

- DEFINE_PCI_DEVICE_TABLE(i)
+ const struct pci_device_id i[]
= z;

// </smpl>

I have 103 patches ready, and will only send a few for you to judge if
it is useful enough, and to prevent from spamming too much.

Thanks.

^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: John W. Linville @ 2014-07-18 16:22 UTC (permalink / raw)
  To: Benoit Taine
  Cc: linux-mips, linux-fbdev, linux-pci, dri-devel, linux-kernel,
	ath5k-devel, MPT-FusionLinux.pdl, linux-acenic, linux-scsi,
	linux-rdma, ath10k, linux-hippi, industrypack-devel, linux-mmc,
	virtualization, ath9k-devel, wil6210, linux-pcmcia, linux-can,
	xen-devel, platform-driver-x86, netdev, linux-wireless, users,
	e1000-devel, linux-crypto, devel
In-Reply-To: <1405697232-11785-1-git-send-email-benoit.taine@lip6.fr>

On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
> We should prefer `const struct pci_device_id` over
> `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> This issue was reported by checkpatch.

Honestly, I prefer the macro -- it stands-out more.  Maybe the style
guidelines and/or checkpatch should change instead?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: James Bottomley @ 2014-07-18 16:28 UTC (permalink / raw)
  To: Benoit Taine
  Cc: linux-mips, linux-fbdev, linux-pci, dri-devel, linux-kernel,
	ath5k-devel, linux-acenic, linux-scsi, linux-rdma, ath10k,
	linux-hippi, industrypack-devel, linux-mmc, MPT-FusionLinux.pdl,
	virtualization, ath9k-devel, wil6210, linux-pcmcia, linux-can,
	xen-devel, platform-driver-x86, netdev, linux-wireless, users,
	e1000-devel, linux-crypto, devel
In-Reply-To: <1405697232-11785-1-git-send-email-benoit.taine@lip6.fr>

On Fri, 2014-07-18 at 17:26 +0200, Benoit Taine wrote:
> We should prefer `const struct pci_device_id` over
> `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> This issue was reported by checkpatch.

What kernel coding style?  checkpatch isn't the arbiter of style, if
that's the only problem.

The DEFINE_PCI macro was a well reasoned addition when it was added in
2008.  The problem was most people were getting the definition wrong.
When we converted away from CONFIG_HOTPLUG, having this DEFINE_ meant
that only one place needed changing instead of hundreds for PCI tables.

The reason people were getting the PCI table wrong was mostly the init
section specifiers which are now gone, but it has enough underlying
utility (mostly constification) that I don't think we'd want to churn
the kernel hugely to make a change to struct pci_table and then have to
start detecting and fixing misuses.

James



^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: Greg KH @ 2014-07-18 16:43 UTC (permalink / raw)
  To: John W. Linville
  Cc: linux-mips, linux-fbdev, linux-pci, dri-devel,
	platform-driver-x86, Benoit Taine, ath5k-devel, linux-acenic,
	linux-scsi, users, linux-rdma, ath10k, linux-hippi,
	industrypack-devel, linux-wireless, xen-devel,
	MPT-FusionLinux.pdl, ath9k-devel, wil6210, linux-pcmcia,
	linux-can, virtualization, netdev, linux-mmc, linux-kernel,
	e1000-devel, linux-crypto, devel
In-Reply-To: <20140718162213.GC31114@tuxdriver.com>

On Fri, Jul 18, 2014 at 12:22:13PM -0400, John W. Linville wrote:
> On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
> > We should prefer `const struct pci_device_id` over
> > `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> > This issue was reported by checkpatch.
> 
> Honestly, I prefer the macro -- it stands-out more.  Maybe the style
> guidelines and/or checkpatch should change instead?

The macro is horrid, no other bus has this type of thing just to save a
few characters in typing, so why should PCI be "special" in this regard
anymore?

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: James Bottomley @ 2014-07-18 16:54 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-mips, linux-fbdev, linux-pci, dri-devel, virtualization,
	Benoit Taine, ath5k-devel, linux-acenic, linux-scsi, users,
	linux-rdma, ath10k, linux-hippi, industrypack-devel,
	linux-wireless, xen-devel, MPT-FusionLinux.pdl, ath9k-devel,
	wil6210, linux-pcmcia, John W. Linville, linux-can,
	platform-driver-x86, netdev, linux-mmc, linux-kernel, e1000-devel,
	linux-crypto
In-Reply-To: <20140718164340.GA24960@kroah.com>

On Fri, 2014-07-18 at 09:43 -0700, Greg KH wrote:
> On Fri, Jul 18, 2014 at 12:22:13PM -0400, John W. Linville wrote:
> > On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
> > > We should prefer `const struct pci_device_id` over
> > > `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> > > This issue was reported by checkpatch.
> > 
> > Honestly, I prefer the macro -- it stands-out more.  Maybe the style
> > guidelines and/or checkpatch should change instead?
> 
> The macro is horrid, no other bus has this type of thing just to save a
> few characters in typing

OK, so this is the macro:

#define DEFINE_PCI_DEVICE_TABLE(_table) \
	const struct pci_device_id _table[]

Could you explain what's so horrible?

The reason it's useful today is that people forget the const (and
sometimes the [] making it a true table instead of a pointer).  If you
use the DEFINE_PCI_DEVICE_TABLE macro, the compile breaks if you use it
wrongly (good) and you automatically get the correct annotations.

> , so why should PCI be "special" in this regard
> anymore?

I think the PCI usage dwarfs most other bus types now, so you could turn
the question around.  However, I don't think majority voting is a good
guide to best practise; lets debate the merits for their own sake.

James



^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: Joe Perches @ 2014-07-18 18:05 UTC (permalink / raw)
  To: Greg KH
  Cc: John W. Linville, Benoit Taine, linux-mips, linux-fbdev,
	linux-pci, dri-devel, linux-kernel, ath5k-devel, linux-acenic,
	linux-scsi, linux-rdma, ath10k, linux-hippi, industrypack-devel,
	linux-mmc, MPT-FusionLinux.pdl, virtualization, ath9k-devel,
	wil6210, linux-pcmcia, linux-can, xen-devel, platform-driver-x86,
	netdev, linux-wireless, users, e1000-devel, linux-crypto
In-Reply-To: <20140718164340.GA24960@kroah.com>

On Fri, 2014-07-18 at 09:43 -0700, Greg KH wrote:
> On Fri, Jul 18, 2014 at 12:22:13PM -0400, John W. Linville wrote:
> > On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
> > > We should prefer `const struct pci_device_id` over
> > > `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> > > This issue was reported by checkpatch.
> >  scripts/checkpatch.pl | 4 ++--
> > Honestly, I prefer the macro -- it stands-out more.  Maybe the style
> > guidelines and/or checkpatch should change instead?
> 
> The macro is horrid, no other bus has this type of thing just to save a
> few characters in typing, so why should PCI be "special" in this regard
> anymore?

I think it doesn't matter much.

The PCI_DEVICE and PCI_VDEVICE macro uses are somewhat similar
and are frequently used with PCI_DEVICE_TABLE, so there's some
commonality there.

The checkpatch message could be made --strict/CHK instead of
WARN so most people would never see it.

Of course it could be removed altogether too.  I don't care.
---
(suggested patch is for -next)

 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index dc72a9b..754fbf2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3018,8 +3018,8 @@ sub process {
 
 # check for uses of DEFINE_PCI_DEVICE_TABLE
 		if ($line =~ /\bDEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=/) {
-			if (WARN("DEFINE_PCI_DEVICE_TABLE",
-				 "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) &&
+			if (CHK("DEFINE_PCI_DEVICE_TABLE",
+				"Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) &&
 			    $fix) {
 				$fixed[$fixlinenr] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /;
 			}



^ permalink raw reply related

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: Greg KH @ 2014-07-18 18:17 UTC (permalink / raw)
  To: James Bottomley
  Cc: John W. Linville, Benoit Taine, linux-mips, linux-fbdev,
	linux-pci, dri-devel, linux-kernel, ath5k-devel, linux-acenic,
	linux-scsi, linux-rdma, ath10k, linux-hippi, industrypack-devel,
	linux-mmc, MPT-FusionLinux.pdl, virtualization, ath9k-devel,
	wil6210, linux-pcmcia, linux-can, xen-devel, platform-driver-x86,
	netdev, linux-wireless, users, e1000-devel, linux-crypto
In-Reply-To: <1405702472.30262.1.camel@dabdike.int.hansenpartnership.com>

On Fri, Jul 18, 2014 at 09:54:32AM -0700, James Bottomley wrote:
> On Fri, 2014-07-18 at 09:43 -0700, Greg KH wrote:
> > On Fri, Jul 18, 2014 at 12:22:13PM -0400, John W. Linville wrote:
> > > On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
> > > > We should prefer `const struct pci_device_id` over
> > > > `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> > > > This issue was reported by checkpatch.
> > > 
> > > Honestly, I prefer the macro -- it stands-out more.  Maybe the style
> > > guidelines and/or checkpatch should change instead?
> > 
> > The macro is horrid, no other bus has this type of thing just to save a
> > few characters in typing
> 
> OK, so this is the macro:
> 
> #define DEFINE_PCI_DEVICE_TABLE(_table) \
> 	const struct pci_device_id _table[]
> 
> Could you explain what's so horrible?
> 
> The reason it's useful today is that people forget the const (and
> sometimes the [] making it a true table instead of a pointer).  If you
> use the DEFINE_PCI_DEVICE_TABLE macro, the compile breaks if you use it
> wrongly (good) and you automatically get the correct annotations.

We have almost 1000 more uses of the non-macro version than the "macro"
version in the kernel today:
$ git grep -w DEFINE_PCI_DEVICE_TABLE | wc -l
262
$ git grep "const struct pci_device_id" | wc -l
1254

My big complaint is that we need to be consistant, either pick one or
the other and stick to it.  As the macro is the least used, it's easiest
to fix up, and it also is more consistant with all other kernel
subsystems which do not have such a macro.

As there is no need for the __init macro mess anymore, there's no real
need for the DEFINE_PCI_DEVICE_TABLE macro either.  I think checkpatch
will catch the use of non-const users for the id table already today, it
catches lots of other uses like this already.

> > , so why should PCI be "special" in this regard
> > anymore?
> 
> I think the PCI usage dwarfs most other bus types now, so you could turn
> the question around.  However, I don't think majority voting is a good
> guide to best practise; lets debate the merits for their own sake.

Not really "dwarf", USB is close with over 700 such structures:
$ git grep "const struct usb_device_id" | wc -l
725

And i2c is almost just as big as PCI:
$ git grep "const struct i2c_device_id" | wc -l
1223

So again, this macro is not consistent with the majority of PCI drivers,
nor with any other type of "device id" declaration in the kernel, which
is why I feel it should be removed.

And finally, the PCI documentation itself says to not use this macro, so
this isn't a "new" thing.  From Documentation/PCI/pci.txt:

	The ID table is an array of struct pci_device_id entries ending with an
	all-zero entry.  Definitions with static const are generally preferred.
	Use of the deprecated macro DEFINE_PCI_DEVICE_TABLE should be avoided.

That wording went into the file last December, when we last talked about
this and everyone in that discussion agreed to remove the macro for the
above reasons.

Consistency matters.

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: James Bottomley @ 2014-07-18 18:50 UTC (permalink / raw)
  To: Greg KH
  Cc: John W. Linville, Benoit Taine, linux-mips, linux-fbdev,
	linux-pci, dri-devel, linux-kernel, ath5k-devel, linux-acenic,
	linux-scsi, linux-rdma, ath10k, linux-hippi, industrypack-devel,
	linux-mmc, MPT-FusionLinux.pdl, virtualization, ath9k-devel,
	wil6210, linux-pcmcia, linux-can, xen-devel, platform-driver-x86,
	netdev, linux-wireless, users, e1000-devel, linux-crypto
In-Reply-To: <20140718181759.GB2193@kroah.com>

On Fri, 2014-07-18 at 11:17 -0700, Greg KH wrote:
> On Fri, Jul 18, 2014 at 09:54:32AM -0700, James Bottomley wrote:
> > On Fri, 2014-07-18 at 09:43 -0700, Greg KH wrote:
> > > On Fri, Jul 18, 2014 at 12:22:13PM -0400, John W. Linville wrote:
> > > > On Fri, Jul 18, 2014 at 05:26:47PM +0200, Benoit Taine wrote:
> > > > > We should prefer `const struct pci_device_id` over
> > > > > `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> > > > > This issue was reported by checkpatch.
> > > > 
> > > > Honestly, I prefer the macro -- it stands-out more.  Maybe the style
> > > > guidelines and/or checkpatch should change instead?
> > > 
> > > The macro is horrid, no other bus has this type of thing just to save a
> > > few characters in typing
> > 
> > OK, so this is the macro:
> > 
> > #define DEFINE_PCI_DEVICE_TABLE(_table) \
> > 	const struct pci_device_id _table[]
> > 
> > Could you explain what's so horrible?
> > 
> > The reason it's useful today is that people forget the const (and
> > sometimes the [] making it a true table instead of a pointer).  If you
> > use the DEFINE_PCI_DEVICE_TABLE macro, the compile breaks if you use it
> > wrongly (good) and you automatically get the correct annotations.
> 
> We have almost 1000 more uses of the non-macro version than the "macro"
> version in the kernel today:
> $ git grep -w DEFINE_PCI_DEVICE_TABLE | wc -l
> 262
> $ git grep "const struct pci_device_id" | wc -l
> 1254
> 
> My big complaint is that we need to be consistant, either pick one or
> the other and stick to it.  As the macro is the least used, it's easiest
> to fix up, and it also is more consistant with all other kernel
> subsystems which do not have such a macro.

I've a weak preference for consistency, but not at the expense of
hundreds of patches churning the kernel to remove an innocuous macro.
Churn costs time and effort.

> As there is no need for the __init macro mess anymore, there's no real
> need for the DEFINE_PCI_DEVICE_TABLE macro either.  I think checkpatch
> will catch the use of non-const users for the id table already today, it
> catches lots of other uses like this already.
> 
> > > , so why should PCI be "special" in this regard
> > > anymore?
> > 
> > I think the PCI usage dwarfs most other bus types now, so you could turn
> > the question around.  However, I don't think majority voting is a good
> > guide to best practise; lets debate the merits for their own sake.
> 
> Not really "dwarf", USB is close with over 700 such structures:
> $ git grep "const struct usb_device_id" | wc -l
> 725
> 
> And i2c is almost just as big as PCI:
> $ git grep "const struct i2c_device_id" | wc -l
> 1223
> 
> So again, this macro is not consistent with the majority of PCI drivers,
> nor with any other type of "device id" declaration in the kernel, which
> is why I feel it should be removed.
> 
> And finally, the PCI documentation itself says to not use this macro, so
> this isn't a "new" thing.  From Documentation/PCI/pci.txt:
> 
> 	The ID table is an array of struct pci_device_id entries ending with an
> 	all-zero entry.  Definitions with static const are generally preferred.
> 	Use of the deprecated macro DEFINE_PCI_DEVICE_TABLE should be avoided.
> 
> That wording went into the file last December, when we last talked about
> this and everyone in that discussion agreed to remove the macro for the
> above reasons.
> 
> Consistency matters.

In this case, I don't think it does that much ... a cut and paste either
way (from a macro or non-macro based driver) yields correct code.  Since
there's no bug here and no apparent way to misuse the macro, why bother?

Anyway, it's PCI code ... let the PCI maintainer decide.  However, if he
does want this do it as one big bang patch via either the PCI or Trivial
tree (latter because Jiří has experience doing this, but the former
might be useful so the decider feels the pain ...)

James



^ permalink raw reply

* Re: [PATCH 0/25] Replace DEFINE_PCI_DEVICE_TABLE macro use
From: David Miller @ 2014-07-21  4:18 UTC (permalink / raw)
  To: benoit.taine
  Cc: linux-pci, ath5k-devel, ath9k-devel, linux-hippi, dri-devel,
	linux-acenic, wil6210, platform-driver-x86, linux-scsi,
	linux-kernel, netdev, linux-wireless, linux-mips, users,
	linux-rdma, virtualization, industrypack-devel, linux-can,
	linux-mmc, linux-fbdev, ath10k, linux-crypto, MPT-FusionLinux.pdl,
	devel, xen-devel, linux-pcmcia, e1000-devel
In-Reply-To: <1405697232-11785-1-git-send-email-benoit.taine@lip6.fr>

From: Benoit Taine <benoit.taine@lip6.fr>
Date: Fri, 18 Jul 2014 17:26:47 +0200

> We should prefer `const struct pci_device_id` over
> `DEFINE_PCI_DEVICE_TABLE` to meet kernel coding style guidelines.
> This issue was reported by checkpatch.
> 
> A simplified version of the semantic patch that makes this change is as
> follows (http://coccinelle.lip6.fr/):
> 
> // <smpl>
> 
> @@
> identifier i;
> declarer name DEFINE_PCI_DEVICE_TABLE;
> initializer z;
> @@
> 
> - DEFINE_PCI_DEVICE_TABLE(i)
> + const struct pci_device_id i[]
> = z;
> 
> // </smpl>
> 
> I have 103 patches ready, and will only send a few for you to judge if
> it is useful enough, and to prevent from spamming too much.

I'm fine with this wrt. the networking changes, but I don't think this should
be merged via my tree.

^ permalink raw reply

* Re: [PATCH] video: fbdev: uvesafb.c:  Cleaning up variable that is never used
From: Pavel Machek @ 2014-07-21 21:25 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Rickard Strandqvist, Wang YanQing, Jingoo Han, Evgeniy Polyakov,
	Joe Perches, Sachin Kamat, David Fries, linux-fbdev, linux-kernel
In-Reply-To: <1404564682-21983-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

On Sat 2014-07-05 14:51:22, Rickard Strandqvist wrote:
> From: Rickard Strandqvist <rickard.strandqvist@sonymobile.com>
> 
> Variable ar assigned a value that is never used.
> I have also removed all the code that thereby serves no purpose.
> 
> This was found using a static code analysis program called cppcheck

Are you sure this is right fix?

Should we be returning the error when there's error?
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply

* Re: [PATCH] video: fbdev: uvesafb.c: Cleaning up variable that is never used
From: Pavel Machek @ 2014-07-22  9:27 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Joe Perches, Jean-Christophe Plagniol-Villard, Tomi Valkeinen,
	Sachin Kamat, Evgeniy Polyakov, Wang YanQing, Rickard Strandqvist,
	Jingoo Han, Linux Fbdev development list, David Fries,
	linux-kernel
In-Reply-To: <CAFo99gYhrNR68mdJY=fn1x-+4U=6gdv=C4-Xn-w-YJAPSa5bBQ@mail.gmail.com>

On Tue 2014-07-22 11:16:58, Rickard Strandqvist wrote:
> Hi
> 
> Sure, I agree. But as I thought that I would not change
> currentfunctionality, I would increase the chance that the patches were
> included. And it would of course also clarify this type of problem.

I'm trying to say that getting rid of the variables without changing
functionality might be wrong thing to do, for example in this case. It
looks like error handing is missing by mistake, and you are removing
traces saying that error handing is required here.

Dunno. Perhaps don't push patches where solution is not obvious?

Or push them but mark the place with fixme? 

									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply

* Re: [PATCH v9] video: ARM CLCD: Add DT support
From: Pawel Moll @ 2014-07-22 10:02 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1404824767.21897.7.camel@hornet>

On Tue, 2014-07-08 at 14:06 +0100, Pawel Moll wrote:
> On Tue, 2014-06-24 at 12:55 +0100, Pawel Moll wrote:
> > This patch adds basic DT bindings for the PL11x CLCD cells
> > and make their fbdev driver use them.
> > 
> > Signed-off-by: Pawel Moll <pawel.moll@arm.com>
> 
> As two weeks passed without any further comment, I'm assuming that there
> are no more obstacles for this patch to be merged.
> 
> Tomi, will you pick it up for 3.17, as you offered? Russell, if you
> prefer to take it via your tree, it's in your system as 8005/4.

Ping...

Tomi?

Paweł


^ permalink raw reply

* Re: PATCH] video: fix up versatile CLCD helper move
From: Linus Walleij @ 2014-07-22 12:49 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <9561883.zqovrcBa4A@wuerfel>

On Tue, Jul 15, 2014 at 10:39 AM, Arnd Bergmann <arnd@arndb.de> wrote:

> commit 11c32d7b6274cb0f ("video: move Versatile CLCD helpers")
> moved files out of the plat-versatile directory but in the process
> got a few of the dependencies wrong:
>
> - If CONFIG_FB is not set, the file no longer gets built, resulting
>   in a link error
> - If CONFIG_FB or CONFIG_FB_ARMCLCD are disabled, we also get a
>   Kconfig warning for incorrect dependencies due to the symbol
>   being 'select'ed from the platform Kconfig.
> - When the file is not built, we also get a link error for missing
>   symbols.
>
> This patch should fix all three, by removing the 'select' statements,
> changing the Kconfig description of the symbol to be enabled in
> exactly the right configurations, and adding inline stub functions
> for the case when the framebuffer driver is disabled.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Excellent, thanks a lot Arnd! I struggled with this but didn't
get it right after all :-/
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply


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