devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Murphy <dmurphy@ti.com>
To: robh+dt@kernel.org, mark.rutland@arm.com, rpurdie@rpsys.net,
	jacek.anaszewski@gmail.com, pavel@ucw.cz, sakari.ailus@iki.fi,
	laurent.pinchart@ideasonboard.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-leds@vger.kernel.org, Dan Murphy <dmurphy@ti.com>
Subject: [RFC PATCH 2/2] leds: as3645a: Update LED label generation
Date: Tue, 12 Dec 2017 15:50:24 -0600	[thread overview]
Message-ID: <20171212215024.30116-2-dmurphy@ti.com> (raw)
In-Reply-To: <20171212215024.30116-1-dmurphy@ti.com>

Generate the LED label based off either the
DT label node or off the I2C ID in the
i2c device id struct.

If the label is used then this should denote
the LED function.  As an example it would
be as3645a:<function>

 Otherwise if the label is not
used the LED label will be as3645a:flash and
as3645a:indicator.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/leds/leds-as3645a.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index f883616d9e60..197acd69ddcc 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -526,10 +526,11 @@ static int as3645a_parse_node(struct as3645a *flash,
 
 	rval = of_property_read_string(flash->flash_node, "label", &name);
 	if (!rval)
-		strlcpy(names->flash, name, sizeof(names->flash));
+		snprintf(names->flash, sizeof(names->flash), "%s:%s",
+			 id->name, name);
 	else
 		snprintf(names->flash, sizeof(names->flash),
-			 "%s:flash", node->name);
+			 "%s:flash", id->name);
 
 	rval = of_property_read_u32(flash->flash_node, "flash-timeout-us",
 				    &cfg->flash_timeout_us);
@@ -570,10 +571,11 @@ static int as3645a_parse_node(struct as3645a *flash,
 
 	rval = of_property_read_string(flash->indicator_node, "label", &name);
 	if (!rval)
-		strlcpy(names->indicator, name, sizeof(names->indicator));
+		snprintf(names->indicator, sizeof(names->indicator), "%s:%s",
+			 id->name, name);
 	else
 		snprintf(names->indicator, sizeof(names->indicator),
-			 "%s:indicator", node->name);
+			 "%s:indicator", id->name);
 
 	rval = of_property_read_u32(flash->indicator_node, "led-max-microamp",
 				    &cfg->indicator_max_ua);
-- 
2.15.0.124.g7668cbc60

  reply	other threads:[~2017-12-12 21:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 21:50 [RFC PATCH 1/2] dt: bindings: as3645a: Update dt node example with standard Dan Murphy
2017-12-12 21:50 ` Dan Murphy [this message]
2017-12-14 18:03   ` [RFC PATCH 2/2] leds: as3645a: Update LED label generation Sakari Ailus
     [not found]     ` <20171214180335.j6qk2rrge77gpbba-S+BSfZ9RZZmRSg0ZkenSGLdO1Tsj/99ntUK59QYPAWc@public.gmane.org>
2017-12-14 19:13       ` Dan Murphy
2017-12-13  8:09 ` [RFC PATCH 1/2] dt: bindings: as3645a: Update dt node example with standard Laurent Pinchart
2017-12-13 12:55   ` Dan Murphy
2017-12-13 16:29     ` Laurent Pinchart
     [not found] ` <20171212215024.30116-1-dmurphy-l0cyMroinI0@public.gmane.org>
2017-12-15 22:54   ` Rob Herring

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=20171212215024.30116-2-dmurphy@ti.com \
    --to=dmurphy@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).