Re: [PATCH v2 21/24] platform/x86: ideapad-laptop: add keyboard backlight control support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 13, 2021 at 8:25 PM Barnabás Pőcze <pobrn@xxxxxxxxxxxxxx> wrote:
>
> On certain models it is possible to control/query the keyboard backlight
> via the SALS/HALS ACPI methods. Add support for that, and register an LED
> class device to expose this functionality.
> Tested on: Lenovo YOGA 520-14IKB 80X8

...

> +       struct {
> +               bool initialized;
> +               struct led_classdev led;
> +               unsigned int last_brightness;
> +       } kbd_bl;

Data structure without sense.

...

> +static int ideapad_kbd_bl_brightness_get(struct ideapad_private *priv)
> +{
> +       unsigned long hals;
> +       int err;
> +
> +       err = eval_hals(priv->adev->handle, &hals);
> +       if (err)
> +               return err;
> +
> +       return test_bit(HALS_KBD_BL_STATE_BIT, &hals);

On some architectures IIRC it returns long (or unsigned long). Is it a problem?

> +}

...

> +static int ideapad_kbd_bl_init(struct ideapad_private *priv)
> +{
> +       int err;
> +
> +       if (!priv->features.kbd_bl)
> +               return -ENODEV;
> +
> +       err = ideapad_kbd_bl_brightness_get(priv);

> +       if (err < 0)

Just to be sure, what positive code means here?

> +               return err;
> +
> +       priv->kbd_bl.last_brightness = err;
> +
> +       priv->kbd_bl.led.name                    = "platform::" LED_FUNCTION_KBD_BACKLIGHT;
> +       priv->kbd_bl.led.max_brightness          = 1;
> +       priv->kbd_bl.led.brightness_get          = ideapad_kbd_bl_led_cdev_brightness_get;
> +       priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set;
> +       priv->kbd_bl.led.flags                   = LED_BRIGHT_HW_CHANGED;
> +
> +       err = led_classdev_register(&priv->platform_device->dev, &priv->kbd_bl.led);
> +       if (err)
> +               return err;
> +
> +       priv->kbd_bl.initialized = true;
> +
> +       return 0;
> +}

...

>         if (acpi_has_method(handle, "HALS") && acpi_has_method(handle, "SALS")) {
> -               if (!eval_hals(handle, &val))
> +               if (!eval_hals(handle, &val)) {
>                         if (test_bit(HALS_FNLOCK_SUPPORT_BIT, &val))
>                                 priv->features.fn_lock = true;
> +
> +                       if (test_bit(HALS_KBD_BL_SUPPORT_BIT, &val))
> +                               priv->features.kbd_bl = true;
> +               }

Okay, now I understand which you had separated conditionals (you may
ignore that comment).

-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux