diff mbox series

[1/2] video: ssd1307fb: Print PWM period using 64-bit format specifier

Message ID 20200615141606.2814208-2-thierry.reding@gmail.com
State Accepted
Headers show
Series pwm: Miscellaneous fixes for 64-bit support | expand

Commit Message

Thierry Reding June 15, 2020, 2:16 p.m. UTC
The PWM core will soon change the duty cycle and period of PWMs to 64
bits to allow for a broader range of values. Use a 64-bit format
specifier to avoid a warning when that change is made.

Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 drivers/video/fbdev/ssd1307fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Uwe Kleine-König June 15, 2020, 3:18 p.m. UTC | #1
Hello,

On Mon, Jun 15, 2020 at 04:16:05PM +0200, Thierry Reding wrote:
> The PWM core will soon change the duty cycle and period of PWMs to 64
> bits to allow for a broader range of values. Use a 64-bit format
> specifier to avoid a warning when that change is made.
> 
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> ---
>  drivers/video/fbdev/ssd1307fb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
> index 8e06ba912d60..09425ec317ba 100644
> --- a/drivers/video/fbdev/ssd1307fb.c
> +++ b/drivers/video/fbdev/ssd1307fb.c
> @@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
>  		/* Enable the PWM */
>  		pwm_enable(par->pwm);
>  
> -		dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> +		dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
>  			par->pwm->pwm, pwm_get_period(par->pwm));

I wonder a bit about the driver accessing par->pwm->pwm, but that's
orthogonal to this patch.

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

