backlight: ktz8866: improve it and support slave
Subsystems (5)
cover backlight: ktz8866: improve it and support slave
Sending this patchset to support coming devices which are using dual ktz8866, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, and two devices share the same resources(pinctrl) which is required for every single node under recent dt-bindings, so adding new support. and improve original driver. Details in every commit log.
Pengyu Luo (4):
dt-bindings: backlight: kinetic,ktz8866: add ktz8866 slave compatible
backlight: ktz8866: add slave handler
backlight: ktz8866: improve current sinks setting
backlight: ktz8866: add definitions to make it more readable
.../leds/backlight/kinetic,ktz8866.yaml | 29 +++++- drivers/video/backlight/ktz8866.c | 99 ++++++++++++++++--- 2 files changed, 108 insertions(+), 20 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/4 dt-bindings: backlight: kinetic,ktz8866: add ktz8866 slave compatible
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, add the binding for slave case.
--- .../leds/backlight/kinetic,ktz8866.yaml | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +24 -5
@@ -19,7 +19,9 @@ allOf: properties: compatible: - const: kinetic,ktz8866 + enum: + - kinetic,ktz8866 + - kinetic,ktz8866-slave reg: maxItems: 1
@@ -58,9 +60,16 @@ properties: required: - compatible - reg - - vddpos-supply - - vddneg-supply - - enable-gpios + +if: + properties: + compatible: + const: kinetic,ktz8866 +then: + required: + - vddpos-supply + - vddneg-supply + - enable-gpios unevaluatedProperties: false
@@ -68,7 +77,7 @@ examples: - | #include <dt-bindings/gpio/gpio.h> - i2c { + i2c0 { #address-cells = <1>; #size-cells = <0>;
@@ -84,3 +93,13 @@ examples: kinetic,enable-lcd-bias; }; }; + + i2c1 { + #address-cells = <1>; + #size-cells = <0>; + + backlight@11 { + compatible = "kinetic,ktz8866-slave"; + reg = <0x11>; + }; + };
Signature · 1 line
2.49.0
Re: [PATCH 1/4] dt-bindings: backlight: kinetic,ktz8866: add ktz8866 slave compatible
Quoted 2 lines · Pengyu Luo
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, add the
Just one space after 'and'.
Quoted 12 lines
binding for slave case.
Signed-off-by Pengyu Luo <[email protected]>--- .../leds/backlight/kinetic,ktz8866.yaml | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-)Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +0
-0
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml allOf: · line 24
Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +3
-1@@ -19,7 +19,9 @@ allOf: properties: compatible: - const: kinetic,ktz8866 + enum: + - kinetic,ktz8866 + - kinetic,ktz8866-slave
Does not look right. That's the same device. Same devices have same compatible.
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +0
-3reg: maxItems: 1@@ -58,9 +60,16 @@ properties: required: - compatible - reg - - vddpos-supply - - vddneg-supply - - enable-gpios
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml properties: · line 72
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +10
-0+ +if: + properties: + compatible: + const: kinetic,ktz8866 +then: + required: + - vddpos-supply + - vddneg-supply + - enable-gpios
I don't understand why other device does not need power.
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml examples: · line 80
Quoted 9 lines
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +1
-1unevaluatedProperties: false@@ -68,7 +77,7 @@ examples: - | #include <dt-bindings/gpio/gpio.h> - i2c { + i2c0 {
No, don't change.
Quoted 5 lines
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +0
-0#address-cells = <1>; #size-cells = <0>;@@ -84,3 +93,13 @@ examples: kinetic,enable-lcd-bias;
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml examples: · line 103
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/kinetic,ktz8866.yaml +8
-0}; }; + + i2c1 { + #address-cells = <1>; + #size-cells = <0>; + + backlight@11 { + compatible = "kinetic,ktz8866-slave"; + reg = <0x11>;
No real differences here, so drop the example. Anyway, new examples would start from - | (see other bindings).
Best regards,
Krzysztof
PATCH 2/4 backlight: ktz8866: add slave handler
In reply to Pengyu LuoKinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, so adding the slave handler to support it.
Note that, none of the devices supported by upstream require this, the devices using this is porting.
--- drivers/video/backlight/ktz8866.c | 68 +++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 9 deletions(-)
drivers/video/backlight/ktz8866.c +59 -9
@@ -3,6 +3,9 @@* Backlight driver for the Kinetic KTZ8866 * * Copyright (C) 2022, 2023 Jianhua Lu <[email protected]> +* +* Apr 2025 - Pengyu Luo <[email protected]> +* Added handling for dual KTZ8866(master and slave) */ #include <linux/backlight.h>
@@ -43,11 +46,17 @@#define LCD_BIAS_EN 0x9F#define PWM_HYST 0x5 +struct ktz8866_slave { +struct i2c_client *client; +struct regmap *regmap; +}; +struct ktz8866 {struct i2c_client *client;struct regmap *regmap; -bool led_on;struct gpio_desc *enable_gpio; +struct ktz8866_slave *slave; +bool led_on; };static const struct regmap_config ktz8866_regmap_config = {
@@ -56,16 +65,22 @@ static const struct regmap_config ktz8866_regmap_config = { .max_register = REG_MAX, }; -static int ktz8866_write (struct ktz8866 *ktz,unsigned int reg, -unsigned int val) +static void ktz8866_write (struct ktz8866 *ktz,unsigned int reg, +unsigned int val) { -return regmap_write (ktz->regmap, reg, val); +regmap_write (ktz->regmap, reg, val); + +if (ktz->slave) +regmap_write (ktz->slave->regmap, reg, val); } -static int ktz8866_update_bits (struct ktz8866 *ktz,unsigned int reg, -unsigned int mask,unsigned int val) +static void ktz8866_update_bits (struct ktz8866 *ktz,unsigned int reg, +unsigned int mask,unsigned int val) { -return regmap_update_bits (ktz->regmap, reg, mask, val); +regmap_update_bits (ktz->regmap, reg, mask, val); + +if (ktz->slave) +regmap_update_bits (ktz->slave->regmap, reg, mask, val); }static int ktz8866_backlight_update_status (struct backlight_device *backlight_dev)
@@ -124,10 +139,41 @@ static void ktz8866_init(struct ktz8866 *ktz)ktz8866_write (ktz,LCD_BIAS_CFG1 ,LCD_BIAS_EN ); } +static int ktz8866_slave_register (struct ktz8866 *ktz) +{ +struct device *dev = &ktz->client->dev; +struct ktz8866_slave *slave; +struct i2c_client *client; +struct device_node *np; + + np =of_find_compatible_node (NULL ,NULL ,"kinetic,ktz8866-slave" ); +if (!np) +return 0 ; + + client =of_find_i2c_device_by_node (np); +of_node_put (np); +if (!client) +return 0 ; + + slave =devm_kzalloc (dev,sizeof (*slave),GFP_KERNEL ); +if (!slave) +return -ENOMEM ; + + slave->client = client; + slave->regmap =devm_regmap_init_i2c (client, &ktz8866_regmap_config); +if (IS_ERR (slave->regmap)) +return dev_err_probe (&client->dev,PTR_ERR (slave->regmap), +"failed to init regmap\n" ); + + ktz->slave = slave; + +return 0 ; +} +static int ktz8866_probe (struct i2c_client *client) {struct backlight_device *backlight_dev; -struct backlight_properties props; +struct backlight_properties props = {};struct ktz8866 *ktz;int ret =0 ;
@@ -151,7 +197,6 @@ static int ktz8866_probe(struct i2c_client *client)if (IS_ERR (ktz->enable_gpio))return PTR_ERR (ktz->enable_gpio); -memset (&props,0 ,sizeof (props)); props.type =BACKLIGHT_RAW ; props.max_brightness =MAX_BRIGHTNESS ; props.brightness =DEFAULT_BRIGHTNESS ;
@@ -163,6 +208,11 @@ static int ktz8866_probe(struct i2c_client *client)return dev_err_probe (&client->dev,PTR_ERR (backlight_dev),"failed to register backlight device\n" ); + ret =ktz8866_slave_register (ktz); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to register slave\n" ); +ktz8866_init (ktz);i2c_set_clientdata (client, backlight_dev);
Signature · 1 line
2.49.0
Re: [PATCH 2/4] backlight: ktz8866: add slave handler
Quoted 82 lines · Pengyu Luo
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, so adding the slave handler to support it.
Note that, none of the devices supported by upstream require this, the devices using this is porting.
Signed-off-by Pengyu Luo <[email protected]>--- drivers/video/backlight/ktz8866.c | 68 +++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 9 deletions(-)drivers/video/backlight/ktz8866.c +24
-7@@ -3,6 +3,9 @@* Backlight driver for the Kinetic KTZ8866 * * Copyright (C) 2022, 2023 Jianhua Lu <[email protected]> +* +* Apr 2025 - Pengyu Luo <[email protected]> +* Added handling for dual KTZ8866(master and slave) */ #include <linux/backlight.h> @@ -43,11 +46,17 @@#define LCD_BIAS_EN 0x9F#define PWM_HYST 0x5 +struct ktz8866_slave { +struct i2c_client *client; +struct regmap *regmap; +}; +struct ktz8866 {struct i2c_client *client;struct regmap *regmap; -bool led_on;struct gpio_desc *enable_gpio; +struct ktz8866_slave *slave; +bool led_on; };static const struct regmap_config ktz8866_regmap_config = {@@ -56,16 +65,22 @@ static const struct regmap_config ktz8866_regmap_config = { .max_register = REG_MAX, }; -static int ktz8866_write (struct ktz8866 *ktz,unsigned int reg, -unsigned int val) +static void ktz8866_write (struct ktz8866 *ktz,unsigned int reg, +unsigned int val) { -return regmap_write (ktz->regmap, reg, val); +regmap_write (ktz->regmap, reg, val); + +if (ktz->slave) +regmap_write (ktz->slave->regmap, reg, val); } -static int ktz8866_update_bits (struct ktz8866 *ktz,unsigned int reg, -unsigned int mask,unsigned int val) +static void ktz8866_update_bits (struct ktz8866 *ktz,unsigned int reg, +unsigned int mask,unsigned int val) { -return regmap_update_bits (ktz->regmap, reg, mask, val); +regmap_update_bits (ktz->regmap, reg, mask, val); + +if (ktz->slave) +regmap_update_bits (ktz->slave->regmap, reg, mask, val); }static int ktz8866_backlight_update_status (struct backlight_device *backlight_dev)@@ -124,10 +139,41 @@ static void ktz8866_init(struct ktz8866 *ktz)ktz8866_write (ktz,LCD_BIAS_CFG1 ,LCD_BIAS_EN ); } +static int ktz8866_slave_register (struct ktz8866 *ktz) +{
drivers/video/backlight/ktz8866.c static void ktz8866_init(struct ktz8866 *ktz) · line 153
Quoted 10 lines
drivers/video/backlight/ktz8866.c +10
-0+struct device *dev = &ktz->client->dev; +struct ktz8866_slave *slave; +struct i2c_client *client; +struct device_node *np; + + np =of_find_compatible_node (NULL ,NULL ,"kinetic,ktz8866-slave" ); +if (!np) +return 0 ; + + client =of_find_i2c_device_by_node (np);
I wrote on IRC - phandle to express the relationship between hardware - and I do not see it implemented.
If you have devices depending on each other, you need to express it - for links, for resource dependencies etc. phandle is for that usually. Or OF graph. Or parent-child relationship.
You did not provide any description of the hardware in the binding, so I really do not have any idea what is this setup thus how to represent it. Use hardware terms, diagrams etc to explain the hardware in the bindings commit. What are the addresses? Are there any shared resources? What buses are devices sitting on, etc.
Best regards,
Krzysztof
Re: [PATCH 2/4] backlight: ktz8866: add slave handler
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Pengyu Luo
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, so adding the slave handler to support it.
[...]
Quoted 8 lines
I wrote on IRC - phandle to express the relationship between hardware - and I do not see it implemented.
If you have devices depending on each other, you need to express it - for links, for resource dependencies etc. phandle is for that usually. Or OF graph. Or parent-child relationship.
I got you now, as a non-native speaker, I often misunderstood the first time, you expected that accessing node phandle in relationship or graph way, I did only access node phandle regardless of relationship or graph description, I only implied it in compatible string, but there would be a better way.
Quoted 5 lines
You did not provide any description of the hardware in the binding, so I really do not have any idea what is this setup thus how to represent it. Use hardware terms, diagrams etc to explain the hardware in the bindings commit. What are the addresses? Are there any shared resources? What buses are devices sitting on, etc.
Agree.
Best wishes,
Pengyu
Re: [PATCH 2/4] backlight: ktz8866: add slave handler
In reply to Krzysztof KozlowskiQuoted 7 lines · Daniel Thompson
Quoted 5 lines · Pengyu Luo
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, so adding the slave handler to support it.
Quoted 6 lines
Is there anything unique about KTZ8866 that allows it to be used like this? I think it would be better to add support for secondary backlight controllers into the backlight framework, rather than having to implement driver specific hacks for every backlight controller that appears in a primary/secondary configuration.
According to my understanding, if I add the new api to backlight framework, with a minimal modification, then I either do A or do B(I doubt it is my fixed mindset)
A:
Tied two devices, registering the primary and the secondary device during one probe, to do that, I access another KTZ8866 when probing. Those hack is still here, that doesn't seem to help.
B:
Uncoupled, probing separately, the later one is registered as the secondary one. Brightness control is a little uncoupled, there are two sysfs, I doubt if userspace programs will write brightness to two devices. Then we need synchronization, write primary => write primary and write secondary, viceversa.
Quoted 4 lines
Also, the kernel seeks to avoid adding new instances of master/slave terminology. See the coding style doc for suggested alternatives:
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
Agree.
Best wishes,
Pengyu
Re: [PATCH 2/4] backlight: ktz8866: add slave handler
In reply to Pengyu LuoQuoted 5 lines · Pengyu Luo
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, so adding the slave handler to support it.
Is there anything unique about KTZ8866 that allows it to be used like this? I think it would be better to add support for secondary backlight controllers into the backlight framework, rather than having to implement driver specific hacks for every backlight controller that appears in a primary/secondary configuration.
Also, the kernel seeks to avoid adding new instances of master/slave terminology. See the coding style doc for suggested alternatives:
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
Daniel.
Re: [PATCH 2/4] backlight: ktz8866: add slave handler
Quoted 7 lines · Daniel Thompson
Quoted 5 lines · Pengyu Luo
Kinetic ktz8866, found in many android devices, nowadays, some oem use dual ktz8866 to support a larger panel and higher brightness, original driver would only handle half backlight region on these devices, registering it twice is unreasonable, so adding the slave handler to support it.
Quoted 6 lines
Is there anything unique about KTZ8866 that allows it to be used like this? I think it would be better to add support for secondary backlight controllers into the backlight framework, rather than having to implement driver specific hacks for every backlight controller that appears in a primary/secondary configuration.
According to my understanding, if I add the new api to backlight framework, with a minimal modification, then I either do A or do B(I doubt it is my fixed mindset)
A:
Tied two devices, registering the primary and the secondary device during one probe, to do that, I access another KTZ8866 when probing. Those hack is still here, that doesn't seem to help.
B:
Uncoupled, probing separately, the later one is registered as the secondary one. Brightness control is a little uncoupled, there are two sysfs, I doubt if userspace programs will write brightness to two devices. Then we need synchronization, write primary => write primary and write secondary, viceversa.
Quoted 4 lines
Also, the kernel seeks to avoid adding new instances of master/slave terminology. See the coding style doc for suggested alternatives:
https://www.kernel.org/doc/html/latest/process/coding-style.html#naming
Agree.
Best wishes,
Pengyu
PATCH 3/4 backlight: ktz8866: improve current sinks setting
In reply to Pengyu LuoI polled all registers when the module was loading, found that current sinks have already been configured. Bootloader would set when booting. So checking it before setting the all channels.
--- drivers/video/backlight/ktz8866.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
drivers/video/backlight/ktz8866.c +19 -4
@@ -46,6 +46,8 @@#define LCD_BIAS_EN 0x9F#define PWM_HYST 0x5 +#define CURRENT_SINKS_MASK GENMASK(5, 0) +struct ktz8866_slave {struct i2c_client *client;struct regmap *regmap;
@@ -65,6 +67,12 @@ static const struct regmap_config ktz8866_regmap_config = { .max_register = REG_MAX, }; +static inline void ktz8866_read (struct ktz8866 *ktz,unsigned int reg, +unsigned int *val) +{ +regmap_read (ktz->regmap, reg, &val); +} +static void ktz8866_write (struct ktz8866 *ktz,unsigned int reg,unsigned int val) {
@@ -112,11 +120,18 @@ static void ktz8866_init(struct ktz8866 *ktz) {unsigned int val =0 ; -if (!of_property_read_u32 (ktz->client->dev.of_node,"current-num-sinks" , &val)) +if (!of_property_read_u32 (ktz->client->dev.of_node,"current-num-sinks" , &val)) {ktz8866_write (ktz,BL_EN ,BIT (val) -1 ); -else -/* Enable all 6 current sinks if the number of current sinks isn't specified. */ -ktz8866_write (ktz,BL_EN ,BIT (6 ) -1 ); + }else { +/* +* Enable all 6 current sinks if the number of current +* sinks isn't specified and the bootloader didn't set +* the value. +*/ +ktz8866_read (ktz,BL_EN , &val); +if (!(val &&CURRENT_SINKS_MASK )) +ktz8866_write (ktz,BL_EN ,CURRENT_SINKS_MASK ); + }if (!of_property_read_u32 (ktz->client->dev.of_node,"kinetic,current-ramp-delay-ms" , &val)) {if (val <=128 )
Signature · 1 line
2.49.0
Re: [PATCH 3/4] backlight: ktz8866: improve current sinks setting
Quoted 3 lines · Pengyu Luo
I polled all registers when the module was loading, found that current sinks have already been configured. Bootloader would set when booting. So checking it before setting the all channels.
Can you rephrase this so the problem and solution are more clearly expressed. Perhaps template Ingo suggests here would be good:
https://www.spinics.net/lists/kernel/msg1633438.html
Quoted 10 lines
Signed-off-by Pengyu Luo <[email protected]>--- drivers/video/backlight/ktz8866.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)drivers/video/backlight/ktz8866.c +0
-0
drivers/video/backlight/ktz8866.c line 50
Quoted 5 lines
drivers/video/backlight/ktz8866.c +2
-0@@ -46,6 +46,8 @@#define LCD_BIAS_EN 0x9F#define PWM_HYST 0x5 +#define CURRENT_SINKS_MASK GENMASK(5, 0) +
Call this BL_EN_CURRENT_SINKS_MASK and keep it next to the register it applies to.
Quoted 11 lines
drivers/video/backlight/ktz8866.c +1
-2struct ktz8866_slave {struct i2c_client *client;struct regmap *regmap;@@ -112,11 +120,18 @@ static void ktz8866_init(struct ktz8866 *ktz) {unsigned int val =0 ; -if (!of_property_read_u32 (ktz->client->dev.of_node,"current-num-sinks" , &val)) +if (!of_property_read_u32 (ktz->client->dev.of_node,"current-num-sinks" , &val)) {ktz8866_write (ktz,BL_EN ,BIT (val) -1 ); -else
drivers/video/backlight/ktz8866.c static void ktz8866_init(struct ktz8866 *ktz) · line 132
Quoted 10 lines
drivers/video/backlight/ktz8866.c +8
-2-/* Enable all 6 current sinks if the number of current sinks isn't specified. */ -ktz8866_write (ktz,BL_EN ,BIT (6 ) -1 ); + }else { +/* +* Enable all 6 current sinks if the number of current +* sinks isn't specified and the bootloader didn't set +* the value. +*/ +ktz8866_read (ktz,BL_EN , &val); +if (!(val &&CURRENT_SINKS_MASK ))
This is the wrong form of AND.
drivers/video/backlight/ktz8866.c static void ktz8866_init(struct ktz8866 *ktz) · line 134
Quoted 2 lines
drivers/video/backlight/ktz8866.c +2
-0+ktz8866_write (ktz,BL_EN ,CURRENT_SINKS_MASK ); + }
Daniel.
kernel test robot
build botRe: [PATCH 3/4] backlight: ktz8866: improve current sinks setting
In reply to Pengyu Luokernel test robot noticed the following build errors:
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-4-mitltlatltl%40gmail.com patch subject: [PATCH 3/4] backlight: ktz8866: improve current sinks setting config: riscv-randconfig-002-20250408 (https://download.01.org/0day-ci/archive/20250408/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
>> drivers/video/backlight/ktz8866.c:73:32: error: incompatible pointer types passing 'unsigned int **' to parameter of type 'unsigned int *'; remove & [-Werror,-Wincompatible-pointer-types]
73 | 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:132:13: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
132 | if (!(val && CURRENT_SINKS_MASK))
| ^ ~~~~~~~~~~~~~~~~~~
drivers/video/backlight/ktz8866.c:132:13: note: use '&' for a bitwise operation
132 | if (!(val && CURRENT_SINKS_MASK))
| ^~
| &
drivers/video/backlight/ktz8866.c:132:13: note: remove constant to silence this warning
132 | if (!(val && CURRENT_SINKS_MASK))
| ^~~~~~~~~~~~~~~~~~~~~1 warning and 1 error generated.
vim +73 drivers/video/backlight/ktz8866.c
69
70 static inline void ktz8866_read(struct ktz8866 *ktz, unsigned int reg,
71 unsigned int *val)
72 {
> 73 regmap_read(ktz->regmap, reg, &val);
74 }
75
76 static void ktz8866_write(struct ktz8866 *ktz, unsigned int reg,
77 unsigned int val)
78 {
79 regmap_write(ktz->regmap, reg, val);
80
81 if (ktz->slave)
82 regmap_write(ktz->slave->regmap, reg, val);
83 }
84
85 static void ktz8866_update_bits(struct ktz8866 *ktz, unsigned int reg,
86 unsigned int mask, unsigned int val)
87 {
88 regmap_update_bits(ktz->regmap, reg, mask, val);
89
90 if (ktz->slave)
91 regmap_update_bits(ktz->slave->regmap, reg, mask, val);
92 }
93
94 static int ktz8866_backlight_update_status(struct backlight_device *backlight_dev)
95 {
96 struct ktz8866 *ktz = bl_get_data(backlight_dev);
97 unsigned int brightness = backlight_get_brightness(backlight_dev);
98
99 if (!ktz->led_on && brightness > 0) {
100 ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, BL_EN_BIT);
101 ktz->led_on = true;
102 } else if (brightness == 0) {
103 ktz8866_update_bits(ktz, BL_EN, BL_EN_BIT, 0);
104 ktz->led_on = false;
105 }
106
107 /* Set brightness */
108 ktz8866_write(ktz, BL_BRT_LSB, brightness & 0x7);
109 ktz8866_write(ktz, BL_BRT_MSB, (brightness >> 3) & 0xFF);
110
111 return 0;
112 }
113
114 static const struct backlight_ops ktz8866_backlight_ops = {
115 .options = BL_CORE_SUSPENDRESUME,
116 .update_status = ktz8866_backlight_update_status,
117 };
118
119 static void ktz8866_init(struct ktz8866 *ktz)
120 {
121 unsigned int val = 0;
122
123 if (!of_property_read_u32(ktz->client->dev.of_node, "current-num-sinks", &val)) {
124 ktz8866_write(ktz, BL_EN, BIT(val) - 1);
125 } else {
126 /*
127 * Enable all 6 current sinks if the number of current
128 * sinks isn't specified and the bootloader didn't set
129 * the value.
130 */
131 ktz8866_read(ktz, BL_EN, &val);
> 132 if (!(val && CURRENT_SINKS_MASK)) 133 ktz8866_write(ktz, BL_EN, CURRENT_SINKS_MASK);
134 }
135
136 if (!of_property_read_u32(ktz->client->dev.of_node, "kinetic,current-ramp-delay-ms", &val)) {
137 if (val <= 128)
138 ktz8866_write(ktz, BL_CFG2, BIT(7) | (ilog2(val) << 3) | PWM_HYST);
139 else
140 ktz8866_write(ktz, BL_CFG2, BIT(7) | ((5 + val / 64) << 3) | PWM_HYST);
141 }
142
143 if (!of_property_read_u32(ktz->client->dev.of_node, "kinetic,led-enable-ramp-delay-ms", &val)) {
144 if (val == 0)
145 ktz8866_write(ktz, BL_DIMMING, 0);
146 else {
147 unsigned int ramp_off_time = ilog2(val) + 1;
148 unsigned int ramp_on_time = ramp_off_time << 4;
149 ktz8866_write(ktz, BL_DIMMING, ramp_on_time | ramp_off_time);
150 }
151 }
152
153 if (of_property_read_bool(ktz->client->dev.of_node, "kinetic,enable-lcd-bias"))
154 ktz8866_write(ktz, LCD_BIAS_CFG1, LCD_BIAS_EN);
155 }
156
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 3/4] backlight: ktz8866: improve current sinks setting
In reply to Pengyu Luokernel test robot noticed the following build errors:
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-4-mitltlatltl%40gmail.com patch subject: [PATCH 3/4] backlight: ktz8866: improve current sinks setting config: sparc64-randconfig-002-20250408 (https://download.01.org/0day-ci/archive/20250408/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250408/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/video/backlight/ktz8866.c: In function 'ktz8866_read':
>> drivers/video/backlight/ktz8866.c:73:39: error: passing argument 3 of 'regmap_read' from incompatible pointer type [-Wincompatible-pointer-types]
73 | regmap_read(ktz->regmap, reg, &val);
| ^~~~
| |
| unsigned int **
In file included from drivers/video/backlight/ktz8866.c:17:
include/linux/regmap.h:1297:69: note: expected 'unsigned int *' but argument is of type 'unsigned int **'
1297 | int regmap_read(struct regmap *map, unsigned int reg, unsigned int *val);
| ~~~~~~~~~~~~~~^~~vim +/regmap_read +73 drivers/video/backlight/ktz8866.c
69
70 static inline void ktz8866_read(struct ktz8866 *ktz, unsigned int reg,
71 unsigned int *val)
72 {
> 73 regmap_read(ktz->regmap, reg, &val);
74 }
75 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 4/4 backlight: ktz8866: add definitions to make it more readable
In reply to Pengyu LuoLSB, MSB and their handling are slightly confused, so improve it.
--- drivers/video/backlight/ktz8866.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/video/backlight/ktz8866.c +6 -2
@@ -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 ; }
Signature · 1 line
2.49.0
Re: [PATCH 4/4] backlight: ktz8866: add definitions to make it more readable
Quoted 12 lines · Pengyu Luo
LSB, MSB and their handling are slightly confused, so improve it.
Signed-off-by Pengyu Luo <[email protected]>--- drivers/video/backlight/ktz8866.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/video/backlight/ktz8866.c +0
-0
drivers/video/backlight/ktz8866.c line 29
Quoted 6 lines
drivers/video/backlight/ktz8866.c +2
-0@@ -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 */
I'm not convinced these comments are necessary.
drivers/video/backlight/ktz8866.c line 52
Quoted 8 lines
drivers/video/backlight/ktz8866.c +1
-0#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)
I like using masks and FIELD_GET() but this is not a byte. These are the least significant bits.
Daniel.
kernel test robot
build botRe: [PATCH 4/4] backlight: ktz8866: add definitions to make it more readable
In reply to Pengyu Luokernel test robot noticed the following build errors:
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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
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
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki