* [PATCH] staging: mt7621-pinctrl: Remove space after cast
@ 2019-01-23 16:31 Nishad Kamdar
2019-01-23 17:45 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Nishad Kamdar @ 2019-01-23 16:31 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: NeilBrown, Matthias Brugger, Sergio Paracuellos, Kees Cook,
John Crispin, devel, linux-arm-kernel, linux-mediatek,
linux-kernel, Nishad Kamdar
This patch removes space after a cast as it
is not needed.
Issue found by checkpatch.
Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
---
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index 80e7067cfb79..3e959fa73703 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -363,7 +363,7 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
}
range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL);
- range->name = name = (char *) &range[1];
+ range->name = name = (char *)&range[1];
sprintf(name, "pio");
range->npins = __be32_to_cpu(*ngpio);
range->base = __be32_to_cpu(*gpiobase);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: mt7621-pinctrl: Remove space after cast
2019-01-23 16:31 [PATCH] staging: mt7621-pinctrl: Remove space after cast Nishad Kamdar
@ 2019-01-23 17:45 ` Joe Perches
2019-01-25 15:17 ` Nishad Kamdar
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2019-01-23 17:45 UTC (permalink / raw)
To: Nishad Kamdar, Greg Kroah-Hartman
Cc: NeilBrown, Matthias Brugger, Sergio Paracuellos, Kees Cook,
John Crispin, devel, linux-arm-kernel, linux-mediatek,
linux-kernel
On Wed, 2019-01-23 at 22:01 +0530, Nishad Kamdar wrote:
> This patch removes space after a cast as it
> is not needed.
> Issue found by checkpatch.
>
> Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
> ---
> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> index 80e7067cfb79..3e959fa73703 100644
> --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> @@ -363,7 +363,7 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
> }
>
> range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL);
> - range->name = name = (char *) &range[1];
> + range->name = name = (char *)&range[1];
> sprintf(name, "pio");
I find this code unsightly and fragile.
It doesn't test the return of devm_kzalloc for failure.
This might as well be
---
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index 80e7067cfb79..9b52d44abef1 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -350,7 +350,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") {
const __be32 *ngpio, *gpiobase;
struct pinctrl_gpio_range *range;
- char *name;
if (!of_device_is_available(np))
continue;
@@ -362,9 +361,10 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
return -EINVAL;
}
- range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL);
- range->name = name = (char *) &range[1];
- sprintf(name, "pio");
+ range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL);
+ if (!range)
+ return -ENOMEM;
+ range->name = "pio";
range->npins = __be32_to_cpu(*ngpio);
range->base = __be32_to_cpu(*gpiobase);
range->pin_base = range->base;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: mt7621-pinctrl: Remove space after cast
2019-01-23 17:45 ` Joe Perches
@ 2019-01-25 15:17 ` Nishad Kamdar
0 siblings, 0 replies; 3+ messages in thread
From: Nishad Kamdar @ 2019-01-25 15:17 UTC (permalink / raw)
To: Joe Perches
Cc: NeilBrown, Matthias Brugger, Sergio Paracuellos, Kees Cook,
John Crispin, devel, linux-arm-kernel, linux-mediatek,
linux-kernel, Greg Kroah-Hartman
On Wed, Jan 23, 2019 at 09:45:53AM -0800, Joe Perches wrote:
> On Wed, 2019-01-23 at 22:01 +0530, Nishad Kamdar wrote:
> > This patch removes space after a cast as it
> > is not needed.
> > Issue found by checkpatch.
> >
> > Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
> > ---
> > drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > index 80e7067cfb79..3e959fa73703 100644
> > --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> > @@ -363,7 +363,7 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
> > }
> >
> > range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL);
> > - range->name = name = (char *) &range[1];
> > + range->name = name = (char *)&range[1];
> > sprintf(name, "pio");
>
> I find this code unsightly and fragile.
> It doesn't test the return of devm_kzalloc for failure.
>
> This might as well be
> ---
> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> index 80e7067cfb79..9b52d44abef1 100644
> --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> @@ -350,7 +350,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
> for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") {
> const __be32 *ngpio, *gpiobase;
> struct pinctrl_gpio_range *range;
> - char *name;
>
> if (!of_device_is_available(np))
> continue;
> @@ -362,9 +361,10 @@ static int rt2880_pinmux_probe(struct platform_device *pdev)
> return -EINVAL;
> }
>
> - range = devm_kzalloc(p->dev, sizeof(*range) + 4, GFP_KERNEL);
> - range->name = name = (char *) &range[1];
> - sprintf(name, "pio");
> + range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL);
> + if (!range)
> + return -ENOMEM;
> + range->name = "pio";
> range->npins = __be32_to_cpu(*ngpio);
> range->base = __be32_to_cpu(*gpiobase);
> range->pin_base = range->base;
>
>
>
Ok, I'll include it as a new patch as I think this one has already been
accepted.
Thanks for the review.
Regards,
Nishad
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-25 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23 16:31 [PATCH] staging: mt7621-pinctrl: Remove space after cast Nishad Kamdar
2019-01-23 17:45 ` Joe Perches
2019-01-25 15:17 ` Nishad Kamdar
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).