All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <j.anaszewski@samsung.com>
To: Bryan Wu <cooloney@gmail.com>
Cc: Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Richard Purdie <rpurdie@rpsys.net>,
	Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>,
	Sakari Ailus <sakari.ailus@iki.fi>
Subject: Re: [PATCH v2] leds: start numerating duplicated devices from 2
Date: Fri, 27 Mar 2015 09:01:50 +0100	[thread overview]
Message-ID: <55150E6E.6020605@samsung.com> (raw)
In-Reply-To: <CAK5ve-JVeosdk+c7QsGqGWskNHvrpKbGn--LfGGOzwyROwDk0w@mail.gmail.com>

On 03/26/2015 07:15 PM, Bryan Wu wrote:
> On Thu, Mar 26, 2015 at 7:59 AM, Jacek Anaszewski
> <j.anaszewski@samsung.com> wrote:
>> Duplicated devices are currently given numerical suffixes
>> starting from 1. Since duplication means that one instance
>> of a device already exists in the system, then it is more
>> intuitive for the next device to get the suffix "_2".
>>
>
> No, I prefer to "_1" since normally we treat the first one "_0" or
> empty.

OK, I can live with that :)

> But I suggest we add the "_0" for the first new device then the
> second one will be "_1"

If we changed naming for the device probed as the first one, then
we could break some existing user space applications.

I think that most of time there won't be any device with automagically
added numerical suffix in the LED subsystem, provided that the user
will get acquainted with the DT common leds documentation and will
define labels with different names.

The only case when adding the suffix can't be avoided is the one with
DT overlays.

Adding the suffix should be considered rather a countermeasure than
a convention.


>> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
>> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
>> Cc: Bryan Wu <cooloney@gmail.com>
>> Cc: Richard Purdie <rpurdie@rpsys.net>
>> Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
>> Cc: Sakari Ailus <sakari.ailus@iki.fi>
>> ---
>>   drivers/leds/led-class.c |    4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
>> index 4ca37b8..07fcb35 100644
>> --- a/drivers/leds/led-class.c
>> +++ b/drivers/leds/led-class.c
>> @@ -222,14 +222,14 @@ static int match_name(struct device *dev, const void *data)
>>   static int led_classdev_next_name(const char *init_name, char *name,
>>                                    size_t len)
>>   {
>> -       int i = 0;
>> +       int i = 1;
>>
>>          strncpy(name, init_name, len);
>>
>>          while (class_find_device(leds_class, NULL, name, match_name))
>>                  snprintf(name, len, "%s_%d", init_name, ++i);
>>
>> -       return i;
>> +       return i > 1 ? i : 0;
>>   }
>>
>>   /**
>> --
>> 1.7.9.5
>>
>


-- 
Best Regards,
Jacek Anaszewski

      parent reply	other threads:[~2015-03-27  8:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-26 14:59 [PATCH v2] leds: start numerating duplicated devices from 2 Jacek Anaszewski
2015-03-26 18:15 ` Bryan Wu
2015-03-27  7:51   ` Ricardo Ribalda Delgado
2015-03-27  8:01   ` Jacek Anaszewski [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=55150E6E.6020605@samsung.com \
    --to=j.anaszewski@samsung.com \
    --cc=cooloney@gmail.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=ricardo.ribalda@gmail.com \
    --cc=rpurdie@rpsys.net \
    --cc=sakari.ailus@iki.fi \
    /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.