gpio: xilinx: drop dependency on GPIO_OF
Subsystems (3)
PATCH 1/3 gpio: xilinx: drop dependency on GPIO_OF
From: Bartosz Golaszewski <[email protected]>
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
--- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/gpio/Kconfig +0 -1
@@ -796,7 +796,6 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" select GPIOLIB_IRQCHIP - depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device.
Signature · 1 line
2.43.0
PATCH 2/3 gpio: xilinx: use helper variable to store the address of pdev->dev
From: Bartosz Golaszewski <[email protected]>
For better readability don't repeatedly dereference pdev->dev but instead store the address of the embedded struct device in a local variable in probe().
--- drivers/gpio/gpio-xilinx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/gpio/gpio-xilinx.c +17 -17
@@ -561,9 +561,10 @@ static const struct irq_chip xgpio_irq_chip = {*/ static int xgpio_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct xgpio_instance *chip;int status =0 ; -struct device_node *np = pdev->dev.of_node; +struct device_node *np = dev->of_node;u32 is_dual =0 ;u32 width[2 ];u32 state[2 ];
@@ -571,7 +572,7 @@ static int xgpio_probe(struct platform_device *pdev)struct gpio_irq_chip *girq;u32 temp; - chip =devm_kzalloc (&pdev->dev,sizeof (*chip),GFP_KERNEL ); + chip =devm_kzalloc (dev,sizeof (*chip),GFP_KERNEL );if (!chip)return -ENOMEM ;
@@ -624,7 +625,7 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base =-1 ; chip->gc.ngpio =bitmap_weight (chip->hw_map,64 ); - chip->gc.parent = &pdev->dev; + chip->gc.parent = dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out; chip->gc.get = xgpio_get;
@@ -633,21 +634,21 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.free = xgpio_free; chip->gc.set_multiple = xgpio_set_multiple; - chip->gc.label =dev_name (&pdev->dev); + chip->gc.label =dev_name (dev); chip->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (chip->regs)) { -dev_err (&pdev->dev,"failed to ioremap memory resource\n" ); +dev_err (dev,"failed to ioremap memory resource\n" );return PTR_ERR (chip->regs); } - chip->clk =devm_clk_get_optional_enabled (&pdev->dev,NULL ); + chip->clk =devm_clk_get_optional_enabled (dev,NULL );if (IS_ERR (chip->clk)) -return dev_err_probe (&pdev->dev,PTR_ERR (chip->clk),"input clock not found.\n" ); +return dev_err_probe (dev,PTR_ERR (chip->clk),"input clock not found.\n" ); -pm_runtime_get_noresume (&pdev->dev); -pm_runtime_set_active (&pdev->dev); -pm_runtime_enable (&pdev->dev); +pm_runtime_get_noresume (dev); +pm_runtime_set_active (dev); +pm_runtime_enable (dev);xgpio_save_regs (chip);
@@ -667,8 +668,7 @@ static int xgpio_probe(struct platform_device *pdev)gpio_irq_chip_set_chip (girq, &xgpio_irq_chip); girq->parent_handler = xgpio_irqhandler; girq->num_parents =1 ; - girq->parents =devm_kcalloc (&pdev->dev,1 , -sizeof (*girq->parents), + girq->parents =devm_kcalloc (dev,1 ,sizeof (*girq->parents),GFP_KERNEL );if (!girq->parents) { status = -ENOMEM ;
@@ -679,18 +679,18 @@ static int xgpio_probe(struct platform_device *pdev) girq->handler = handle_bad_irq; skip_irq: - status =devm_gpiochip_add_data (&pdev->dev, &chip->gc, chip); + status =devm_gpiochip_add_data (dev, &chip->gc, chip);if (status) { -dev_err (&pdev->dev,"failed to add GPIO chip\n" ); +dev_err (dev,"failed to add GPIO chip\n" ); goto err_pm_put; } -pm_runtime_put (&pdev->dev); +pm_runtime_put (dev);return 0 ; err_pm_put: -pm_runtime_disable (&pdev->dev); -pm_runtime_put_noidle (&pdev->dev); +pm_runtime_disable (dev); +pm_runtime_put_noidle (dev);return status; }
Signature · 1 line
2.43.0
PATCH 3/3 gpio: xilinx: use generic device properties
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
OF-specific routines should not be used unless necessary. Generic device properties are preferred so switch to using them in the driver code.
--- drivers/gpio/gpio-xilinx.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpio/gpio-xilinx.c +7 -9
@@ -15,7 +15,6 @@#include <linux/io.h> #include <linux/irq.h> #include <linux/module.h> -#include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/slab.h>
@@ -564,7 +563,6 @@ static int xgpio_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct xgpio_instance *chip;int status =0 ; -struct device_node *np = dev->of_node;u32 is_dual =0 ;u32 width[2 ];u32 state[2 ];
@@ -579,7 +577,7 @@ static int xgpio_probe(struct platform_device *pdev)platform_set_drvdata (pdev, chip);/* First, check if the device is dual-channel */ -of_property_read_u32 (np,"xlnx,is-dual" , &is_dual); +device_property_read_u32 (dev,"xlnx,is-dual" , &is_dual);/* Setup defaults */ memset32 (width,0 ,ARRAY_SIZE (width));
@@ -587,14 +585,14 @@ static int xgpio_probe(struct platform_device *pdev)memset32 (dir,0xFFFFFFFF ,ARRAY_SIZE (dir));/* Update GPIO state shadow register with default value */ -of_property_read_u32 (np,"xlnx,dout-default" , &state[0 ]); -of_property_read_u32 (np,"xlnx,dout-default-2" , &state[1 ]); +device_property_read_u32 (dev,"xlnx,dout-default" , &state[0 ]); +device_property_read_u32 (dev,"xlnx,dout-default-2" , &state[1 ]);bitmap_from_arr32 (chip->state, state,64 );/* Update GPIO direction shadow register with default value */ -of_property_read_u32 (np,"xlnx,tri-default" , &dir[0 ]); -of_property_read_u32 (np,"xlnx,tri-default-2" , &dir[1 ]); +device_property_read_u32 (dev,"xlnx,tri-default" , &dir[0 ]); +device_property_read_u32 (dev,"xlnx,tri-default-2" , &dir[1 ]);bitmap_from_arr32 (chip->dir, dir,64 );
@@ -602,13 +600,13 @@ static int xgpio_probe(struct platform_device *pdev)* Check device node and parent device node for device width * and assume default width of 32 */ -if (of_property_read_u32 (np,"xlnx,gpio-width" , &width[0 ])) +if (device_property_read_u32 (dev,"xlnx,gpio-width" , &width[0 ])) width[0 ] =32 ;if (width[0 ] >32 )return -EINVAL ; -if (is_dual &&of_property_read_u32 (np,"xlnx,gpio2-width" , &width[1 ])) +if (is_dual &&device_property_read_u32 (dev,"xlnx,gpio2-width" , &width[1 ])) width[1 ] =32 ;if (width[1 ] >32 )
Signature · 1 line
2.43.0
Re: [PATCH 2/3] gpio: xilinx: use helper variable to store the address of pdev->dev
In reply to Bartosz GolaszewskiQuoted 98 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
For better readability don't repeatedly dereference
pdev->devbut instead store the address of the embedded struct device in a local variable inprobe().Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpio-xilinx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)drivers/gpio/gpio-xilinx.c +15
-15@@ -561,9 +561,10 @@ static const struct irq_chip xgpio_irq_chip = {*/ static int xgpio_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct xgpio_instance *chip;int status =0 ; -struct device_node *np = pdev->dev.of_node; +struct device_node *np = dev->of_node;u32 is_dual =0 ;u32 width[2 ];u32 state[2 ];@@ -571,7 +572,7 @@ static int xgpio_probe(struct platform_device *pdev)struct gpio_irq_chip *girq;u32 temp; - chip =devm_kzalloc (&pdev->dev,sizeof (*chip),GFP_KERNEL ); + chip =devm_kzalloc (dev,sizeof (*chip),GFP_KERNEL );if (!chip)return -ENOMEM ;@@ -624,7 +625,7 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.base =-1 ; chip->gc.ngpio =bitmap_weight (chip->hw_map,64 ); - chip->gc.parent = &pdev->dev; + chip->gc.parent = dev; chip->gc.direction_input = xgpio_dir_in; chip->gc.direction_output = xgpio_dir_out; chip->gc.get = xgpio_get;@@ -633,21 +634,21 @@ static int xgpio_probe(struct platform_device *pdev) chip->gc.free = xgpio_free; chip->gc.set_multiple = xgpio_set_multiple; - chip->gc.label =dev_name (&pdev->dev); + chip->gc.label =dev_name (dev); chip->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (chip->regs)) { -dev_err (&pdev->dev,"failed to ioremap memory resource\n" ); +dev_err (dev,"failed to ioremap memory resource\n" );return PTR_ERR (chip->regs); } - chip->clk =devm_clk_get_optional_enabled (&pdev->dev,NULL ); + chip->clk =devm_clk_get_optional_enabled (dev,NULL );if (IS_ERR (chip->clk)) -return dev_err_probe (&pdev->dev,PTR_ERR (chip->clk),"input clock not found.\n" ); +return dev_err_probe (dev,PTR_ERR (chip->clk),"input clock not found.\n" ); -pm_runtime_get_noresume (&pdev->dev); -pm_runtime_set_active (&pdev->dev); -pm_runtime_enable (&pdev->dev); +pm_runtime_get_noresume (dev); +pm_runtime_set_active (dev); +pm_runtime_enable (dev);xgpio_save_regs (chip);@@ -667,8 +668,7 @@ static int xgpio_probe(struct platform_device *pdev)gpio_irq_chip_set_chip (girq, &xgpio_irq_chip); girq->parent_handler = xgpio_irqhandler; girq->num_parents =1 ; - girq->parents =devm_kcalloc (&pdev->dev,1 , -sizeof (*girq->parents), + girq->parents =devm_kcalloc (dev,1 ,sizeof (*girq->parents),GFP_KERNEL );if (!girq->parents) { status = -ENOMEM ;@@ -679,18 +679,18 @@ static int xgpio_probe(struct platform_device *pdev) girq->handler = handle_bad_irq; skip_irq: - status =devm_gpiochip_add_data (&pdev->dev, &chip->gc, chip); + status =devm_gpiochip_add_data (dev, &chip->gc, chip);if (status) { -dev_err (&pdev->dev,"failed to add GPIO chip\n" ); +dev_err (dev,"failed to add GPIO chip\n" ); goto err_pm_put; } -pm_runtime_put (&pdev->dev); +pm_runtime_put (dev);
drivers/gpio/gpio-xilinx.c static int xgpio_probe(struct platform_device *pdev) · line 696
Quoted 10 lines
drivers/gpio/gpio-xilinx.c +2
-2return 0 ; err_pm_put: -pm_runtime_disable (&pdev->dev); -pm_runtime_put_noidle (&pdev->dev); +pm_runtime_disable (dev); +pm_runtime_put_noidle (dev);return status; }
make sense.
Thanks,
Michal
Re: [PATCH 3/3] gpio: xilinx: use generic device properties
In reply to Bartosz GolaszewskiQuoted 64 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
OF-specific routines should not be used unless necessary. Generic device properties are preferred so switch to using them in the driver code.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/gpio-xilinx.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)drivers/gpio/gpio-xilinx.c +6
-8@@ -15,7 +15,6 @@#include <linux/io.h> #include <linux/irq.h> #include <linux/module.h> -#include <linux/of.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/slab.h> @@ -564,7 +563,6 @@ static int xgpio_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct xgpio_instance *chip;int status =0 ; -struct device_node *np = dev->of_node;u32 is_dual =0 ;u32 width[2 ];u32 state[2 ];@@ -579,7 +577,7 @@ static int xgpio_probe(struct platform_device *pdev)platform_set_drvdata (pdev, chip);/* First, check if the device is dual-channel */ -of_property_read_u32 (np,"xlnx,is-dual" , &is_dual); +device_property_read_u32 (dev,"xlnx,is-dual" , &is_dual);/* Setup defaults */ memset32 (width,0 ,ARRAY_SIZE (width));@@ -587,14 +585,14 @@ static int xgpio_probe(struct platform_device *pdev)memset32 (dir,0xFFFFFFFF ,ARRAY_SIZE (dir));/* Update GPIO state shadow register with default value */ -of_property_read_u32 (np,"xlnx,dout-default" , &state[0 ]); -of_property_read_u32 (np,"xlnx,dout-default-2" , &state[1 ]); +device_property_read_u32 (dev,"xlnx,dout-default" , &state[0 ]); +device_property_read_u32 (dev,"xlnx,dout-default-2" , &state[1 ]);bitmap_from_arr32 (chip->state, state,64 );/* Update GPIO direction shadow register with default value */ -of_property_read_u32 (np,"xlnx,tri-default" , &dir[0 ]); -of_property_read_u32 (np,"xlnx,tri-default-2" , &dir[1 ]); +device_property_read_u32 (dev,"xlnx,tri-default" , &dir[0 ]); +device_property_read_u32 (dev,"xlnx,tri-default-2" , &dir[1 ]);bitmap_from_arr32 (chip->dir, dir,64 );@@ -602,13 +600,13 @@ static int xgpio_probe(struct platform_device *pdev)* Check device node and parent device node for device width * and assume default width of 32 */ -if (of_property_read_u32 (np,"xlnx,gpio-width" , &width[0 ])) +if (device_property_read_u32 (dev,"xlnx,gpio-width" , &width[0 ]))
drivers/gpio/gpio-xilinx.c static int xgpio_probe(struct platform_device *pdev) · line 612
Quoted 10 lines
drivers/gpio/gpio-xilinx.c +1
-1width[0 ] =32 ;if (width[0 ] >32 )return -EINVAL ; -if (is_dual &&of_property_read_u32 (np,"xlnx,gpio2-width" , &width[1 ])) +if (is_dual &&device_property_read_u32 (dev,"xlnx,gpio2-width" , &width[1 ])) width[1 ] =32 ;if (width[1 ] >32 )
This is also fine.
Thanks,
Michal
Quoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/gpio/Kconfig +0
-0
drivers/gpio/Kconfig config GPIO_XGENE_SB · line 801
Quoted 7 lines
drivers/gpio/Kconfig +0
-1@@ -796,7 +796,6 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" select GPIOLIB_IRQCHIP - depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device.
The patch itself is fine but it should be likely applied as last one not the first one. If this is applied like that feel free to add
Thanks,
Michal
Quoted 29 lines · Michal Simek
Quoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/gpio/Kconfig +0
-0drivers/gpio/Kconfig config GPIO_XGENE_SB · line 801
Quoted 7 lines
drivers/gpio/Kconfig +0
-1@@ -796,7 +796,6 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" select GPIOLIB_IRQCHIP - depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device.The patch itself is fine but it should be likely applied as last one not the first one.
If this is applied like that feel free to add
Quoted 2 lines
Acked-by Michal Simek <[email protected]>
I think you may be confusing CONFIG_OF with CONFIG_OF_GPIO. This driver doesn't depend at build-time on the latter and this patch can be applied right away.
Bart
Michal Simek
maintainerQuoted 30 lines · Bartosz Golaszewski
Quoted 29 lines · Michal Simek
Quoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/gpio/Kconfig +0
-0drivers/gpio/Kconfig config GPIO_XGENE_SB · line 801
Quoted 7 lines
drivers/gpio/Kconfig +0
-1@@ -796,7 +796,6 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" select GPIOLIB_IRQCHIP - depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device.The patch itself is fine but it should be likely applied as last one not the first one.
If this is applied like that feel free to add
Quoted 6 lines
Quoted 2 lines
Acked-by Michal Simek <[email protected]>I think you may be confusing
CONFIG_OFwithCONFIG_OF_GPIO. This driver doesn't depend at build-time on the latter and this patch can be applied right away.
ok then.
Thanks,
Michal
Quoted 37 lines · Michal Simek
Quoted 33 lines · Bartosz Golaszewski
Quoted 31 lines · Michal Simek
Quoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/gpio/Kconfig +0
-0drivers/gpio/Kconfig config GPIO_XGENE_SB · line 801
Quoted 7 lines
drivers/gpio/Kconfig +0
-1@@ -796,7 +796,6 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" select GPIOLIB_IRQCHIP - depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device.The patch itself is fine but it should be likely applied as last one not the first one.
If this is applied like that feel free to addAcked-by Michal Simek <[email protected]>
Quoted 9 lines
Quoted 3 lines
I think you may be confusing
CONFIG_OFwithCONFIG_OF_GPIO. This driver doesn't depend at build-time on the latter and this patch can be applied right away.ok then.
Thanks,
Michal
Now that I think about it - we should probably use of_match_ptr() once we drop this dependency though.
Bart
Re: [PATCH 2/3] gpio: xilinx: use helper variable to store the address of pdev->dev
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
For better readability don't repeatedly dereference
pdev->devbut instead store the address of the embedded struct device in a local variable inprobe().Signed-off-by Bartosz Golaszewski <[email protected]>
Yours,
Linus Walleij
Re: [PATCH 3/3] gpio: xilinx: use generic device properties
In reply to Bartosz GolaszewskiQuoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
OF-specific routines should not be used unless necessary. Generic device properties are preferred so switch to using them in the driver code.
Signed-off-by Bartosz Golaszewski <[email protected]>
Yours,
Linus Walleij
Quoted 45 lines · Bartosz Golaszewski
Quoted 43 lines · Michal Simek
Quoted 30 lines · Bartosz Golaszewski
Quoted 29 lines · Michal Simek
Quoted 15 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/gpio/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/gpio/Kconfig +0
-0drivers/gpio/Kconfig config GPIO_XGENE_SB · line 801
Quoted 7 lines
drivers/gpio/Kconfig +0
-1@@ -796,7 +796,6 @@ config GPIO_XGENE_SB config GPIO_XILINX tristate "Xilinx GPIO support" select GPIOLIB_IRQCHIP - depends on OF_GPIO help Say yes here to support the Xilinx FPGA GPIO device.The patch itself is fine but it should be likely applied as last one not the first one.
If this is applied like that feel free to addQuoted 6 lines
Quoted 2 lines
Acked-by Michal Simek <[email protected]>I think you may be confusing
CONFIG_OFwithCONFIG_OF_GPIO. This driver doesn't depend at build-time on the latter and this patch can be applied right away.ok then.
Quoted 8 lines
Quoted 3 lines
Thanks,
MichalNow that I think about it - we should probably use
of_match_ptr()once we drop this dependency though.Bart
Scratch that - that would actually require us to conditionally define the ids struct.
Bart
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 4 lines · Bartosz Golaszewski
This driver doesn't really depend on gpiolib-of being built and can be compiled without it.
Applied, thanks!
[1/3] gpio: xilinx: drop dependency on GPIO_OF
commit: e96c6de61233bfea7d0d0c32a7d539906ac23180
[2/3] gpio: xilinx: use helper variable to store the address of pdev->dev
commit: 3cc3af160be758e95c9b4008b3bf06f4a81b653f
[3/3] gpio: xilinx: use generic device properties
commit: 06c88b7ac9eed417f02cd748499b29318a9795beBest regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>