Re: [PATCH 3/3] leds: add sgm3140 driver

From: Jacek Anaszewski
Date: Wed Mar 11 2020 - 17:09:33 EST


Dan,

On 3/11/20 2:02 PM, Dan Murphy wrote:
> Luca
>
> On 3/9/20 3:35 PM, Luca Weiss wrote:
>> Add a driver for the SGMICRO SGM3140 Buck/Boost Charge Pump LED driver.
>>
>> This device is controlled by two GPIO pins, one for enabling and the
>> second one for switching between torch and flash mode.
>
> How does one enable torch and one enable flash?
>
> Is the flash-gpio control this or does the enable-gpio enable the flash?
>
> The DT binding did not indicate what the GPIOs are really going to control.
>
>>
>> Signed-off-by: Luca Weiss <luca@xxxxxxxxx>
>> ---
>> Changes since RFC:
>> - address review comments from Jacek Anaszewski:
>> ÂÂ - implement strobe_get op
>> ÂÂ - implement timeout_set op
>> ÂÂ - init v4l2_sd_cfg variable
>> ÂÂ - remove init_data.devicename assignemnt
>> ÂÂ - use devm_ version of led_classdev_flash_register_ext
>> ÂÂ - release child_node in case of success
>>
>> Â drivers/leds/KconfigÂÂÂÂÂÂÂ |ÂÂ 9 ++
>> Â drivers/leds/MakefileÂÂÂÂÂÂ |ÂÂ 1 +
>> Â drivers/leds/leds-sgm3140.c | 260 ++++++++++++++++++++++++++++++++++++
>> Â 3 files changed, 270 insertions(+)
>> Â create mode 100644 drivers/leds/leds-sgm3140.c
>>
>> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
>> index 4b68520ac251..9206fc66799d 100644
>> --- a/drivers/leds/Kconfig
>> +++ b/drivers/leds/Kconfig
>> @@ -836,6 +836,15 @@ config LEDS_LM36274
>> ÂÂÂÂÂÂÂ Say Y to enable the LM36274 LED driver for TI LMU devices.
>> ÂÂÂÂÂÂÂ This supports the LED device LM36274.
>> Â +config LEDS_SGM3140
>> +ÂÂÂ tristate "LED support for the SGM3140"
>> +ÂÂÂ depends on LEDS_CLASS_FLASH
>> +ÂÂÂ depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
>
> What is the purpose of this? Enable if V4L2_FLASH_LED_CLASS is enabled
> or if it is not enabled?
>
> Seems to be a do nothing dependency in the Kconfig

See the patch: 58d1809b9d61 ("leds: fix aat1290 build errors")

and Documentation/kbuild/kconfig-language.rst,
chapter "Menu dependencies".

According to that ('!' <expr>) boils down to (2-/expr/),
where

"An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
respectively for calculations)".

In a result:
- in case V4L2_FLASH_LED_CLASS=n it evaluates to 2,
- in case V4L2_FLASH_LED_CLASS=m it evaluates to 1,
- in case V4L2_FLASH_LED_CLASS=y it evaluates to 0

And (<expr> '||' <expr>) returns the result of max(/expr/, /expr/).

It allows to restrict LEDS_SGM3140 to m if CONFIG_V4L2_FLASH_LED_CLASS=m
(we will have max(1,1) then)
and ignore the dependency if CONFIG_V4L2_FLASH_LED_CLASS=n
(max(0,2)).

--
Best regards,
Jacek Anaszewski