Best regards
Uwe
kernel test robot June 15, 2020, 5:19 p.m. UTC | #2
Hi Thierry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.8-rc1 next-20200615]
[cannot apply to pwm/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Thierry-Reding/pwm-Miscellaneous-fixes-for-64-bit-support/20200615-221856
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b3a9e3b9622ae10064826dccb4f7a52bd88c7407
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/printk.h:404,
from include/linux/kernel.h:15,
from include/asm-generic/bug.h:19,
from arch/sparc/include/asm/bug.h:25,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from arch/sparc/include/asm/current.h:15,
from include/linux/sched.h:12,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/backlight.h:12,
from drivers/video/fbdev/ssd1307fb.c:8:
drivers/video/fbdev/ssd1307fb.c: In function 'ssd1307fb_init':
>> drivers/video/fbdev/ssd1307fb.c:315:30: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 5 has type 'unsigned int' [-Wformat=]
315 |   dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.n",
|                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
125 |   func(&id, ##__VA_ARGS__);           |               ^~~~~~~~~~~
include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
157 |  _dynamic_func_call(fmt,__dynamic_dev_dbg,            |  ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:115:2: note: in expansion of macro 'dynamic_dev_dbg'
115 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
|  ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:115:23: note: in expansion of macro 'dev_fmt'
115 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
|                       ^~~~~~~
drivers/video/fbdev/ssd1307fb.c:315:3: note: in expansion of macro 'dev_dbg'
315 |   dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.n",
|   ^~~~~~~
drivers/video/fbdev/ssd1307fb.c:315:53: note: format string is defined here
315 |   dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.n",
|                                                  ~~~^
|                                                     |
|                                                     long long unsigned int
|                                                  %u

vim +315 drivers/video/fbdev/ssd1307fb.c

   294	
   295	static int ssd1307fb_init(struct ssd1307fb_par *par)
   296	{
   297		struct pwm_state pwmstate;
   298		int ret;
   299		u32 precharge, dclk, com_invdir, compins;
   300	
   301		if (par->device_info->need_pwm) {
   302			par->pwm = pwm_get(&par->client->dev, NULL);
   303			if (IS_ERR(par->pwm)) {
   304				dev_err(&par->client->dev, "Could not get PWM from device tree!\n");
   305				return PTR_ERR(par->pwm);
   306			}
   307	
   308			pwm_init_state(par->pwm, &pwmstate);
   309			pwm_set_relative_duty_cycle(&pwmstate, 50, 100);
   310			pwm_apply_state(par->pwm, &pwmstate);
   311	
   312			/* Enable the PWM */
   313			pwm_enable(par->pwm);
   314	
 > 315			dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
   316				par->pwm->pwm, pwm_get_period(par->pwm));
   317		}
   318	
   319		/* Set initial contrast */
   320		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST);
   321		if (ret < 0)
   322			return ret;
   323	
   324		ret = ssd1307fb_write_cmd(par->client, par->contrast);
   325		if (ret < 0)
   326			return ret;
   327	
   328		/* Set segment re-map */
   329		if (par->seg_remap) {
   330			ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON);
   331			if (ret < 0)
   332				return ret;
   333		}
   334	
   335		/* Set COM direction */
   336		com_invdir = 0xc0 | par->com_invdir << 3;
   337		ret = ssd1307fb_write_cmd(par->client,  com_invdir);
   338		if (ret < 0)
   339			return ret;
   340	
   341		/* Set multiplex ratio value */
   342		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO);
   343		if (ret < 0)
   344			return ret;
   345	
   346		ret = ssd1307fb_write_cmd(par->client, par->height - 1);
   347		if (ret < 0)
   348			return ret;
   349	
   350		/* set display offset value */
   351		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET);
   352		if (ret < 0)
   353			return ret;
   354	
   355		ret = ssd1307fb_write_cmd(par->client, par->com_offset);
   356		if (ret < 0)
   357			return ret;
   358	
   359		/* Set clock frequency */
   360		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ);
   361		if (ret < 0)
   362			return ret;
   363	
   364		dclk = ((par->dclk_div - 1) & 0xf) | (par->dclk_frq & 0xf) << 4;
   365		ret = ssd1307fb_write_cmd(par->client, dclk);
   366		if (ret < 0)
   367			return ret;
   368	
   369		/* Set Set Area Color Mode ON/OFF & Low Power Display Mode */
   370		if (par->area_color_enable || par->low_power) {
   371			u32 mode;
   372	
   373			ret = ssd1307fb_write_cmd(par->client,
   374						  SSD1307FB_SET_AREA_COLOR_MODE);
   375			if (ret < 0)
   376				return ret;
   377	
   378			mode = (par->area_color_enable ? 0x30 : 0) |
   379				(par->low_power ? 5 : 0);
   380			ret = ssd1307fb_write_cmd(par->client, mode);
   381			if (ret < 0)
   382				return ret;
   383		}
   384	
   385		/* Set precharge period in number of ticks from the internal clock */
   386		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD);
   387		if (ret < 0)
   388			return ret;
   389	
   390		precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4;
   391		ret = ssd1307fb_write_cmd(par->client, precharge);
   392		if (ret < 0)
   393			return ret;
   394	
   395		/* Set COM pins configuration */
   396		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG);
   397		if (ret < 0)
   398			return ret;
   399	
   400		compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5;
   401		ret = ssd1307fb_write_cmd(par->client, compins);
   402		if (ret < 0)
   403			return ret;
   404	
   405		/* Set VCOMH */
   406		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH);
   407		if (ret < 0)
   408			return ret;
   409	
   410		ret = ssd1307fb_write_cmd(par->client, par->vcomh);
   411		if (ret < 0)
   412			return ret;
   413	
   414		/* Turn on the DC-DC Charge Pump */
   415		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
   416		if (ret < 0)
   417			return ret;
   418	
   419		ret = ssd1307fb_write_cmd(par->client,
   420			BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0));
   421		if (ret < 0)
   422			return ret;
   423	
   424		/* Set lookup table */
   425		if (par->lookup_table_set) {
   426			int i;
   427	
   428			ret = ssd1307fb_write_cmd(par->client,
   429						  SSD1307FB_SET_LOOKUP_TABLE);
   430			if (ret < 0)
   431				return ret;
   432	
   433			for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) {
   434				u8 val = par->lookup_table[i];
   435	
   436				if (val < 31 || val > 63)
   437					dev_warn(&par->client->dev,
   438						 "lookup table index %d value out of range 31 <= %d <= 63\n",
   439						 i, val);
   440				ret = ssd1307fb_write_cmd(par->client, val);
   441				if (ret < 0)
   442					return ret;
   443			}
   444		}
   445	
   446		/* Switch to horizontal addressing mode */
   447		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE);
   448		if (ret < 0)
   449			return ret;
   450	
   451		ret = ssd1307fb_write_cmd(par->client,
   452					  SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL);
   453		if (ret < 0)
   454			return ret;
   455	
   456		/* Set column range */
   457		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
   458		if (ret < 0)
   459			return ret;
   460	
   461		ret = ssd1307fb_write_cmd(par->client, 0x0);
   462		if (ret < 0)
   463			return ret;
   464	
   465		ret = ssd1307fb_write_cmd(par->client, par->width - 1);
   466		if (ret < 0)
   467			return ret;
   468	
   469		/* Set page range */
   470		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
   471		if (ret < 0)
   472			return ret;
   473	
   474		ret = ssd1307fb_write_cmd(par->client, par->page_offset);
   475		if (ret < 0)
   476			return ret;
   477	
   478		ret = ssd1307fb_write_cmd(par->client,
   479					  par->page_offset +
   480					  DIV_ROUND_UP(par->height, 8) - 1);
   481		if (ret < 0)
   482			return ret;
   483	
   484		/* Clear the screen */
   485		ssd1307fb_update_display(par);
   486	
   487		/* Turn on the display */
   488		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON);
   489		if (ret < 0)
   490			return ret;
   491	
   492		return 0;
   493	}
   494	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot June 15, 2020, 5:25 p.m. UTC | #3
