Skip to contentSkip to conversation

pwm: Miscellaneous fixes for 64-bit support

PATCH In review Thierry Reding 6 participants 12 messages Jun 15, 2020 – Jun 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover pwm: Miscellaneous fixes for 64-bit support

Hi,

this contains a couple of fixes for issues that I ran into after applying Guru's series to convert PWM period and duty-cycle to 64-bit.

Bartlomiej, can you provide an Acked-by on the first patch so that I can take it through the PWM tree along with the rest of Guru's series?

Thanks,
Thierry

Thierry Reding (2):
video: ssd1307fb: Print PWM period using 64-bit format specifier
pwm: iqs620a: Use 64-bit division

 drivers/pwm/pwm-iqs620a.c       | 7 ++++---
 drivers/video/fbdev/ssd1307fb.c | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.24.1
#1 lore raw

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

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.

---
 drivers/video/fbdev/ssd1307fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/ssd1307fb.c +1 -1
index 8e06ba912d60..09425ec317ba 100644
@@ -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));
 	}
 
Signature · 1 line
2.24.1
Acked-by on v1 1/2
#2 lore raw

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

Hello,

Quoted 14 lines · Thierry Reding

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.

---
 drivers/video/fbdev/ssd1307fb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/ssd1307fb.c +0 -0
index 8e06ba912d60..09425ec317ba 100644

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_init(struct ssd1307fb_par *par) · line 316

Quoted 6 lines
drivers/video/fbdev/ssd1307fb.c +1 -1
@@ -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.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#3 lore raw

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

In reply to Thierry Reding
I love your patch! Perhaps something to improve:

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

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/[email protected]

#4 lore raw

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

In reply to Thierry Reding
I love your patch! Perhaps something to improve:

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

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/[email protected]

#5 lore raw

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

In reply to Thierry Reding

Hi Thierry,

Quoted 9 lines · Thierry Reding

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.

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_init(struct ssd1307fb_par *par) · line 317

Quoted 7 lines
drivers/video/fbdev/ssd1307fb.c +1 -1
@@ -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

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#6 lore raw

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

Quoted 15 lines · Geert Uytterhoeven

Hi Thierry,

Quoted 12 lines · Thierry Reding

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.

drivers/video/fbdev/ssd1307fb.c +0 -0
@@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
                /* Enable the PWM */
                pwm_enable(par->pwm);
 
Quoted 8 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_init(struct ssd1307fb_par *par) · line 317

Quoted 4 lines
drivers/video/fbdev/ssd1307fb.c +1 -1
-               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

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#7 lore raw

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

In reply to Geert Uytterhoeven
Quoted 15 lines · Geert Uytterhoeven

Hi Thierry,

Quoted 12 lines · Thierry Reding

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.

drivers/video/fbdev/ssd1307fb.c +0 -0
@@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
                /* Enable the PWM */
                pwm_enable(par->pwm);
 
Quoted 8 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_init(struct ssd1307fb_par *par) · line 317

Quoted 4 lines
drivers/video/fbdev/ssd1307fb.c +1 -1
-               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.

#8 lore raw

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

Hi Guru,

Quoted 23 lines · Guru Das Srinagesh
Quoted 13 lines · Geert Uytterhoeven
Quoted 12 lines · Thierry Reding

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.

drivers/video/fbdev/ssd1307fb.c +0 -0
@@ -312,7 +312,7 @@ static int ssd1307fb_init(struct ssd1307fb_par *par)
                /* Enable the PWM */
                pwm_enable(par->pwm);
 
Quoted 8 lines

drivers/video/fbdev/ssd1307fb.c static int ssd1307fb_init(struct ssd1307fb_par *par) · line 317

Quoted 4 lines
drivers/video/fbdev/ssd1307fb.c +1 -1
-               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.

Quoted 6 lines

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

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw

PATCH 2/2 pwm: iqs620a: Use 64-bit division

In reply to Thierry Reding

The PWM framework is going to change the PWM period and duty cycles to be 64-bit unsigned integers. To avoid build errors on platforms that do not natively support 64-bit division, use explicity 64-bit division.

---
 drivers/pwm/pwm-iqs620a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pwm/pwm-iqs620a.c +4 -3
index 674f0e238ba0..b2bb27eff623 100644
@@ -46,7 +46,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 {
 	struct iqs620_pwm_private *iqs620_pwm;
 	struct iqs62x_core *iqs62x;
-	int duty_scale, ret;
+	u64 duty_scale;
+	int ret;
 
 	if (state->polarity != PWM_POLARITY_NORMAL)
 		return -ENOTSUPP;
@@ -69,7 +70,7 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	 * For lower duty cycles (e.g. 0), the PWM output is simply disabled to
 	 * allow an external pull-down resistor to hold the GPIO3/LTX pin low.
 	 */
-	duty_scale = state->duty_cycle * 256 / IQS620_PWM_PERIOD_NS;
+	duty_scale = div_u64(state->duty_cycle * 256, IQS620_PWM_PERIOD_NS);
 
 	mutex_lock(&iqs620_pwm->lock);
 
@@ -81,7 +82,7 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	}
 
 	if (duty_scale) {
-		u8 duty_val = min(duty_scale - 1, 0xFF);
+		u8 duty_val = min_t(u64, duty_scale - 1, 0xff);
 
 		ret = regmap_write(iqs62x->regmap, IQS620_PWM_DUTY_CYCLE,
 				   duty_val);
Signature · 1 line
2.24.1
Acked-by on v1 2/2
#10 lore raw

Re: [PATCH 2/2] pwm: iqs620a: Use 64-bit division

Quoted 5 lines · Thierry Reding

The PWM framework is going to change the PWM period and duty cycles to be 64-bit unsigned integers. To avoid build errors on platforms that do not natively support 64-bit division, use explicity 64-bit division.

LGTM,

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
Acked-by on v1 2/2
#11 lore raw

Re: [PATCH 2/2] pwm: iqs620a: Use 64-bit division

In reply to Thierry Reding
Quoted 8 lines · Thierry Reding

The PWM framework is going to change the PWM period and duty cycles to be 64-bit unsigned integers. To avoid build errors on platforms that do not natively support 64-bit division, use explicity 64-bit division.

---
 drivers/pwm/pwm-iqs620a.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog