From: Joel Stanley <joel@jms.id.au>
To: Pavel Machek <pavel@ucw.cz>, Dan Murphy <dmurphy@ti.com>
Cc: "Cédric Le Goater" <clg@kaod.org>,
"Andrew Jeffery" <andrew@aj.id.au>,
"Vishwanatha Subbanna" <vishwa@linux.vnet.ibm.com>,
linux-leds@vger.kernel.org
Subject: [PATCH] leds: pca955x: Allow full control over led name
Date: Thu, 25 Mar 2021 11:24:56 +1030 [thread overview]
Message-ID: <20210325005456.152469-1-joel@jms.id.au> (raw)
The PCA955x driver since it was merged has added a "pca955x:" prefix to
LED names. This meanas platform data (such as the device tree) cannot
fully control the name. Here's what this produces using the example in
the device tree bindings:
# cat /sys/class/leds/
pca955x:green:power/
pca955x:pca9552:white/
pca955x:pca9552:yellow/
pca955x:red:power/
Some systems want the ability to configure the full string. To do this,
introduce a build time option that adds the prefix that defaults to
enabled in order to preserve existing behaviour.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/leds/Kconfig | 11 +++++++++++
drivers/leds/leds-pca955x.c | 8 +++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index b6742b4231bf..dcdb107e0967 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -519,6 +519,17 @@ config LEDS_PCA955X
LED driver chips accessed via the I2C bus. Supported
devices include PCA9550, PCA9551, PCA9552, and PCA9553.
+config LEDS_PCA955X_SYSFS_PREFIX
+ bool "PCA955x sysfs prefix"
+ depends on LEDS_PCA955X
+ default y
+ help
+ This option adds the string "pca955x:" to the start of the name
+ presented in sysfs.
+
+ If you wish to use the label provided by platform data without a
+ prefix, disable this option.
+
config LEDS_PCA955X_GPIO
bool "Enable GPIO support for PCA955X"
depends on LEDS_PCA955X
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 7087ca4592fc..b7742d6226b5 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -61,6 +61,12 @@
#define PCA955X_GPIO_HIGH LED_OFF
#define PCA955X_GPIO_LOW LED_FULL
+#ifdef CONFIG_LEDS_PCA955X_SYSFS_PREFIX
+#define SYSFS_NAME "pca955x:%s"
+#else
+#define SYSFS_NAME "%s"
+#endif
+
enum pca955x_type {
pca9550,
pca9551,
@@ -504,7 +510,7 @@ static int pca955x_probe(struct i2c_client *client,
sizeof(pdata->leds[i].name), "%d", i);
snprintf(pca955x_led->name,
- sizeof(pca955x_led->name), "pca955x:%s",
+ sizeof(pca955x_led->name), SYSFS_NAME,
pdata->leds[i].name);
if (pdata->leds[i].default_trigger)
--
2.30.2
next reply other threads:[~2021-03-25 0:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-25 0:54 Joel Stanley [this message]
2021-03-26 21:41 ` leds: pca955x: Allow full control over led name Eddie James
[not found] ` <1807483D-FF4A-454F-B0B9-AC373B938292@linux.vnet.ibm.com>
2021-04-14 11:06 ` [PATCH] " vishwanatha subbanna
2021-04-25 21:46 ` Pavel Machek
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=20210325005456.152469-1-joel@jms.id.au \
--to=joel@jms.id.au \
--cc=andrew@aj.id.au \
--cc=clg@kaod.org \
--cc=dmurphy@ti.com \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=vishwa@linux.vnet.ibm.com \
/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).