Hi Thierry,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.8-rc1 next-20200615]
[cannot apply to pwm/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Thierry-Reding/pwm-Miscellaneous-fixes-for-64-bit-support/20200615-221856
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b3a9e3b9622ae10064826dccb4f7a52bd88c7407
config: h8300-randconfig-r004-20200615 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=h8300 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/printk.h:404,
from include/linux/kernel.h:15,
from include/asm-generic/bug.h:19,
from arch/h8300/include/asm/bug.h:8,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from include/asm-generic/current.h:5,
from ./arch/h8300/include/generated/asm/current.h:1,
from include/linux/sched.h:12,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/backlight.h:12,
from drivers/video/fbdev/ssd1307fb.c:8:
drivers/video/fbdev/ssd1307fb.c: In function 'ssd1307fb_init':
>> drivers/video/fbdev/ssd1307fb.c:315:30: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 5 has type 'unsigned int' [-Wformat=]
315 |   dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.n",
|                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
125 |   func(&id, ##__VA_ARGS__);           |               ^~~~~~~~~~~
include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
157 |  _dynamic_func_call(fmt,__dynamic_dev_dbg,            |  ^~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:115:2: note: in expansion of macro 'dynamic_dev_dbg'
115 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
|  ^~~~~~~~~~~~~~~
include/linux/dev_printk.h:115:23: note: in expansion of macro 'dev_fmt'
115 |  dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
|                       ^~~~~~~
drivers/video/fbdev/ssd1307fb.c:315:3: note: in expansion of macro 'dev_dbg'
315 |   dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.n",
|   ^~~~~~~
drivers/video/fbdev/ssd1307fb.c:315:53: note: format string is defined here
315 |   dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.n",
|                                                  ~~~^
|                                                     |
|                                                     long long unsigned int
|                                                  %u

vim +315 drivers/video/fbdev/ssd1307fb.c

   294	
   295	static int ssd1307fb_init(struct ssd1307fb_par *par)
   296	{
   297		struct pwm_state pwmstate;
   298		int ret;
   299		u32 precharge, dclk, com_invdir, compins;
   300	
   301		if (par->device_info->need_pwm) {
   302			par->pwm = pwm_get(&par->client->dev, NULL);
   303			if (IS_ERR(par->pwm)) {
   304				dev_err(&par->client->dev, "Could not get PWM from device tree!\n");
   305				return PTR_ERR(par->pwm);
   306			}
   307	
   308			pwm_init_state(par->pwm, &pwmstate);
   309			pwm_set_relative_duty_cycle(&pwmstate, 50, 100);
   310			pwm_apply_state(par->pwm, &pwmstate);
   311	
   312			/* Enable the PWM */
   313			pwm_enable(par->pwm);
   314	
 > 315			dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
   316				par->pwm->pwm, pwm_get_period(par->pwm));
   317		}
   318	
   319		/* Set initial contrast */
   320		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST);
   321		if (ret < 0)
   322			return ret;
   323	
   324		ret = ssd1307fb_write_cmd(par->client, par->contrast);
   325		if (ret < 0)
   326			return ret;
   327	
   328		/* Set segment re-map */
   329		if (par->seg_remap) {
   330			ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON);
   331			if (ret < 0)
   332				return ret;
   333		}
   334	
   335		/* Set COM direction */
   336		com_invdir = 0xc0 | par->com_invdir << 3;
   337		ret = ssd1307fb_write_cmd(par->client,  com_invdir);
   338		if (ret < 0)
   339			return ret;
   340	
   341		/* Set multiplex ratio value */
   342		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO);
   343		if (ret < 0)
   344			return ret;
   345	
   346		ret = ssd1307fb_write_cmd(par->client, par->height - 1);
   347		if (ret < 0)
   348			return ret;
   349	
   350		/* set display offset value */
   351		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET);
   352		if (ret < 0)
   353			return ret;
   354	
   355		ret = ssd1307fb_write_cmd(par->client, par->com_offset);
   356		if (ret < 0)
   357			return ret;
   358	
   359		/* Set clock frequency */
   360		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ);
   361		if (ret < 0)
   362			return ret;
   363	
   364		dclk = ((par->dclk_div - 1) & 0xf) | (par->dclk_frq & 0xf) << 4;
   365		ret = ssd1307fb_write_cmd(par->client, dclk);
   366		if (ret < 0)
   367			return ret;
   368	
   369		/* Set Set Area Color Mode ON/OFF & Low Power Display Mode */
   370		if (par->area_color_enable || par->low_power) {
   371			u32 mode;
   372	
   373			ret = ssd1307fb_write_cmd(par->client,
   374						  SSD1307FB_SET_AREA_COLOR_MODE);
   375			if (ret < 0)
   376				return ret;
   377	
   378			mode = (par->area_color_enable ? 0x30 : 0) |
   379				(par->low_power ? 5 : 0);
   380			ret = ssd1307fb_write_cmd(par->client, mode);
   381			if (ret < 0)
   382				return ret;
   383		}
   384	
   385		/* Set precharge period in number of ticks from the internal clock */
   386		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD);
   387		if (ret < 0)
   388			return ret;
   389	
   390		precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4;
   391		ret = ssd1307fb_write_cmd(par->client, precharge);
   392		if (ret < 0)
   393			return ret;
   394	
   395		/* Set COM pins configuration */
   396		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG);
   397		if (ret < 0)
   398			return ret;
   399	
   400		compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5;
   401		ret = ssd1307fb_write_cmd(par->client, compins);
   402		if (ret < 0)
   403			return ret;
   404	
   405		/* Set VCOMH */
   406		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH);
   407		if (ret < 0)
   408			return ret;
   409	
   410		ret = ssd1307fb_write_cmd(par->client, par->vcomh);
   411		if (ret < 0)
   412			return ret;
   413	
   414		/* Turn on the DC-DC Charge Pump */
   415		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP);
   416		if (ret < 0)
   417			return ret;
   418	
   419		ret = ssd1307fb_write_cmd(par->client,
   420			BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0));
   421		if (ret < 0)
   422			return ret;
   423	
   424		/* Set lookup table */
   425		if (par->lookup_table_set) {
   426			int i;
   427	
   428			ret = ssd1307fb_write_cmd(par->client,
   429						  SSD1307FB_SET_LOOKUP_TABLE);
   430			if (ret < 0)
   431				return ret;
   432	
   433			for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) {
   434				u8 val = par->lookup_table[i];
   435	
   436				if (val < 31 || val > 63)
   437					dev_warn(&par->client->dev,
   438						 "lookup table index %d value out of range 31 <= %d <= 63\n",
   439						 i, val);
   440				ret = ssd1307fb_write_cmd(par->client, val);
   441				if (ret < 0)
   442					return ret;
   443			}
   444		}
   445	
   446		/* Switch to horizontal addressing mode */
   447		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE);
   448		if (ret < 0)
   449			return ret;
   450	
   451		ret = ssd1307fb_write_cmd(par->client,
   452					  SSD1307FB_SET_ADDRESS_MODE_HORIZONTAL);
   453		if (ret < 0)
   454			return ret;
   455	
   456		/* Set column range */
   457		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE);
   458		if (ret < 0)
   459			return ret;
   460	
   461		ret = ssd1307fb_write_cmd(par->client, 0x0);
   462		if (ret < 0)
   463			return ret;
   464	
   465		ret = ssd1307fb_write_cmd(par->client, par->width - 1);
   466		if (ret < 0)
   467			return ret;
   468	
   469		/* Set page range */
   470		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE);
   471		if (ret < 0)
   472			return ret;
   473	
   474		ret = ssd1307fb_write_cmd(par->client, par->page_offset);
   475		if (ret < 0)
   476			return ret;
   477	
   478		ret = ssd1307fb_write_cmd(par->client,
   479					  par->page_offset +
   480					  DIV_ROUND_UP(par->height, 8) - 1);
   481		if (ret < 0)
   482			return ret;
   483	
   484		/* Clear the screen */
   485		ssd1307fb_update_display(par);
   486	
   487		/* Turn on the display */
   488		ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON);
   489		if (ret < 0)
   490			return ret;
   491	
   492		return 0;
   493	}
   494	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Geert Uytterhoeven June 17, 2020, 7:18 a.m. UTC | #4
