* [PATCH 0/4] led: drivers bug fixes
@ 2013-03-19 18:07 Simon Guinot
2013-03-19 18:07 ` [PATCH 1/4] leds: leds-ns2: fix oops at module removal Simon Guinot
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Simon Guinot @ 2013-03-19 18:07 UTC (permalink / raw)
To: linux-arm-kernel
Here are some bug fixes for the LED drivers leds-ns2, leds-lt3593 and
leds-renesas-tpu. Note that I don't have tested the patches related with
the two lasts. I don't have the hardware.
Regards,
Simon
Simon Guinot (4):
leds: leds-ns2: fix oops at module removal
leds: leds-ns2: fix devm_gpio_request_one() flags parameter
leds: leds-lt3593: fix devm_gpio_request_one() flags parameter
leds: renesas: fix devm_gpio_request_one() flags parameter
drivers/leds/leds-lt3593.c | 5 +++--
drivers/leds/leds-ns2.c | 44 ++++++++++++++++++++++++++-------------
drivers/leds/leds-renesas-tpu.c | 3 ++-
3 files changed, 34 insertions(+), 18 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] leds: leds-ns2: fix oops at module removal
2013-03-19 18:07 [PATCH 0/4] led: drivers bug fixes Simon Guinot
@ 2013-03-19 18:07 ` Simon Guinot
2013-03-19 18:07 ` [PATCH 2/4] leds: leds-ns2: fix devm_gpio_request_one() flags parameter Simon Guinot
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Simon Guinot @ 2013-03-19 18:07 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes a regression introduced by commit 72052fcc10
("leds: leds-ns2: add device tree binding").
When the driver is initialized with device tree data, platform_data
pointer is NULL. This causes a kernel oops at removal.
To fix this bug, num_leds is moved into driver_data and platform_data
is not longer used from ns2_led_remove().
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
drivers/leds/leds-ns2.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index d978171..81af8e9 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -306,10 +306,21 @@ static const struct of_device_id of_ns2_leds_match[] = {
};
#endif /* CONFIG_OF_GPIO */
+struct ns2_led_priv {
+ int num_leds;
+ struct ns2_led_data leds_data[];
+};
+
+static inline int sizeof_ns2_led_priv(int num_leds)
+{
+ return sizeof(struct ns2_led_priv) +
+ (sizeof(struct ns2_led_data) * num_leds);
+}
+
static int ns2_led_probe(struct platform_device *pdev)
{
struct ns2_led_platform_data *pdata = pdev->dev.platform_data;
- struct ns2_led_data *leds_data;
+ struct ns2_led_priv *priv;
int i;
int ret;
@@ -330,21 +341,23 @@ static int ns2_led_probe(struct platform_device *pdev)
return -EINVAL;
#endif /* CONFIG_OF_GPIO */
- leds_data = devm_kzalloc(&pdev->dev, sizeof(struct ns2_led_data) *
- pdata->num_leds, GFP_KERNEL);
- if (!leds_data)
+ priv = devm_kzalloc(&pdev->dev,
+ sizeof_ns2_led_priv(pdata->num_leds), GFP_KERNEL);
+ if (!priv)
return -ENOMEM;
+ priv->num_leds = pdata->num_leds;
- for (i = 0; i < pdata->num_leds; i++) {
- ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]);
+ for (i = 0; i < priv->num_leds; i++) {
+ ret = create_ns2_led(pdev, &priv->leds_data[i],
+ &pdata->leds[i]);
if (ret < 0) {
for (i = i - 1; i >= 0; i--)
- delete_ns2_led(&leds_data[i]);
+ delete_ns2_led(&priv->leds_data[i]);
return ret;
}
}
- platform_set_drvdata(pdev, leds_data);
+ platform_set_drvdata(pdev, priv);
return 0;
}
@@ -352,13 +365,12 @@ static int ns2_led_probe(struct platform_device *pdev)
static int ns2_led_remove(struct platform_device *pdev)
{
int i;
- struct ns2_led_platform_data *pdata = pdev->dev.platform_data;
- struct ns2_led_data *leds_data;
+ struct ns2_led_priv *priv;
- leds_data = platform_get_drvdata(pdev);
+ priv = platform_get_drvdata(pdev);
- for (i = 0; i < pdata->num_leds; i++)
- delete_ns2_led(&leds_data[i]);
+ for (i = 0; i < priv->num_leds; i++)
+ delete_ns2_led(&priv->leds_data[i]);
platform_set_drvdata(pdev, NULL);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] leds: leds-ns2: fix devm_gpio_request_one() flags parameter
2013-03-19 18:07 [PATCH 0/4] led: drivers bug fixes Simon Guinot
2013-03-19 18:07 ` [PATCH 1/4] leds: leds-ns2: fix oops at module removal Simon Guinot
@ 2013-03-19 18:07 ` Simon Guinot
2013-03-20 0:58 ` Jingoo Han
2013-03-19 18:07 ` [PATCH 3/4] leds: leds-lt3593: " Simon Guinot
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Simon Guinot @ 2013-03-19 18:07 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes a regression introduced by commit 31c3dc7488
("leds: leds-ns2: use gpio_request_one").
gpio_request_one is called with a wrong flag value: The initial GPIO
state is used to configure the direction (bit 0) instead of the value
(bit 1). As a result, if the initial GPIO state is non null then the
GPIO will be configured as input.
This patch fixes the issue by using the dedicated macros
GPIOF_OUT_INIT_{LOW,HIGH} to configure the initial GPIO value.
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
drivers/leds/leds-ns2.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
index 81af8e9..70137b1 100644
--- a/drivers/leds/leds-ns2.c
+++ b/drivers/leds/leds-ns2.c
@@ -193,7 +193,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
enum ns2_led_modes mode;
ret = devm_gpio_request_one(&pdev->dev, template->cmd,
- GPIOF_DIR_OUT | gpio_get_value(template->cmd),
+ gpio_get_value(template->cmd) ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
template->name);
if (ret) {
dev_err(&pdev->dev, "%s: failed to setup command GPIO\n",
@@ -202,7 +203,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
}
ret = devm_gpio_request_one(&pdev->dev, template->slow,
- GPIOF_DIR_OUT | gpio_get_value(template->slow),
+ gpio_get_value(template->slow) ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
template->name);
if (ret) {
dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n",
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] leds: leds-lt3593: fix devm_gpio_request_one() flags parameter
2013-03-19 18:07 [PATCH 0/4] led: drivers bug fixes Simon Guinot
2013-03-19 18:07 ` [PATCH 1/4] leds: leds-ns2: fix oops at module removal Simon Guinot
2013-03-19 18:07 ` [PATCH 2/4] leds: leds-ns2: fix devm_gpio_request_one() flags parameter Simon Guinot
@ 2013-03-19 18:07 ` Simon Guinot
2013-03-20 0:59 ` Jingoo Han
2013-03-19 18:07 ` [PATCH 4/4] leds: renesas: " Simon Guinot
2013-03-21 0:23 ` [PATCH 0/4] led: drivers bug fixes Bryan Wu
4 siblings, 1 reply; 9+ messages in thread
From: Simon Guinot @ 2013-03-19 18:07 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes a regression introduced by commit 507d967bc1
("leds: leds-lt3593: use gpio_request_one").
gpio_request_one is called with a wrong flag value: The GPIO default
state is used to configure the direction (bit 0) instead of the value
(bit 1). As a result, if the default GPIO state is non null then the
GPIO will be configured as input.
This patch fixes the issue by using the dedicated macros
GPIOF_OUT_INIT_{LOW,HIGH} to configure the initial GPIO value.
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
drivers/leds/leds-lt3593.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
index c9b9e1f..ca48a7d 100644
--- a/drivers/leds/leds-lt3593.c
+++ b/drivers/leds/leds-lt3593.c
@@ -106,8 +106,9 @@ static int create_lt3593_led(const struct gpio_led *template,
if (!template->retain_state_suspended)
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
- ret = devm_gpio_request_one(parent, template->gpio,
- GPIOF_DIR_OUT | state, template->name);
+ ret = devm_gpio_request_one(parent, template->gpio, state ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
+ template->name);
if (ret < 0)
return ret;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/4] leds: renesas: fix devm_gpio_request_one() flags parameter
2013-03-19 18:07 [PATCH 0/4] led: drivers bug fixes Simon Guinot
` (2 preceding siblings ...)
2013-03-19 18:07 ` [PATCH 3/4] leds: leds-lt3593: " Simon Guinot
@ 2013-03-19 18:07 ` Simon Guinot
2013-03-20 1:00 ` Jingoo Han
2013-03-21 0:23 ` [PATCH 0/4] led: drivers bug fixes Bryan Wu
4 siblings, 1 reply; 9+ messages in thread
From: Simon Guinot @ 2013-03-19 18:07 UTC (permalink / raw)
To: linux-arm-kernel
This patch fixes a regression introduced by commit b0053aaa23
("leds: renesas: use gpio_request_one").
gpio_request_one is called with a wrong flag value: The brightness is
used to configure the direction (bit 0) instead of the value (bit 1).
This patch fixes the issue by using the dedicated macros
GPIOF_OUT_INIT_{LOW,HIGH} to configure the initial GPIO value.
Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
---
drivers/leds/leds-renesas-tpu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c
index d3c2b7e..79cca23 100644
--- a/drivers/leds/leds-renesas-tpu.c
+++ b/drivers/leds/leds-renesas-tpu.c
@@ -205,7 +205,8 @@ static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state,
gpio_free(cfg->pin_gpio_fn);
if (new_state == R_TPU_PIN_GPIO)
- gpio_request_one(cfg->pin_gpio, GPIOF_DIR_OUT | !!brightness,
+ gpio_request_one(cfg->pin_gpio, brightness ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
cfg->name);
if (new_state == R_TPU_PIN_GPIO_FN)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] leds: leds-ns2: fix devm_gpio_request_one() flags parameter
2013-03-19 18:07 ` [PATCH 2/4] leds: leds-ns2: fix devm_gpio_request_one() flags parameter Simon Guinot
@ 2013-03-20 0:58 ` Jingoo Han
0 siblings, 0 replies; 9+ messages in thread
From: Jingoo Han @ 2013-03-20 0:58 UTC (permalink / raw)
To: linux-arm-kernel
On Wednesday, March 20, 2013 3:08 AM, Simon Guinot wrote:
>
> This patch fixes a regression introduced by commit 31c3dc7488
> ("leds: leds-ns2: use gpio_request_one").
>
> gpio_request_one is called with a wrong flag value: The initial GPIO
> state is used to configure the direction (bit 0) instead of the value
> (bit 1). As a result, if the initial GPIO state is non null then the
> GPIO will be configured as input.
>
> This patch fixes the issue by using the dedicated macros
> GPIOF_OUT_INIT_{LOW,HIGH} to configure the initial GPIO value.
>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Hi Simon Guinot,
The same patch was already merged to Bryan's git.
Thus, this patch is not necessary.
(http://www.spinics.net/lists/linux-leds/msg00756.html)
Best regards,
Jingoo Han
> ---
> drivers/leds/leds-ns2.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c
> index 81af8e9..70137b1 100644
> --- a/drivers/leds/leds-ns2.c
> +++ b/drivers/leds/leds-ns2.c
> @@ -193,7 +193,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
> enum ns2_led_modes mode;
>
> ret = devm_gpio_request_one(&pdev->dev, template->cmd,
> - GPIOF_DIR_OUT | gpio_get_value(template->cmd),
> + gpio_get_value(template->cmd) ?
> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> template->name);
> if (ret) {
> dev_err(&pdev->dev, "%s: failed to setup command GPIO\n",
> @@ -202,7 +203,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat,
> }
>
> ret = devm_gpio_request_one(&pdev->dev, template->slow,
> - GPIOF_DIR_OUT | gpio_get_value(template->slow),
> + gpio_get_value(template->slow) ?
> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> template->name);
> if (ret) {
> dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n",
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/4] leds: leds-lt3593: fix devm_gpio_request_one() flags parameter
2013-03-19 18:07 ` [PATCH 3/4] leds: leds-lt3593: " Simon Guinot
@ 2013-03-20 0:59 ` Jingoo Han
0 siblings, 0 replies; 9+ messages in thread
From: Jingoo Han @ 2013-03-20 0:59 UTC (permalink / raw)
To: linux-arm-kernel
On Wednesday, March 20, 2013 3:08 AM, Simon Guinot wrote:
>
> This patch fixes a regression introduced by commit 507d967bc1
> ("leds: leds-lt3593: use gpio_request_one").
>
> gpio_request_one is called with a wrong flag value: The GPIO default
> state is used to configure the direction (bit 0) instead of the value
> (bit 1). As a result, if the default GPIO state is non null then the
> GPIO will be configured as input.
>
> This patch fixes the issue by using the dedicated macros
> GPIOF_OUT_INIT_{LOW,HIGH} to configure the initial GPIO value.
>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Hi Simon Guinot,
The same patch was already merged to Bryan's git.
Thus, this patch is not necessary.
(http://www.spinics.net/lists/linux-leds/msg00755.html)
Best regards,
Jingoo Han
> ---
> drivers/leds/leds-lt3593.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
> index c9b9e1f..ca48a7d 100644
> --- a/drivers/leds/leds-lt3593.c
> +++ b/drivers/leds/leds-lt3593.c
> @@ -106,8 +106,9 @@ static int create_lt3593_led(const struct gpio_led *template,
> if (!template->retain_state_suspended)
> led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>
> - ret = devm_gpio_request_one(parent, template->gpio,
> - GPIOF_DIR_OUT | state, template->name);
> + ret = devm_gpio_request_one(parent, template->gpio, state ?
> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> + template->name);
> if (ret < 0)
> return ret;
>
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] leds: renesas: fix devm_gpio_request_one() flags parameter
2013-03-19 18:07 ` [PATCH 4/4] leds: renesas: " Simon Guinot
@ 2013-03-20 1:00 ` Jingoo Han
0 siblings, 0 replies; 9+ messages in thread
From: Jingoo Han @ 2013-03-20 1:00 UTC (permalink / raw)
To: linux-arm-kernel
On Wednesday, March 20, 2013 3:08 AM, Simon Guinot wrote:
>
> This patch fixes a regression introduced by commit b0053aaa23
> ("leds: renesas: use gpio_request_one").
>
> gpio_request_one is called with a wrong flag value: The brightness is
> used to configure the direction (bit 0) instead of the value (bit 1).
>
> This patch fixes the issue by using the dedicated macros
> GPIOF_OUT_INIT_{LOW,HIGH} to configure the initial GPIO value.
>
> Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Hi Simon Guinot,
The same patch was already merged to Bryan's git.
Thus, this patch is not necessary.
(http://www.spinics.net/lists/linux-leds/msg00757.html)
Best regards,
Jingoo Han
> ---
> drivers/leds/leds-renesas-tpu.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c
> index d3c2b7e..79cca23 100644
> --- a/drivers/leds/leds-renesas-tpu.c
> +++ b/drivers/leds/leds-renesas-tpu.c
> @@ -205,7 +205,8 @@ static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state,
> gpio_free(cfg->pin_gpio_fn);
>
> if (new_state == R_TPU_PIN_GPIO)
> - gpio_request_one(cfg->pin_gpio, GPIOF_DIR_OUT | !!brightness,
> + gpio_request_one(cfg->pin_gpio, brightness ?
> + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> cfg->name);
>
> if (new_state == R_TPU_PIN_GPIO_FN)
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-leds" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/4] led: drivers bug fixes
2013-03-19 18:07 [PATCH 0/4] led: drivers bug fixes Simon Guinot
` (3 preceding siblings ...)
2013-03-19 18:07 ` [PATCH 4/4] leds: renesas: " Simon Guinot
@ 2013-03-21 0:23 ` Bryan Wu
4 siblings, 0 replies; 9+ messages in thread
From: Bryan Wu @ 2013-03-21 0:23 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Mar 19, 2013 at 11:07 AM, Simon Guinot
<simon.guinot@sequanux.org> wrote:
> Here are some bug fixes for the LED drivers leds-ns2, leds-lt3593 and
> leds-renesas-tpu. Note that I don't have tested the patches related with
> the two lasts. I don't have the hardware.
>
> Regards,
>
> Simon
>
> Simon Guinot (4):
> leds: leds-ns2: fix oops at module removal
Thanks, I merged this patch and other 3 patches are already in my git tree.
-Bryan
> leds: leds-ns2: fix devm_gpio_request_one() flags parameter
> leds: leds-lt3593: fix devm_gpio_request_one() flags parameter
> leds: renesas: fix devm_gpio_request_one() flags parameter
>
> drivers/leds/leds-lt3593.c | 5 +++--
> drivers/leds/leds-ns2.c | 44 ++++++++++++++++++++++++++-------------
> drivers/leds/leds-renesas-tpu.c | 3 ++-
> 3 files changed, 34 insertions(+), 18 deletions(-)
>
> --
> 1.7.10.4
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-03-21 0:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 18:07 [PATCH 0/4] led: drivers bug fixes Simon Guinot
2013-03-19 18:07 ` [PATCH 1/4] leds: leds-ns2: fix oops at module removal Simon Guinot
2013-03-19 18:07 ` [PATCH 2/4] leds: leds-ns2: fix devm_gpio_request_one() flags parameter Simon Guinot
2013-03-20 0:58 ` Jingoo Han
2013-03-19 18:07 ` [PATCH 3/4] leds: leds-lt3593: " Simon Guinot
2013-03-20 0:59 ` Jingoo Han
2013-03-19 18:07 ` [PATCH 4/4] leds: renesas: " Simon Guinot
2013-03-20 1:00 ` Jingoo Han
2013-03-21 0:23 ` [PATCH 0/4] led: drivers bug fixes Bryan Wu
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).