On Thu, Mar 26, 2015 at 7:59 AM, Jacek Anaszewski
<[email protected]> 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. But I suggest we add the "_0" for the first new device then the
second one will be "_1"

Thanks,
-Bryan

> Signed-off-by: Jacek Anaszewski <[email protected]>
> Acked-by: Kyungmin Park <[email protected]>
> Cc: Bryan Wu <[email protected]>
> Cc: Richard Purdie <[email protected]>
> Cc: Ricardo Ribalda Delgado <[email protected]>
> Cc: Sakari Ailus <[email protected]>
> ---
>  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
>
--
To unsubscribe from this list: send the line "unsubscribe linux-leds" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to