public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: sm501: fix mismatches of request_mem_region
@ 2019-11-16 15:13 Chuhong Yuan
  2019-12-09  9:00 ` Lee Jones
  2019-12-09 13:13 ` Lee Jones
  0 siblings, 2 replies; 5+ messages in thread
From: Chuhong Yuan @ 2019-11-16 15:13 UTC (permalink / raw)
  Cc: Lee Jones, linux-kernel, Chuhong Yuan

This driver misuses release_resource + kfree to match request_mem_region,
which is incorrect.
The right way is to use release_mem_region.
Replace the mismatched calls with the right ones to fix it.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
---
 drivers/mfd/sm501.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 154270f8d8d7..e49787e6bb93 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1086,8 +1086,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
 	iounmap(gpio->regs);
 
  err_claimed:
-	release_resource(gpio->regs_res);
-	kfree(gpio->regs_res);
+	release_mem_region(iobase, 0x20);
 
 	return ret;
 }
@@ -1095,6 +1094,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
 static void sm501_gpio_remove(struct sm501_devdata *sm)
 {
 	struct sm501_gpio *gpio = &sm->gpio;
+	resource_size_t iobase = sm->io_res->start + SM501_GPIO;
 
 	if (!sm->gpio.registered)
 		return;
@@ -1103,8 +1103,7 @@ static void sm501_gpio_remove(struct sm501_devdata *sm)
 	gpiochip_remove(&gpio->high.gpio);
 
 	iounmap(gpio->regs);
-	release_resource(gpio->regs_res);
-	kfree(gpio->regs_res);
+	release_mem_region(iobase, 0x20);
 }
 
 static inline int sm501_gpio_isregistered(struct sm501_devdata *sm)
@@ -1427,8 +1426,7 @@ static int sm501_plat_probe(struct platform_device *dev)
 	return sm501_init_dev(sm);
 
  err_claim:
-	release_resource(sm->regs_claim);
-	kfree(sm->regs_claim);
+	release_mem_region(sm->io_res->start, 0x100);
  err_res:
 	kfree(sm);
  err1:
@@ -1637,8 +1635,7 @@ static int sm501_pci_probe(struct pci_dev *dev,
 	return 0;
 
  err4:
-	release_resource(sm->regs_claim);
-	kfree(sm->regs_claim);
+	release_mem_region(sm->io_res->start, 0x100);
  err3:
 	pci_disable_device(dev);
  err2:
@@ -1673,8 +1670,7 @@ static void sm501_pci_remove(struct pci_dev *dev)
 	sm501_dev_remove(sm);
 	iounmap(sm->regs);
 
-	release_resource(sm->regs_claim);
-	kfree(sm->regs_claim);
+	release_mem_region(sm->io_res->start, 0x100);
 
 	pci_disable_device(dev);
 }
@@ -1686,8 +1682,7 @@ static int sm501_plat_remove(struct platform_device *dev)
 	sm501_dev_remove(sm);
 	iounmap(sm->regs);
 
-	release_resource(sm->regs_claim);
-	kfree(sm->regs_claim);
+	release_mem_region(sm->io_res->start, 0x100);
 
 	return 0;
 }
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: sm501: fix mismatches of request_mem_region
  2019-11-16 15:13 [PATCH] mfd: sm501: fix mismatches of request_mem_region Chuhong Yuan
@ 2019-12-09  9:00 ` Lee Jones
  2019-12-09  9:09   ` Chuhong Yuan
  2019-12-09 13:13 ` Lee Jones
  1 sibling, 1 reply; 5+ messages in thread
From: Lee Jones @ 2019-12-09  9:00 UTC (permalink / raw)
  To: Chuhong Yuan; +Cc: linux-kernel

On Sat, 16 Nov 2019, Chuhong Yuan wrote:

> This driver misuses release_resource + kfree to match request_mem_region,
> which is incorrect.
> The right way is to use release_mem_region.
> Replace the mismatched calls with the right ones to fix it.
> 
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
>  drivers/mfd/sm501.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> index 154270f8d8d7..e49787e6bb93 100644
> --- a/drivers/mfd/sm501.c
> +++ b/drivers/mfd/sm501.c
> @@ -1086,8 +1086,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
>  	iounmap(gpio->regs);
>  
>   err_claimed:
> -	release_resource(gpio->regs_res);
> -	kfree(gpio->regs_res);
> +	release_mem_region(iobase, 0x20);
>  
>  	return ret;
>  }
> @@ -1095,6 +1094,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
>  static void sm501_gpio_remove(struct sm501_devdata *sm)
>  {
>  	struct sm501_gpio *gpio = &sm->gpio;
> +	resource_size_t iobase = sm->io_res->start + SM501_GPIO;

Shouldn't this be 'struct resource *'?

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: sm501: fix mismatches of request_mem_region
  2019-12-09  9:00 ` Lee Jones
