diff mbox series

backlight: lp855x: Switch to atomic PWM API

Message ID YXQStu5yv4bwj2Tn@fedora (mailing list archive)
State New, archived
Headers show
Series backlight: lp855x: Switch to atomic PWM API | expand

Commit Message

Maíra Canal Oct. 23, 2021, 1:48 p.m. UTC
Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
replace it for the atomic PWM API.

Signed-off-by: Maíra Canal <maira.canal@usp.br>
---
 drivers/video/backlight/lp855x_bl.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

Comments

kernel test robot Oct. 26, 2021, 9:33 p.m. UTC | #1
Hi "Maíra,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on lee-backlight/for-backlight-next]
[also build test ERROR on v5.15-rc7 next-20211026]
[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/0day-ci/linux/commits/Ma-ra-Canal/backlight-lp855x-Switch-to-atomic-PWM-API/20211024-103835
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git for-backlight-next
config: riscv-buildonly-randconfig-r005-20211026 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project e5fb79b31424267704e9d2d9674089fd7316453e)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/f79ab2c306d1c5d666df34f3062f9f1a0b8e4448
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Ma-ra-Canal/backlight-lp855x-Switch-to-atomic-PWM-API/20211024-103835
        git checkout f79ab2c306d1c5d666df34f3062f9f1a0b8e4448
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=riscv 

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

All errors (new ones prefixed by >>):

   In file included from drivers/video/backlight/lp855x_bl.c:10:
   In file included from include/linux/i2c.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:464:31: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:477:61: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/video/backlight/lp855x_bl.c:10:
   In file included from include/linux/i2c.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:490:61: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/video/backlight/lp855x_bl.c:10:
   In file included from include/linux/i2c.h:18:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:9:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:136:
   include/asm-generic/io.h:501:33: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:511:59: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:521:59: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:1024:55: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]
           return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
                                                     ~~~~~~~~~~ ^
>> drivers/video/backlight/lp855x_bl.c:242:6: error: variable 'pwm' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
           if (!lp->pwm) {
               ^~~~~~~~
   drivers/video/backlight/lp855x_bl.c:260:18: note: uninitialized use occurs here
           pwm_apply_state(pwm, &state);
                           ^~~
   drivers/video/backlight/lp855x_bl.c:242:2: note: remove the 'if' if its condition is always true
           if (!lp->pwm) {
           ^~~~~~~~~~~~~~
   drivers/video/backlight/lp855x_bl.c:238:24: note: initialize the variable 'pwm' to silence this warning
           struct pwm_device *pwm;
                                 ^
                                  = NULL
   8 errors generated.


vim +242 drivers/video/backlight/lp855x_bl.c

7be865ab8634d4e Kim, Milo   2012-03-23  233  
8cc9764c9c7d01a Kim, Milo   2012-12-17  234  static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
8cc9764c9c7d01a Kim, Milo   2012-12-17  235  {
8cc9764c9c7d01a Kim, Milo   2012-12-17  236  	unsigned int period = lp->pdata->period_ns;
8cc9764c9c7d01a Kim, Milo   2012-12-17  237  	unsigned int duty = br * period / max_br;
8cc9764c9c7d01a Kim, Milo   2012-12-17  238  	struct pwm_device *pwm;
f79ab2c306d1c5d Maíra Canal 2021-10-23  239  	struct pwm_state state;
8cc9764c9c7d01a Kim, Milo   2012-12-17  240  
8cc9764c9c7d01a Kim, Milo   2012-12-17  241  	/* request pwm device with the consumer name */
8cc9764c9c7d01a Kim, Milo   2012-12-17 @242  	if (!lp->pwm) {
8cc9764c9c7d01a Kim, Milo   2012-12-17  243  		pwm = devm_pwm_get(lp->dev, lp->chipname);
8cc9764c9c7d01a Kim, Milo   2012-12-17  244  		if (IS_ERR(pwm))
8cc9764c9c7d01a Kim, Milo   2012-12-17  245  			return;
8cc9764c9c7d01a Kim, Milo   2012-12-17  246  
8cc9764c9c7d01a Kim, Milo   2012-12-17  247  		lp->pwm = pwm;
8cc9764c9c7d01a Kim, Milo   2012-12-17  248  	}
8cc9764c9c7d01a Kim, Milo   2012-12-17  249  
f79ab2c306d1c5d Maíra Canal 2021-10-23  250  	pwm_init_state(pwm, &state);
f79ab2c306d1c5d Maíra Canal 2021-10-23  251  
f79ab2c306d1c5d Maíra Canal 2021-10-23  252  	state.duty_cycle = duty;
f79ab2c306d1c5d Maíra Canal 2021-10-23  253  	state.period = period;
f79ab2c306d1c5d Maíra Canal 2021-10-23  254  
8cc9764c9c7d01a Kim, Milo   2012-12-17  255  	if (duty)
f79ab2c306d1c5d Maíra Canal 2021-10-23  256  		state.enabled = true;
8cc9764c9c7d01a Kim, Milo   2012-12-17  257  	else
f79ab2c306d1c5d Maíra Canal 2021-10-23  258  		state.enabled = false;
f79ab2c306d1c5d Maíra Canal 2021-10-23  259  
f79ab2c306d1c5d Maíra Canal 2021-10-23  260  	pwm_apply_state(pwm, &state);
8cc9764c9c7d01a Kim, Milo   2012-12-17  261  }
8cc9764c9c7d01a Kim, Milo   2012-12-17  262  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index e94932c69f54..dd63141a0d26 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -236,6 +236,7 @@  static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
 	unsigned int period = lp->pdata->period_ns;
 	unsigned int duty = br * period / max_br;
 	struct pwm_device *pwm;
+	struct pwm_state state;
 
 	/* request pwm device with the consumer name */
 	if (!lp->pwm) {
@@ -244,19 +245,19 @@  static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
 			return;
 
 		lp->pwm = pwm;
-
-		/*
-		 * FIXME: pwm_apply_args() should be removed when switching to
-		 * the atomic PWM API.
-		 */
-		pwm_apply_args(pwm);
 	}
 
-	pwm_config(lp->pwm, duty, period);
+	pwm_init_state(pwm, &state);
+
+	state.duty_cycle = duty;
+	state.period = period;
+
 	if (duty)
-		pwm_enable(lp->pwm);
+		state.enabled = true;
 	else
-		pwm_disable(lp->pwm);
+		state.enabled = false;
+
+	pwm_apply_state(pwm, &state);
 }
 
 static int lp855x_bl_update_status(struct backlight_device *bl)