diff mbox series

[4/4] backlight: ktz8866: add definitions to make it more readable

Message ID 20250407095119.588920-5-mitltlatltl@gmail.com
State New
Headers show
Series backlight: ktz8866: improve it and support slave | expand

Commit Message

Pengyu Luo April 7, 2025, 9:51 a.m. UTC
LSB, MSB and their handling are slightly confused, so improve it.

Signed-off-by: Pengyu Luo <mitltlatltl@gmail.com>
---
 drivers/video/backlight/ktz8866.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

kernel test robot April 8, 2025, 5:19 a.m. UTC | #1
Hi Pengyu,

kernel test robot noticed the following build errors:

[auto build test ERROR on lee-backlight/for-backlight-next]
[also build test ERROR on lee-leds/for-leds-next lee-backlight/for-backlight-fixes linus/master v6.15-rc1 next-20250407]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pengyu-Luo/dt-bindings-backlight-kinetic-ktz8866-add-ktz8866-slave-compatible/20250407-175635
base:   https://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git for-backlight-next
patch link:    https://lore.kernel.org/r/20250407095119.588920-5-mitltlatltl%40gmail.com
patch subject: [PATCH 4/4] backlight: ktz8866: add definitions to make it more readable
config: riscv-randconfig-002-20250408 (https://download.01.org/0day-ci/archive/20250408/202504081215.rL4DExNA-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 92c93f5286b9ff33f27ff694d2dc33da1c07afdd)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250408/202504081215.rL4DExNA-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504081215.rL4DExNA-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/video/backlight/ktz8866.c:77:32: error: incompatible pointer types passing 'unsigned int **' to parameter of type 'unsigned int *'; remove & [-Werror,-Wincompatible-pointer-types]
      77 |         regmap_read(ktz->regmap, reg, &val);
         |                                       ^~~~
   include/linux/regmap.h:1297:69: note: passing argument to parameter 'val' here
    1297 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
         |                                                                     ^
>> drivers/video/backlight/ktz8866.c:112:66: error: expected ')'
     112 |         ktz8866_write(ktz, BL_BRT_LSB, FIELD_GET(LOWER_BYTE, brightness);
         |                                                                         ^
   drivers/video/backlight/ktz8866.c:112:15: note: to match this '('
     112 |         ktz8866_write(ktz, BL_BRT_LSB, FIELD_GET(LOWER_BYTE, brightness);
         |                      ^
   drivers/video/backlight/ktz8866.c:113:67: error: expected ')'
     113 |         ktz8866_write(ktz, BL_BRT_MSB, FIELD_GET(HIGHER_BYTE, brightness);
         |                                                                          ^
   drivers/video/backlight/ktz8866.c:113:15: note: to match this '('
     113 |         ktz8866_write(ktz, BL_BRT_MSB, FIELD_GET(HIGHER_BYTE, brightness);
         |                      ^
   drivers/video/backlight/ktz8866.c:136:13: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
     136 |                 if (!(val && CURRENT_SINKS_MASK))
         |                           ^  ~~~~~~~~~~~~~~~~~~
   drivers/video/backlight/ktz8866.c:136:13: note: use '&' for a bitwise operation
     136 |                 if (!(val && CURRENT_SINKS_MASK))
         |                           ^~
         |                           &
   drivers/video/backlight/ktz8866.c:136:13: note: remove constant to silence this warning
     136 |                 if (!(val && CURRENT_SINKS_MASK))
         |                           ^~~~~~~~~~~~~~~~~~~~~
   1 warning and 3 errors generated.


vim +112 drivers/video/backlight/ktz8866.c

    97	
    98	static int ktz8866_backlight_update_status(struct backlight_device *backlight_dev)
    99	{
   100		struct ktz8866 *ktz = bl_get_data(backlight_dev);
   101		unsigned int brightness = backlight_get_brightness(backlight_dev);
   102	
   103		if (!ktz->led_on && brightness > 0) {
   104			ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, BL_EN_BIT);
   105			ktz->led_on = true;
   106		} else if (brightness == 0) {
   107			ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, 0);
   108			ktz->led_on = false;
   109		}
   110	
   111		/* Set brightness */
 > 112		ktz8866_write(ktz, BL_BRT_LSB, FIELD_GET(LOWER_BYTE, brightness);
   113		ktz8866_write(ktz, BL_BRT_MSB, FIELD_GET(HIGHER_BYTE, brightness);
   114	
   115		return 0;
   116	}
   117
diff mbox series

Patch

diff --git a/drivers/video/backlight/ktz8866.c b/drivers/video/backlight/ktz8866.c
index b67ca136d..5364ecfc0 100644
--- a/drivers/video/backlight/ktz8866.c
+++ b/drivers/video/backlight/ktz8866.c
@@ -24,7 +24,9 @@ 
 #define DEVICE_ID 0x01
 #define BL_CFG1 0x02
 #define BL_CFG2 0x03
+/* least significant byte */
 #define BL_BRT_LSB 0x04
+/* most significant byte */
 #define BL_BRT_MSB 0x05
 #define BL_EN 0x08
 #define LCD_BIAS_CFG1 0x09
@@ -47,6 +49,8 @@ 
 #define PWM_HYST 0x5
 
 #define CURRENT_SINKS_MASK GENMASK(5, 0)
+#define LOWER_BYTE GENMASK(2, 0)
+#define HIGHER_BYTE GENMASK(10, 3)
 
 struct ktz8866_slave {
 	struct i2c_client *client;
@@ -105,8 +109,8 @@  static int ktz8866_backlight_update_status(struct backlight_device *backlight_de
 	}
 
 	/* Set brightness */
-	ktz8866_write(ktz, BL_BRT_LSB, brightness & 0x7);
-	ktz8866_write(ktz, BL_BRT_MSB, (brightness >> 3) & 0xFF);
+	ktz8866_write(ktz, BL_BRT_LSB, FIELD_GET(LOWER_BYTE, brightness);
+	ktz8866_write(ktz, BL_BRT_MSB, FIELD_GET(HIGHER_BYTE, brightness);
 
 	return 0;
 }