gpio: davinci: Add missing return checks
Subsystems (2)
Keerthy
maintainerv2 cover gpio: davinci: Add missing return checks
The patch series does a couple of important return handling which were missed earlier in the driver probe.
This is based on Suman's:
http://marc.info/?l=linux-arm-kernel&m=150034845427555&w=2
http://marc.info/?l=linux-arm-kernel&m=150034856627618&w=2
Changes in v2:
* Removed the device tree patch for to keep the series independent.
Keerthy (3):
gpio: davinci: Use devm_gpiochip_add_data in place of
gpiochip_add_data
gpio: davinci: Handle the return value of davinci_gpio_irq_setup
function
gpio: davinci: Convert prinkt to dev_err
drivers/gpio/gpio-davinci.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
Keerthy
maintainerPATCH v2 1/3 gpio: davinci: Use devm_gpiochip_add_data in place of gpiochip_add_data
Use the devm version of gpiochip_add_data and pass on the return value. This avoids memory leak due to gpiochip_add_data in case the driver is unbound.
---
Changes in v2:
* Restoring the previous values of ctrl_num and bank_base in case of an error.
drivers/gpio/gpio-davinci.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpio/gpio-davinci.c +12 -2
@@ -166,7 +166,7 @@ static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset)static int davinci_gpio_probe (struct platform_device *pdev) {static int ctrl_num, bank_base; -int gpio, bank; +int gpio, bank, ret =0 ;unsigned ngpio, nbank;struct davinci_gpio_controller *chips;struct davinci_gpio_platform_data *pdata;
@@ -232,10 +232,20 @@ static int davinci_gpio_probe(struct platform_device *pdev)for (gpio =0 , bank =0 ; gpio < ngpio; gpio +=32 , bank++) chips->regs[bank] = gpio_base + offset_array[bank]; -gpiochip_add_data (&chips->chip, chips); + ret =devm_gpiochip_add_data (dev, &chips->chip, chips); +if (ret) + goto err; +platform_set_drvdata (pdev, chips);davinci_gpio_irq_setup (pdev);return 0 ; + +err: +/* Revert the static variable increments */ + ctrl_num--; + bank_base -= ngpio; + +return ret; }/*--------------------------------------------------------------------------*/
Signature · 1 line
1.9.1
PATCH v2 1/3 gpio: davinci: Use devm_gpiochip_add_data in place of gpiochip_add_data
Quoted 5 lines · Keerthy
Use the devm version of
gpiochip_add_dataand pass on the return value. This avoids memory leak due togpiochip_add_datain case the driver is unbound.Signed-off-by Keerthy <[email protected]>
Patch applied.
Yours,
Linus Walleij
Keerthy
maintainerPATCH v2 2/3 gpio: davinci: Handle the return value of davinci_gpio_irq_setup function
In reply to KeerthyCurrently davinci_gpio_irq_setup return value is ignored. Handle the return value appropriately.
--- drivers/gpio/gpio-davinci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-davinci.c +4 -1
@@ -237,7 +237,10 @@ static int davinci_gpio_probe(struct platform_device *pdev) goto err;platform_set_drvdata (pdev, chips); -davinci_gpio_irq_setup (pdev); + ret =davinci_gpio_irq_setup (pdev); +if (ret) + goto err; +return 0 ; err:
Signature · 1 line
1.9.1
Keerthy
maintainerPATCH v2 2/3 gpio: davinci: Handle the return value of davinci_gpio_irq_setup function
Quoted 2 lines · Keerthy
Currently
davinci_gpio_irq_setupreturn value is ignored. Handle the return value appropriately.
Linus,
Any comments on this? Sorry if i pinged too soon. The rest 2 of this series were pulled by you. So just wanted to check on this one if you had specific comments.
Regards,
Keerthy
Quoted 23 lines
Signed-off-by Keerthy <[email protected]>--- drivers/gpio/gpio-davinci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpio/gpio-davinci.c +4
-1@@ -237,7 +237,10 @@ static int davinci_gpio_probe(struct platform_device *pdev) goto err;platform_set_drvdata (pdev, chips); -davinci_gpio_irq_setup (pdev); + ret =davinci_gpio_irq_setup (pdev); +if (ret) + goto err; +return 0 ; err:
PATCH v2 2/3 gpio: davinci: Handle the return value of davinci_gpio_irq_setup function
Quoted 9 lines · Keerthy
Quoted 2 lines · Keerthy
Currently
davinci_gpio_irq_setupreturn value is ignored. Handle the return value appropriately.Linus,
Any comments on this? Sorry if i pinged too soon. The rest 2 of this series were pulled by you. So just wanted to check on this one if you had specific comments.
I got the impression you would send this in a series with a new patch requested by Johan.
Do we have consensus that this patch should be applied as-is?
Yours,
Linus Walleij
Keerthy
maintainerPATCH v2 2/3 gpio: davinci: Handle the return value of davinci_gpio_irq_setup function
Quoted 7 lines · Linus Walleij
Quoted 6 lines · Keerthy
Quoted 2 lines · Keerthy
Currently
davinci_gpio_irq_setupreturn value is ignored. Handle the return value appropriately.Linus,
Quoted 8 lines
Quoted 3 lines
Any comments on this? Sorry if i pinged too soon. The rest 2 of this series were pulled by you. So just wanted to check on this one if you had specific comments.
I got the impression you would send this in a series with a new patch requested by Johan.
Do we have consensus that this patch should be applied as-is?
IIUC a separate patch is needed to implement remove function. This can still be independent of that.
https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1450395.html
Quoted 4 lines
Yours,
Linus Walleij
PATCH v2 2/3 gpio: davinci: Handle the return value of davinci_gpio_irq_setup function
In reply to KeerthyQuoted 4 lines · Keerthy
Currently
davinci_gpio_irq_setupreturn value is ignored. Handle the return value appropriately.Signed-off-by Keerthy <[email protected]>
Patch applied.
Yours,
Linus Walleij
Keerthy
maintainerPATCH v2 3/3 gpio: davinci: Convert prinkt to dev_err
In reply to KeerthyIn case of devm_clk_get failure use dev_err instead of printk
--- drivers/gpio/gpio-davinci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-davinci.c +1 -2
@@ -490,8 +490,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev) clk =devm_clk_get (dev,"gpio" );if (IS_ERR (clk)) { -printk (KERN_ERR "Error %ld getting gpio clock?\n" , -PTR_ERR (clk)); +dev_err (dev,"Error %ld getting gpio clock\n" ,PTR_ERR (clk));return PTR_ERR (clk); } ret =clk_prepare_enable (clk);
Signature · 1 line
1.9.1
PATCH v2 3/3 gpio: davinci: Convert prinkt to dev_err
Quoted 3 lines · Keerthy
In case of
devm_clk_getfailure usedev_errinstead of printkSigned-off-by Keerthy <[email protected]>
Patch applied.
Yours,
Linus Walleij
Keerthy
maintainerv2 cover gpio: davinci: Add missing return checks
In reply to KeerthyQuoted 8 lines · Keerthy
The patch series does a couple of important return handling which were missed earlier in the driver probe.
This is based on Suman's:
http://marc.info/?l=linux-arm-kernel&m=150034845427555&w=2
http://marc.info/?l=linux-arm-kernel&m=150034856627618&w=2
My bad! The series has no dependency on the above. I have split the device tree patches to keep it independent.
Quoted 14 lines
Changes in v2:
* Removed the device tree patch for to keep the series independent.
Keerthy (3):
gpio: davinci: Usedevm_gpiochip_add_datain place of
gpiochip_add_data
gpio: davinci: Handle the return value ofdavinci_gpio_irq_setup
function
gpio: davinci: Convert prinkt todev_errdrivers/gpio/gpio-davinci.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
v2 cover gpio: davinci: Add missing return checks
Hi Keerthy,
Quoted 13 lines · Keerthy
Quoted 8 lines
The patch series does a couple of important return handling which were missed earlier in the driver probe.
This is based on Suman's:
http://marc.info/?l=linux-arm-kernel&m=150034845427555&w=2
http://marc.info/?l=linux-arm-kernel&m=150034856627618&w=2My bad! The series has no dependency on the above. I have split the device tree patches to keep it independent.
The new patches looks clean. The davinci_gpio_irq_setup() function though could also do with couple more cleanups. Not all failure paths are doing the necessary cleanup (there are some non devres functions also called, but not cleaned up).
regards
Suman
Quoted 15 lines
Quoted 15 lines
Changes in v2:
* Removed the device tree patch for to keep the series independent.
Keerthy (3):
gpio: davinci: Usedevm_gpiochip_add_datain place of
gpiochip_add_data
gpio: davinci: Handle the return value ofdavinci_gpio_irq_setup
function
gpio: davinci: Convert prinkt todev_errdrivers/gpio/gpio-davinci.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
Keerthy
maintainerv2 cover gpio: davinci: Add missing return checks
Quoted 13 lines · Suman Anna
Hi Keerthy,
Quoted 11 lines · Keerthy
Quoted 8 lines
The patch series does a couple of important return handling which were missed earlier in the driver probe.
This is based on Suman's:
http://marc.info/?l=linux-arm-kernel&m=150034845427555&w=2
http://marc.info/?l=linux-arm-kernel&m=150034856627618&w=2
Quoted 7 lines
Quoted 2 lines
My bad! The series has no dependency on the above. I have split the device tree patches to keep it independent.
The new patches looks clean. The
davinci_gpio_irq_setup()function though could also do with couple more cleanups. Not all failure paths are doing the necessary cleanup (there are some non devres functions also called, but not cleaned up).
Linus,
Any comments on this series?
Regards,
Keerthy
Quoted 20 lines
regards
SumanQuoted 15 lines
Quoted 15 lines
Changes in v2:
* Removed the device tree patch for to keep the series independent.
Keerthy (3):
gpio: davinci: Usedevm_gpiochip_add_datain place of
gpiochip_add_data
gpio: davinci: Handle the return value ofdavinci_gpio_irq_setup
function
gpio: davinci: Convert prinkt todev_errdrivers/gpio/gpio-davinci.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)