All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] leds: start numerating duplicated devices from 2
@ 2015-03-26 14:59 Jacek Anaszewski
  2015-03-26 18:15 ` Bryan Wu
  0 siblings, 1 reply; 4+ messages in thread
From: Jacek Anaszewski @ 2015-03-26 14:59 UTC (permalink / raw)
  To: linux-leds
  Cc: Jacek Anaszewski, Bryan Wu, Richard Purdie,
	Ricardo Ribalda Delgado, Sakari Ailus

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".

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-27  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.