| Message ID | 20261104215959.24035-6-rosenp@gmail.com |
|---|---|
| State | New |
| Headers | show |
| Series | gpio: ppc44x: assorted cleanups | expand |
On Wed, Nov 04, 2026 at 01:59:59PM -0800, Rosen Penev wrote: > Remove some unused includes that are not used directly. > > While at it: > - use devm_kzalloc_obj() for the chip allocation > - rename the platform_device from ofdev to the conventional pdev > - compact the OF match table > - move module_platform_driver() next to the driver struct > > No functional change. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > --- > drivers/gpio/gpio-ppc44x.c | 20 ++++++-------------- > 1 file changed, 6 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c > index 8b9ea00f170c..04653e753d43 100644 > --- a/drivers/gpio/gpio-ppc44x.c > +++ b/drivers/gpio/gpio-ppc44x.c > @@ -10,13 +10,8 @@ > */ > > #include <linux/bits.h> > -#include <linux/kernel.h> > -#include <linux/init.h> > #include <linux/io.h> > -#include <linux/of.h> > #include <linux/gpio/generic.h> > -#include <linux/types.h> > -#include <linux/slab.h> > #include <linux/platform_device.h> > > /* Pins are numbered from the MSB; the select registers use 2 bits per pin */ > @@ -139,20 +134,20 @@ ppc44x_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) > return 0; > } > > -static int ppc44x_gpio_probe(struct platform_device *ofdev) > +static int ppc44x_gpio_probe(struct platform_device *pdev) > { > - struct device *dev = &ofdev->dev; > + struct device *dev = &pdev->dev; > struct ppc44x_gpio __iomem *regs; > struct ppc44x_gpio_chip *chip; > struct gpio_generic_chip_config config; > struct gpio_chip *gc; > int ret; > > - regs = devm_platform_ioremap_resource(ofdev, 0); > + regs = devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(regs)) > return PTR_ERR(regs); > > - chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); > + chip = devm_kzalloc_obj(dev, *chip); > if (!chip) > return -ENOMEM; > > @@ -180,9 +175,7 @@ static int ppc44x_gpio_probe(struct platform_device *ofdev) > } > > static const struct of_device_id ppc44x_gpio_match[] = { > - { > - .compatible = "ibm,ppc4xx-gpio", > - }, > + { .compatible = "ibm,ppc4xx-gpio" }, > {}, Uwe: is this in line with your recent cleanups? Bart
Hello Bart, On 2026-11-09 10:01, Bartosz Golaszewski wrote: >> static const struct of_device_id ppc44x_gpio_match[] = { >> - { >> - .compatible = "ibm,ppc4xx-gpio", >> - }, >> + { .compatible = "ibm,ppc4xx-gpio" }, >> {}, > > Uwe: is this in line with your recent cleanups? The change is fine, I'd appreciate to also do - {}, + { } at the same time. Best regards Uwe
On Mon, Nov 9, 2026 at 3:30 AM Uwe Kleine-König <ukleinek@kernel.org> wrote: > > Hello Bart, > > On 2026-11-09 10:01, Bartosz Golaszewski wrote: > >> static const struct of_device_id ppc44x_gpio_match[] = { > >> - { > >> - .compatible = "ibm,ppc4xx-gpio", > >> - }, > >> + { .compatible = "ibm,ppc4xx-gpio" }, > >> {}, > > > > Uwe: is this in line with your recent cleanups? > The change is fine, I'd appreciate to also do > > - {}, > + { } > > at the same time. {} was done by clang-format IIRC. > > Best regards > Uwe
On Mon, Nov 09, 2026 at 12:46:13PM -0800, Rosen Penev wrote: > On Mon, Nov 9, 2026 at 3:30 AM Uwe Kleine-König <ukleinek@kernel.org> wrote: > > > > Hello Bart, > > > > On 2026-11-09 10:01, Bartosz Golaszewski wrote: > > >> static const struct of_device_id ppc44x_gpio_match[] = { > > >> - { > > >> - .compatible = "ibm,ppc4xx-gpio", > > >> - }, > > >> + { .compatible = "ibm,ppc4xx-gpio" }, > > >> {}, > > > > > > Uwe: is this in line with your recent cleanups? > > The change is fine, I'd appreciate to also do > > > > - {}, > > + { } > > > > at the same time. > {} was done by clang-format IIRC. I saw that already, too. I'd argue that clang-format is wrong here, with non-empty initializers we want a space after the opening brance and before the closing one. Last time I looked (and IIRC), the kernel intended to still work with an old version of clang-format and that doesn't distinguish between a space between { } and ( ). For the latter we don't want a space, so there is no way to configure clang-format to do the right thing. That's better with newer clang-format versions, but I didn't find a way to specify { } and () without breaking older clang-format. Best regards Uwe
On Mon, Nov 09, 2026 at 12:46:13PM -0800, Rosen Penev wrote: > On Mon, Nov 9, 2026 at 3:30 AM Uwe Kleine-König <ukleinek@kernel.org> wrote: > > > > Hello Bart, > > > > On 2026-11-09 10:01, Bartosz Golaszewski wrote: > > >> static const struct of_device_id ppc44x_gpio_match[] = { > > >> - { > > >> - .compatible = "ibm,ppc4xx-gpio", > > >> - }, > > >> + { .compatible = "ibm,ppc4xx-gpio" }, > > >> {}, > > > > > > Uwe: is this in line with your recent cleanups? > > The change is fine, I'd appreciate to also do > > > > - {}, > > + { } > > > > at the same time. > {} was done by clang-format IIRC. Uwe: you may want to update .clang-format if you care about this bit. Bart
diff --git a/drivers/gpio/gpio-ppc44x.c b/drivers/gpio/gpio-ppc44x.c index 8b9ea00f170c..04653e753d43 100644 --- a/drivers/gpio/gpio-ppc44x.c +++ b/drivers/gpio/gpio-ppc44x.c @@ -10,13 +10,8 @@ */ #include <linux/bits.h> -#include <linux/kernel.h> -#include <linux/init.h> #include <linux/io.h> -#include <linux/of.h> #include <linux/gpio/generic.h> -#include <linux/types.h> -#include <linux/slab.h> #include <linux/platform_device.h> /* Pins are numbered from the MSB; the select registers use 2 bits per pin */ @@ -139,20 +134,20 @@ ppc44x_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) return 0; } -static int ppc44x_gpio_probe(struct platform_device *ofdev) +static int ppc44x_gpio_probe(struct platform_device *pdev) { - struct device *dev = &ofdev->dev; + struct device *dev = &pdev->dev; struct ppc44x_gpio __iomem *regs; struct ppc44x_gpio_chip *chip; struct gpio_generic_chip_config config; struct gpio_chip *gc; int ret; - regs = devm_platform_ioremap_resource(ofdev, 0); + regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) return PTR_ERR(regs); - chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); + chip = devm_kzalloc_obj(dev, *chip); if (!chip) return -ENOMEM; @@ -180,9 +175,7 @@ static int ppc44x_gpio_probe(struct platform_device *ofdev) } static const struct of_device_id ppc44x_gpio_match[] = { - { - .compatible = "ibm,ppc4xx-gpio", - }, + { .compatible = "ibm,ppc4xx-gpio" }, {}, }; MODULE_DEVICE_TABLE(of, ppc44x_gpio_match); @@ -194,8 +187,7 @@ static struct platform_driver ppc44x_gpio_driver = { .of_match_table = ppc44x_gpio_match, }, }; +module_platform_driver(ppc44x_gpio_driver); MODULE_DESCRIPTION("PPC44x gpio driver"); MODULE_LICENSE("GPL"); - -module_platform_driver(ppc44x_gpio_driver);
Remove some unused includes that are not used directly. While at it: - use devm_kzalloc_obj() for the chip allocation - rename the platform_device from ofdev to the conventional pdev - compact the OF match table - move module_platform_driver() next to the driver struct No functional change. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- drivers/gpio/gpio-ppc44x.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)