* [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure
@ 2014-08-30 14:45 Pramod Gurav
2014-09-04 16:53 ` Linus Walleij
2014-09-04 18:08 ` Srinivas Kandagatla
0 siblings, 2 replies; 5+ messages in thread
From: Pramod Gurav @ 2014-08-30 14:45 UTC (permalink / raw)
To: linux-arm-kernel
This patch adds a remove function to platform_driver to unload
the driver in a cleaner way. This also releases gpiochip related
resources by calling gpiochip_remove when gpiochip_irqchip_add fails.
CC: Srinivas Kandagatla <srinivas.kandagatla@gmail.com>
CC: Srinivas Kandagatla <srinivas.kandagatla@linaro.com>
CC: Maxime Coquelin <maxime.coquelin@st.com>
CC: Patrice Chotard <patrice.chotard@st.com>
CC: Linus Walleij <linus.walleij@linaro.org>
CC: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
drivers/pinctrl/pinctrl-st.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 5475374..9296845 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1517,6 +1517,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info,
0, handle_simple_irq,
IRQ_TYPE_LEVEL_LOW);
if (err) {
+ gpiochip_remove(&bank->gpio_chip);
dev_info(dev, "could not add irqchip\n");
return err;
}
@@ -1685,6 +1686,29 @@ static int st_pctl_probe(struct platform_device *pdev)
return 0;
}
+static int st_pctl_remove(struct platform_device *pdev)
+{
+ struct st_pinctrl *info = platform_get_drvdata(pdev);
+ struct device_node *np = pdev->dev.of_node;
+ struct device_node *child;
+ struct gpio_chip gpio_chip;
+ int bank = 0;
+
+ if (info->nbanks) {
+ for_each_child_of_node(np, child) {
+ if (of_property_read_bool(child, "gpio-controller")) {
+ gpio_chip = info->banks[bank].gpio_chip;
+ gpiochip_remove(&gpio_chip);
+ bank++;
+ }
+ }
+ }
+
+ pinctrl_unregister(info->pctl);
+
+ return 0;
+}
+
static struct platform_driver st_pctl_driver = {
.driver = {
.name = "st-pinctrl",
@@ -1692,6 +1716,7 @@ static struct platform_driver st_pctl_driver = {
.of_match_table = st_pctl_of_match,
},
.probe = st_pctl_probe,
+ .remove = st_pctl_remove,
};
static int __init st_pctl_init(void)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure
2014-08-30 14:45 [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure Pramod Gurav
@ 2014-09-04 16:53 ` Linus Walleij
2014-09-04 18:08 ` Srinivas Kandagatla
1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2014-09-04 16:53 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Aug 30, 2014 at 4:45 PM, Pramod Gurav
<pramod.gurav@smartplayin.com> wrote:
> This patch adds a remove function to platform_driver to unload
> the driver in a cleaner way. This also releases gpiochip related
> resources by calling gpiochip_remove when gpiochip_irqchip_add fails.
>
> CC: Srinivas Kandagatla <srinivas.kandagatla@gmail.com>
> CC: Srinivas Kandagatla <srinivas.kandagatla@linaro.com>
> CC: Maxime Coquelin <maxime.coquelin@st.com>
> CC: Patrice Chotard <patrice.chotard@st.com>
> CC: Linus Walleij <linus.walleij@linaro.org>
> CC: Bjorn Andersson <bjorn.andersson@sonymobile.com>
>
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
Srinivas/Patrice: can you have a look at this?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure
2014-08-30 14:45 [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure Pramod Gurav
2014-09-04 16:53 ` Linus Walleij
@ 2014-09-04 18:08 ` Srinivas Kandagatla
2014-09-05 4:48 ` Pramod Gurav
2014-09-05 7:27 ` Maxime Coquelin
1 sibling, 2 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2014-09-04 18:08 UTC (permalink / raw)
To: linux-arm-kernel
Pramod,
sorry for delay in reply as I was travelling, still in Jet lag.
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
> drivers/pinctrl/pinctrl-st.c | 25 +++++++++++++++++++++++++
> 1 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
> index 5475374..9296845 100644
> --- a/drivers/pinctrl/pinctrl-st.c
> +++ b/drivers/pinctrl/pinctrl-st.c
> @@ -1517,6 +1517,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info,
> 0, handle_simple_irq,
> IRQ_TYPE_LEVEL_LOW);
> if (err) {
> + gpiochip_remove(&bank->gpio_chip);
This change-set looks good.
IMO, you can send a patch for this change set.
> dev_info(dev, "could not add irqchip\n");
> return err;
> }
> @@ -1685,6 +1686,29 @@ static int st_pctl_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static int st_pctl_remove(struct platform_device *pdev)
> +{
Ideally this driver will not be removed, as other drivers depend on
this, even the serial.
so I see no big achievement in adding the remove functionality, as this
is going to be a dead code and would never be tested.
> + struct st_pinctrl *info = platform_get_drvdata(pdev);
> + struct device_node *np = pdev->dev.of_node;
> + struct device_node *child;
> + struct gpio_chip gpio_chip;
> + int bank = 0;
> +
> + if (info->nbanks) {
> + for_each_child_of_node(np, child) {
> + if (of_property_read_bool(child, "gpio-controller")) {
We should not re-parse the DT nodes once we are done with it in the probe.
> + gpio_chip = info->banks[bank].gpio_chip;
> + gpiochip_remove(&gpio_chip);
> + bank++;
> + }
> + }
> + }
> +
I think the logic is very simple:
while (nbanks--)
gpiochip_remove(&info->banks[bank++].gpio_chip))
thanks,
srini
> + pinctrl_unregister(info->pctl);
> +
> + return 0;
> +}
> +
> static struct platform_driver st_pctl_driver = {
> .driver = {
> .name = "st-pinctrl",
> @@ -1692,6 +1716,7 @@ static struct platform_driver st_pctl_driver = {
> .of_match_table = st_pctl_of_match,
> },
> .probe = st_pctl_probe,
> + .remove = st_pctl_remove,
> };
>
> static int __init st_pctl_init(void)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure
2014-09-04 18:08 ` Srinivas Kandagatla
@ 2014-09-05 4:48 ` Pramod Gurav
2014-09-05 7:27 ` Maxime Coquelin
1 sibling, 0 replies; 5+ messages in thread
From: Pramod Gurav @ 2014-09-05 4:48 UTC (permalink / raw)
To: linux-arm-kernel
Hi Srini,
Thanks for review.
On 04-09-2014 11:38 PM, Srinivas Kandagatla wrote:
> Pramod,
> sorry for delay in reply as I was travelling, still in Jet lag.
>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
>> ---
>> drivers/pinctrl/pinctrl-st.c | 25 +++++++++++++++++++++++++
>> 1 files changed, 25 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
>> index 5475374..9296845 100644
>> --- a/drivers/pinctrl/pinctrl-st.c
>> +++ b/drivers/pinctrl/pinctrl-st.c
>> @@ -1517,6 +1517,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info,
>> 0, handle_simple_irq,
>> IRQ_TYPE_LEVEL_LOW);
>> if (err) {
>> + gpiochip_remove(&bank->gpio_chip);
> This change-set looks good.
> IMO, you can send a patch for this change set.
Will resend just this.
>
>> dev_info(dev, "could not add irqchip\n");
>> return err;
>> }
>> @@ -1685,6 +1686,29 @@ static int st_pctl_probe(struct platform_device *pdev)
>> return 0;
>> }
>>
>
>> +static int st_pctl_remove(struct platform_device *pdev)
>> +{
> Ideally this driver will not be removed, as other drivers depend on
> this, even the serial.
>
> so I see no big achievement in adding the remove functionality, as this
> is going to be a dead code and would never be tested.
>
>> + struct st_pinctrl *info = platform_get_drvdata(pdev);
>> + struct device_node *np = pdev->dev.of_node;
>> + struct device_node *child;
>> + struct gpio_chip gpio_chip;
>> + int bank = 0;
>> +
>
>> + if (info->nbanks) {
>> + for_each_child_of_node(np, child) {
>> + if (of_property_read_bool(child, "gpio-controller")) {
> We should not re-parse the DT nodes once we are done with it in the probe.
Thanks. :)
>
>> + gpio_chip = info->banks[bank].gpio_chip;
>> + gpiochip_remove(&gpio_chip);
>> + bank++;
>> + }
>> + }
>> + }
>> +
>
> I think the logic is very simple:
>
> while (nbanks--)
> gpiochip_remove(&info->banks[bank++].gpio_chip))
Thanks again. Remove is not needed hence will not do this. But good know.
>
>
> thanks,
> srini
>> + pinctrl_unregister(info->pctl);
>> +
>> + return 0;
>> +}
>> +
>> static struct platform_driver st_pctl_driver = {
>> .driver = {
>> .name = "st-pinctrl",
>> @@ -1692,6 +1716,7 @@ static struct platform_driver st_pctl_driver = {
>> .of_match_table = st_pctl_of_match,
>> },
>> .probe = st_pctl_probe,
>> + .remove = st_pctl_remove,
>> };
>>
>> static int __init st_pctl_init(void)
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure
2014-09-04 18:08 ` Srinivas Kandagatla
2014-09-05 4:48 ` Pramod Gurav
@ 2014-09-05 7:27 ` Maxime Coquelin
1 sibling, 0 replies; 5+ messages in thread
From: Maxime Coquelin @ 2014-09-05 7:27 UTC (permalink / raw)
To: linux-arm-kernel
Hi Pramod, Srini
On 09/04/2014 08:08 PM, Srinivas Kandagatla wrote:
> Pramod,
> sorry for delay in reply as I was travelling, still in Jet lag.
>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
>> ---
>> drivers/pinctrl/pinctrl-st.c | 25 +++++++++++++++++++++++++
>> 1 files changed, 25 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
>> index 5475374..9296845 100644
>> --- a/drivers/pinctrl/pinctrl-st.c
>> +++ b/drivers/pinctrl/pinctrl-st.c
>> @@ -1517,6 +1517,7 @@ static int st_gpiolib_register_bank(struct
>> st_pinctrl *info,
>> 0, handle_simple_irq,
>> IRQ_TYPE_LEVEL_LOW);
>> if (err) {
>> + gpiochip_remove(&bank->gpio_chip);
> This change-set looks good.
> IMO, you can send a patch for this change set.
Removing the gpiochip here looks good to me too.
>
>> dev_info(dev, "could not add irqchip\n");
>> return err;
>> }
>> @@ -1685,6 +1686,29 @@ static int st_pctl_probe(struct platform_device
>> *pdev)
>> return 0;
>> }
>>
>
>> +static int st_pctl_remove(struct platform_device *pdev)
>> +{
> Ideally this driver will not be removed, as other drivers depend on
> this, even the serial.
>
> so I see no big achievement in adding the remove functionality, as this
> is going to be a dead code and would never be tested.
Agree too.
Thanks,
Maxime
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-09-05 7:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-30 14:45 [PATCH] pinctrl: st: Add remove function and remove gpio_chip on failure Pramod Gurav
2014-09-04 16:53 ` Linus Walleij
2014-09-04 18:08 ` Srinivas Kandagatla
2014-09-05 4:48 ` Pramod Gurav
2014-09-05 7:27 ` Maxime Coquelin
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).