All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony <tony.makkiel@daqri.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: linux-leds@vger.kernel.org
Subject: Re: [PATCH v8 1/1] leds: LED driver for TI LP3952 6-Channel Color LED
Date: Thu, 7 Jul 2016 15:59:44 +0100	[thread overview]
Message-ID: <577E6E60.50804@daqri.com> (raw)
In-Reply-To: <577E688C.9080409@samsung.com>



On 07/07/16 15:34, Jacek Anaszewski wrote:

>>>
>>> Why actually do you need this array? Couldn't you provide the LED
>>> identifier in the DSD entry corresponding to a LED? You can follow
>>> the scheme used in Device Tree by introducing "reg" property.
>>
>> The names in the array are the 6 identifiers in the DSD entry. For
>> example
>> the DSD property for blue2 led used is
>>
>> "Package ()
>> {
>>          Package (2) {"blue2", "led_blue2"},
>> "
>> acpi_dev_get_property will return "led_blue2" in obj->string.pointer.
>>
>> There isn't separate DSD for individual leds. There is only 1 DSD for
>> the led controller identified by "Name (_HID, "TXNW3952")". The
>> individual led names are separate properties withing th DSD (eg:
>> led_blue2 identified by blue2).
>
> OK, thanks for the explanation. BTW LED name pattern is
> devicename:colour:function.
>
>>>
>>>>>> +    for (i = 0; i < LP3952_LED_ALL; i++) {
>>>>>> +        priv->leds[i].cdev.brightness = LED_OFF;
>>>>>> +        priv->leds[i].cdev.max_brightness = LP3952_BRIGHT_MAX;
>>>>>> +        priv->leds[i].cdev.brightness_set_blocking =
>>>>>> +                lp3952_set_brightness;
>>>>>> +        priv->leds[i].channel = i;
>>>>>> +        priv->leds[i].priv = priv;
>>>>>> +
>>>>>> +        ret = lp3952_get_label(priv->leds[i].name, led_name_hdl[i],
>>>>>> +                       &priv->client->dev);
>>>>>> +        if (ret)
>>>>>> +            break;
>>>>>
>>>>> You're assuming here that all LEDs will always be present, which
>>>>> doesn't necessarily have to be true. How about just skipping
>>>>> the LED and moving to the next one if given label was not found?
>>>>> You could move this check to the beginning of the loop then.
>>>>
>>>> If we skip leds, there could be problem, if all the leds were
>>>> skipped(For example, no ACPI name data present).
>>>
>>> If all the LEDs were skipped, then no LED class device would be
>>> registered. In such a case you could return an error from
>>> lp3952_probe().
>>>
>>>>
>>>> At present, if a label is not present, the probe will fail.
>>>> How about reverting to a default name (eg: "lp3952:blue2") if led name
>>>> read fails?
>>>
>>> There is no point in registering the LED if its DSD entry is not
>>> valid. In case of Device Tree we fail LED registration in such
>>> cases.
>>
>> Sorry, I thought we were skipping LEDs due to invalid DSD. If that is
>> not the case, isn't the assumption all LEDS will be present true?
>> I am guessing leds might be missing, if some of the leds are not
>> physically connected to controller output. But the controller would
>> have 6 led controls all the time.
>
> Right, but there is no point in exposing corresponding
> LED class devices to user space if the user will be unable
> to notice any effect because the LED is not connected.

Got it, Thank you :) Will skip registration if led not found.
>
>>>
>>>> This would also cover cases in which none of the led names
>>>> were read properly.
>>>
>>> Whole driver probing should fail then.
>>>
>>>>
>>>>>
>>>>>> +
>>>>>> +        priv->leds[i].cdev.name = priv->leds[i].name;
>>>>>> +
>>>>>> +        ret = devm_led_classdev_register(&priv->client->dev,
>>>>>> +                         &priv->leds[i].cdev);
>>>>>> +        if (ret < 0) {
>>>>>> +            dev_err(&priv->client->dev,
>>>>>> +                "couldn't register LED %s\n",
>>>>>> +                priv->leds[i].cdev.name);
>>>>>> +            break;
>>>>>> +        }
>>>>>> +    }
>>>>>> +    return ret;
>>>>>> +}
>>>>>> +
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe
>>>> linux-acpi" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>
>>>>
>>>
>>>
>>
>>
>
>

      reply	other threads:[~2016-07-07 15:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05 15:30 [PATCH v8 1/1] leds: LED driver for TI LP3952 6-Channel Color LED Tony Makkiel
2016-07-06  8:23 ` Mika Westerberg
2016-07-06 13:33 ` Jacek Anaszewski
2016-07-06 15:05   ` Tony
2016-07-07  7:13     ` Jacek Anaszewski
2016-07-07 11:44       ` Tony
2016-07-07 14:34         ` Jacek Anaszewski
2016-07-07 14:59           ` Tony [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=577E6E60.50804@daqri.com \
    --to=tony.makkiel@daqri.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-leds@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.