Hi Thierry,

On Mon, Jun 15, 2020 at 4:17 PM Thierry Reding <thierry.reding@gmail.com> wrote:
> The PWM core will soon change the duty cycle and period of PWMs to 64
> bits to allow for a broader range of values. Use a 64-bit format
> specifier to avoid a warning when that change is made.
>
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

> --- a/drivers/video/fbdev/ssd1307fb.c
> +++ b/drivers/video/fbdev/ssd1307fb.c
> @@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
>                 /* Enable the PWM */
>                 pwm_enable(par->pwm);
>
> -               dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> +               dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
>                         par->pwm->pwm, pwm_get_period(par->pwm));
>         }

This change must be done together with changing the return type of
pwm_get_period(), else you will get a compiler warning, and will print a
bogus value.

Gr{oetje,eeting}s,

                        Geert
Uwe Kleine-König June 17, 2020, 5:30 p.m. UTC | #5
On Wed, Jun 17, 2020 at 09:18:34AM +0200, Geert Uytterhoeven wrote:
> Hi Thierry,
> 
> On Mon, Jun 15, 2020 at 4:17 PM Thierry Reding <thierry.reding@gmail.com> wrote:
> > The PWM core will soon change the duty cycle and period of PWMs to 64
> > bits to allow for a broader range of values. Use a 64-bit format
> > specifier to avoid a warning when that change is made.
> >
> > Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> 
> > --- a/drivers/video/fbdev/ssd1307fb.c
> > +++ b/drivers/video/fbdev/ssd1307fb.c
> > @@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
> >                 /* Enable the PWM */
> >                 pwm_enable(par->pwm);
> >
> > -               dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> > +               dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
> >                         par->pwm->pwm, pwm_get_period(par->pwm));
> >         }
> 
> This change must be done together with changing the return type of
> pwm_get_period(), else you will get a compiler warning, and will print a
> bogus value.

Right, or we must change to passing (unsigned long
long)pwm_get_period(par->pwm), then change the prototype and then drop
the cast again.

Best regards
Uwe
Guru Das Srinagesh June 18, 2020, 8:05 p.m. UTC | #6
On Wed, Jun 17, 2020 at 09:18:34AM +0200, Geert Uytterhoeven wrote:
> Hi Thierry,
> 
> On Mon, Jun 15, 2020 at 4:17 PM Thierry Reding <thierry.reding@gmail.com> wrote:
> > The PWM core will soon change the duty cycle and period of PWMs to 64
> > bits to allow for a broader range of values. Use a 64-bit format
> > specifier to avoid a warning when that change is made.
> >
> > Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> 
> > --- a/drivers/video/fbdev/ssd1307fb.c
> > +++ b/drivers/video/fbdev/ssd1307fb.c
> > @@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
> >                 /* Enable the PWM */
> >                 pwm_enable(par->pwm);
> >
> > -               dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> > +               dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
> >                         par->pwm->pwm, pwm_get_period(par->pwm));
> >         }
> 
> This change must be done together with changing the return type of
> pwm_get_period(), else you will get a compiler warning, and will print a
> bogus value.

Hi Geert,

Yes, this is already being done in the patch series [1] that forms the
base for this specific patch.

[1] https://lore.kernel.org/lkml/64f9ba1c9d6c49a397f12846493707883cee430f.1591136989.git.gurus@codeaurora.org/

Thank you.

Guru Das.
Geert Uytterhoeven June 19, 2020, 6:46 a.m. UTC | #7
Hi Guru,

On Thu, Jun 18, 2020 at 10:05 PM Guru Das Srinagesh
<gurus@codeaurora.org> wrote:
> On Wed, Jun 17, 2020 at 09:18:34AM +0200, Geert Uytterhoeven wrote:
> > On Mon, Jun 15, 2020 at 4:17 PM Thierry Reding <thierry.reding@gmail.com> wrote:
> > > The PWM core will soon change the duty cycle and period of PWMs to 64
> > > bits to allow for a broader range of values. Use a 64-bit format
> > > specifier to avoid a warning when that change is made.
> > >
> > > Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> >
> > > --- a/drivers/video/fbdev/ssd1307fb.c
> > > +++ b/drivers/video/fbdev/ssd1307fb.c
> > > @@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
> > >                 /* Enable the PWM */
> > >                 pwm_enable(par->pwm);
> > >
> > > -               dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
> > > +               dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
> > >                         par->pwm->pwm, pwm_get_period(par->pwm));
> > >         }
> >
> > This change must be done together with changing the return type of
> > pwm_get_period(), else you will get a compiler warning, and will print a
> > bogus value.
>
> Hi Geert,
>
> Yes, this is already being done in the patch series [1] that forms the
> base for this specific patch.
>
> [1] https://lore.kernel.org/lkml/64f9ba1c9d6c49a397f12846493707883cee430f.1591136989.git.gurus@codeaurora.org/

IC, but the "will soon" suggested otherwise.
In any case, not combining both into a single patch causes a bisection
regression, regardless of the order in which they are applied.

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 8e06ba912d60..09425ec317ba 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -312,7 +312,7 @@  static int ssd1307fb_init(struct ssd1307fb_par *par)
 		/* Enable the PWM */
 		pwm_enable(par->pwm);
 
-		dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n",
+		dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n",
 			par->pwm->pwm, pwm_get_period(par->pwm));
 	}