@ 2019-12-09  9:09   ` Chuhong Yuan
  2019-12-09 13:13     ` Lee Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Chuhong Yuan @ 2019-12-09  9:09 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML

On Mon, Dec 9, 2019 at 5:00 PM Lee Jones <lee.jones@linaro.org> wrote:
>
> On Sat, 16 Nov 2019, Chuhong Yuan wrote:
>
> > This driver misuses release_resource + kfree to match request_mem_region,
> > which is incorrect.
> > The right way is to use release_mem_region.
> > Replace the mismatched calls with the right ones to fix it.
> >
> > Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> > ---
> >  drivers/mfd/sm501.c | 19 +++++++------------
> >  1 file changed, 7 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> > index 154270f8d8d7..e49787e6bb93 100644
> > --- a/drivers/mfd/sm501.c
> > +++ b/drivers/mfd/sm501.c
> > @@ -1086,8 +1086,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
> >       iounmap(gpio->regs);
> >
> >   err_claimed:
> > -     release_resource(gpio->regs_res);
> > -     kfree(gpio->regs_res);
> > +     release_mem_region(iobase, 0x20);
> >
> >       return ret;
> >  }
> > @@ -1095,6 +1094,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
> >  static void sm501_gpio_remove(struct sm501_devdata *sm)
> >  {
> >       struct sm501_gpio *gpio = &sm->gpio;
> > +     resource_size_t iobase = sm->io_res->start + SM501_GPIO;
>
> Shouldn't this be 'struct resource *'?
>

sm501_register_gpio() uses resource_size_t, so I use the same type in remove.

> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: sm501: fix mismatches of request_mem_region
  2019-12-09  9:09   ` Chuhong Yuan
@ 2019-12-09 13:13     ` Lee Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2019-12-09 13:13 UTC (permalink / raw)
  To: Chuhong Yuan; +Cc: LKML

On Mon, 09 Dec 2019, Chuhong Yuan wrote:

> On Mon, Dec 9, 2019 at 5:00 PM Lee Jones <lee.jones@linaro.org> wrote:
> >
> > On Sat, 16 Nov 2019, Chuhong Yuan wrote:
> >
> > > This driver misuses release_resource + kfree to match request_mem_region,
> > > which is incorrect.
> > > The right way is to use release_mem_region.
> > > Replace the mismatched calls with the right ones to fix it.
> > >
> > > Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> > > ---
> > >  drivers/mfd/sm501.c | 19 +++++++------------
> > >  1 file changed, 7 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
> > > index 154270f8d8d7..e49787e6bb93 100644
> > > --- a/drivers/mfd/sm501.c
> > > +++ b/drivers/mfd/sm501.c
> > > @@ -1086,8 +1086,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
> > >       iounmap(gpio->regs);
> > >
> > >   err_claimed:
> > > -     release_resource(gpio->regs_res);
> > > -     kfree(gpio->regs_res);
> > > +     release_mem_region(iobase, 0x20);
> > >
> > >       return ret;
> > >  }
> > > @@ -1095,6 +1094,7 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
> > >  static void sm501_gpio_remove(struct sm501_devdata *sm)
> > >  {
> > >       struct sm501_gpio *gpio = &sm->gpio;
> > > +     resource_size_t iobase = sm->io_res->start + SM501_GPIO;
> >
> > Shouldn't this be 'struct resource *'?
> 
> sm501_register_gpio() uses resource_size_t, so I use the same type in remove.

Okay.  Just for the record, there are a few things I don't like about
this patch, but seeing as it's inline with the current coding style, I
will accept it based on the fact that it would be unreasonable to ask
for the driver to be bought back into line as a prerequisite for
acceptance.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mfd: sm501: fix mismatches of request_mem_region
  2019-11-16 15:13 [PATCH] mfd: sm501: fix mismatches of request_mem_region Chuhong Yuan
  2019-12-09  9:00 ` Lee Jones
@ 2019-12-09 13:13 ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Lee Jones @ 2019-12-09 13:13 UTC (permalink / raw)
  To: Chuhong Yuan; +Cc: linux-kernel

On Sat, 16 Nov 2019, Chuhong Yuan wrote:

> This driver misuses release_resource + kfree to match request_mem_region,
> which is incorrect.
> The right way is to use release_mem_region.
> Replace the mismatched calls with the right ones to fix it.
> 
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> ---
>  drivers/mfd/sm501.c | 19 +++++++------------
>  1 file changed, 7 insertions(+), 12 deletions(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-09 13:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-16 15:13 [PATCH] mfd: sm501: fix mismatches of request_mem_region Chuhong Yuan
2019-12-09  9:00 ` Lee Jones
2019-12-09  9:09   ` Chuhong Yuan
2019-12-09 13:13     ` Lee Jones
2019-12-09 13:13 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox