All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] leds: pca955x: Add HW blink support
@ 2022-04-11 16:20 ` Eddie James
  0 siblings, 0 replies; 24+ messages in thread
From: Eddie James @ 2022-04-11 16:20 UTC (permalink / raw)
  To: linux-leds
  Cc: linux-kernel, pavel, patrick, andy.shevchenko, openbmc, joel,
	Eddie James

This series adds support for blinking using the PCA955x chip, falling
back to software blinking if another LED on the chip is already blinking
at a different rate, or if the requested rate isn't representable with
the PCA955x.
Also included are some minor clean up and optimization changes that make
the HW blinking a bit easier.

Changes since v2:
 - Split the cleanup patch
 - Prettier dev_err calls
 - Include units for blink period and use defined unit translations
   rather than just a number.
 - Use positive conditionals.

Changes since v1:
 - Rework the blink function to fallback to software blinking if the
   period is out of range of the chip's capabilities or if another LED
   on the chip is already blinking at a different rate.
 - Add the cleanup patch

Eddie James (4):
  leds: pca955x: Refactor with helper functions and renaming
  leds: pca955x: Use pointers to driver data rather than I2C client
  leds: pca955x: Optimize probe led selection
  leds: pca955x: Add HW blink support

 drivers/leds/leds-pca955x.c | 341 ++++++++++++++++++++++++------------
 1 file changed, 232 insertions(+), 109 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: [PATCH v3 4/4] leds: pca955x: Add HW blink support
  2022-04-11 16:20   ` Eddie James
  (?)
  (?)
@ 2022-04-12 11:33 ` Dan Carpenter
  -1 siblings, 0 replies; 24+ messages in thread
From: kernel test robot @ 2022-04-12 11:22 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6627 bytes --]

CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
In-Reply-To: <20220411162033.39613-5-eajames@linux.ibm.com>
References: <20220411162033.39613-5-eajames@linux.ibm.com>
TO: Eddie James <eajames@linux.ibm.com>
TO: linux-leds(a)vger.kernel.org
CC: linux-kernel(a)vger.kernel.org
CC: pavel(a)ucw.cz
CC: patrick(a)stwcx.xyz
CC: andy.shevchenko(a)gmail.com
CC: openbmc(a)lists.ozlabs.org
CC: joel(a)jms.id.au
CC: Eddie James <eajames@linux.ibm.com>

Hi Eddie,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pavel-leds/for-next]
[also build test WARNING on linus/master v5.18-rc2 next-20220412]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/intel-lab-lkp/linux/commits/Eddie-James/leds-pca955x-Add-HW-blink-support/20220412-002330
base:   git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
:::::: branch date: 19 hours ago
:::::: commit date: 19 hours ago
config: i386-randconfig-m021-20220411 (https://download.01.org/0day-ci/archive/20220412/202204121953.zHZcX6EV-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

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

smatch warnings:
drivers/leds/leds-pca955x.c:455 pca955x_led_blink() error: uninitialized symbol 'ret'.

vim +/ret +455 drivers/leds/leds-pca955x.c

3b7b1899f6cc6d Eddie James      2022-04-11  389  
3b7b1899f6cc6d Eddie James      2022-04-11  390  static int pca955x_led_blink(struct led_classdev *led_cdev,
3b7b1899f6cc6d Eddie James      2022-04-11  391  			     unsigned long *delay_on, unsigned long *delay_off)
3b7b1899f6cc6d Eddie James      2022-04-11  392  {
3b7b1899f6cc6d Eddie James      2022-04-11  393  	struct pca955x_led *pca955x_led = led_to_pca955x(led_cdev);
3b7b1899f6cc6d Eddie James      2022-04-11  394  	struct pca955x *pca955x = pca955x_led->pca955x;
3b7b1899f6cc6d Eddie James      2022-04-11  395  	unsigned long p = *delay_on + *delay_off;
3b7b1899f6cc6d Eddie James      2022-04-11  396  	int ret;
3b7b1899f6cc6d Eddie James      2022-04-11  397  
3b7b1899f6cc6d Eddie James      2022-04-11  398  	mutex_lock(&pca955x->lock);
3b7b1899f6cc6d Eddie James      2022-04-11  399  
3b7b1899f6cc6d Eddie James      2022-04-11  400  	if (p) {
3b7b1899f6cc6d Eddie James      2022-04-11  401  		if (*delay_on != *delay_off) {
3b7b1899f6cc6d Eddie James      2022-04-11  402  			ret = -EINVAL;
3b7b1899f6cc6d Eddie James      2022-04-11  403  			goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  404  		}
3b7b1899f6cc6d Eddie James      2022-04-11  405  
3b7b1899f6cc6d Eddie James      2022-04-11  406  		if (p < pca955x_psc_to_period(pca955x, 0) ||
3b7b1899f6cc6d Eddie James      2022-04-11  407  		    p > pca955x_psc_to_period(pca955x, 0xff)) {
3b7b1899f6cc6d Eddie James      2022-04-11  408  			ret = -EINVAL;
3b7b1899f6cc6d Eddie James      2022-04-11  409  			goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  410  		}
3b7b1899f6cc6d Eddie James      2022-04-11  411  	} else {
3b7b1899f6cc6d Eddie James      2022-04-11  412  		p = pca955x->active_blink ? pca955x->blink_period :
3b7b1899f6cc6d Eddie James      2022-04-11  413  			PCA955X_BLINK_DEFAULT_MS;
3b7b1899f6cc6d Eddie James      2022-04-11  414  	}
3b7b1899f6cc6d Eddie James      2022-04-11  415  
3b7b1899f6cc6d Eddie James      2022-04-11  416  	if (!pca955x->active_blink ||
3b7b1899f6cc6d Eddie James      2022-04-11  417  	    pca955x->active_blink == BIT(pca955x_led->led_num) ||
3b7b1899f6cc6d Eddie James      2022-04-11  418  	    pca955x->blink_period == p) {
3b7b1899f6cc6d Eddie James      2022-04-11  419  		u8 psc = pca955x_period_to_psc(pca955x, p);
f46e9203d9a100 Nate Case        2008-07-16  420  
3b7b1899f6cc6d Eddie James      2022-04-11  421  		if (!test_and_set_bit(pca955x_led->led_num,
3b7b1899f6cc6d Eddie James      2022-04-11  422  				      &pca955x->active_blink)) {
3b7b1899f6cc6d Eddie James      2022-04-11  423  			u8 ls;
3b7b1899f6cc6d Eddie James      2022-04-11  424  			int reg = pca955x_led->led_num / 4;
3b7b1899f6cc6d Eddie James      2022-04-11  425  			int bit = pca955x_led->led_num % 4;
3b7b1899f6cc6d Eddie James      2022-04-11  426  
3b7b1899f6cc6d Eddie James      2022-04-11  427  			ret = pca955x_read_ls(pca955x, reg, &ls);
3b7b1899f6cc6d Eddie James      2022-04-11  428  			if (ret)
3b7b1899f6cc6d Eddie James      2022-04-11  429  				goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  430  
3b7b1899f6cc6d Eddie James      2022-04-11  431  			ls = pca955x_ledsel(ls, bit, PCA955X_LS_BLINK0);
9e58c2a7bb91f6 Eddie James      2022-04-11  432  			ret = pca955x_write_ls(pca955x, reg, ls);
3b7b1899f6cc6d Eddie James      2022-04-11  433  			if (ret)
3b7b1899f6cc6d Eddie James      2022-04-11  434  				goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  435  		}
3b7b1899f6cc6d Eddie James      2022-04-11  436  
3b7b1899f6cc6d Eddie James      2022-04-11  437  		if (pca955x->blink_period != p) {
3b7b1899f6cc6d Eddie James      2022-04-11  438  			pca955x->blink_period = p;
3b7b1899f6cc6d Eddie James      2022-04-11  439  			ret = pca955x_write_psc(pca955x, 0, psc);
3b7b1899f6cc6d Eddie James      2022-04-11  440  			if (ret)
3b7b1899f6cc6d Eddie James      2022-04-11  441  				goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  442  		}
3b7b1899f6cc6d Eddie James      2022-04-11  443  
3b7b1899f6cc6d Eddie James      2022-04-11  444  		p = pca955x_psc_to_period(pca955x, psc);
3b7b1899f6cc6d Eddie James      2022-04-11  445  		p /= 2;
3b7b1899f6cc6d Eddie James      2022-04-11  446  		*delay_on = p;
3b7b1899f6cc6d Eddie James      2022-04-11  447  		*delay_off = p;
3b7b1899f6cc6d Eddie James      2022-04-11  448  	} else {
3b7b1899f6cc6d Eddie James      2022-04-11  449  		ret = -EBUSY;
3b7b1899f6cc6d Eddie James      2022-04-11  450  	}
e7e11d8ba807d4 Alexander Stein  2012-05-29  451  
1591caf2d5eafd Cédric Le Goater 2017-08-30  452  out:
e7e11d8ba807d4 Alexander Stein  2012-05-29  453  	mutex_unlock(&pca955x->lock);
f46e9203d9a100 Nate Case        2008-07-16  454  
1591caf2d5eafd Cédric Le Goater 2017-08-30 @455  	return ret;
f46e9203d9a100 Nate Case        2008-07-16  456  }
f46e9203d9a100 Nate Case        2008-07-16  457  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

end of thread, other threads:[~2022-05-11 19:55 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 16:20 [PATCH v3 0/4] leds: pca955x: Add HW blink support Eddie James
2022-04-11 16:20 ` Eddie James
2022-04-11 16:20 ` [PATCH v3 1/4] leds: pca955x: Refactor with helper functions and renaming Eddie James
2022-04-11 16:20   ` Eddie James
2022-04-11 16:20 ` [PATCH v3 2/4] leds: pca955x: Use pointers to driver data rather than I2C client Eddie James
2022-04-11 16:20   ` Eddie James
2022-04-11 16:20 ` [PATCH v3 3/4] leds: pca955x: Optimize probe led selection Eddie James
2022-04-11 16:20   ` Eddie James
2022-05-04 17:24   ` Pavel Machek
2022-05-04 17:24     ` Pavel Machek
2022-05-11 19:43     ` Eddie James
2022-05-11 19:43       ` Eddie James
2022-04-11 16:20 ` [PATCH v3 4/4] leds: pca955x: Add HW blink support Eddie James
2022-04-11 16:20   ` Eddie James
2022-05-04 17:24   ` Pavel Machek
2022-05-04 17:24     ` Pavel Machek
2022-05-11 19:54     ` Eddie James
2022-05-11 19:54       ` Eddie James
2022-04-11 17:06 ` [PATCH v3 0/4] " Andy Shevchenko
2022-04-11 17:06   ` Andy Shevchenko
2022-04-12 11:22 [PATCH v3 4/4] " kernel test robot
2022-04-12 11:33 ` Dan Carpenter
2022-04-12 11:33 ` Dan Carpenter
2022-04-12 11:33 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.