gpio: logicvc: use devm_platform_get_and_ioremap_resource()
PATCH 1/1 gpio: logicvc: use devm_platform_get_and_ioremap_resource()
In the regmap fallback path, replace of_address_to_resource() plus devm_ioremap_resource() with devm_platform_get_and_ioremap_resource(), which looks up the resource and maps it in one call. The helper returns a pointer to the resource, so update resource_size() to dereference it.
Drop the now-unused linux/of_address.h include; of_node is still used by syscon_node_to_regmap() and platform_get_resource() resolves the same MEM resource that of_address_to_resource(of_node, 0) did.
Built for ARM (multi_v7_defconfig + CONFIG_GPIO_LOGICVC) with LLVM=1; drivers/gpio/gpio-logicvc.o compiles cleanly.
--- drivers/gpio/gpio-logicvc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/gpio/gpio-logicvc.c +3 -10
@@ -8,7 +8,6 @@#include <linux/gpio/driver.h> #include <linux/module.h> #include <linux/of.h> -#include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/regmap.h> #include <linux/mfd/syscon.h>
@@ -102,20 +101,14 @@ static int logicvc_gpio_probe(struct platform_device *pdev)/* Grab our own regmap if that fails. */ if (IS_ERR (logicvc->regmap)) { -struct resource res; +struct resource *res;void __iomem *base; - ret =of_address_to_resource (of_node,0 , &res); -if (ret) { -dev_err (dev,"Failed to get resource from address\n" ); -return ret; - } - - base =devm_ioremap_resource (dev, &res); + base =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (base))return PTR_ERR (base); - logicvc_gpio_regmap_config.max_register =resource_size (&res) - + logicvc_gpio_regmap_config.max_register =resource_size (res) - logicvc_gpio_regmap_config.reg_stride; logicvc->regmap =
Signature · 1 line
2.55.0
Bartosz Golaszewski
maintainerQuoted 5 lines · Rosen Penev
In the regmap fallback path, replace
of_address_to_resource()plusdevm_ioremap_resource()withdevm_platform_get_and_ioremap_resource(), which looks up the resource and maps it in one call. The helper returns a pointer to the resource, so updateresource_size()to dereference it.
Quoted 7 lines
Drop the now-unused
linux/of_address.hinclude;of_nodeis still used bysyscon_node_to_regmap()andplatform_get_resource()resolves the same MEM resource thatof_address_to_resource(of_node, 0)did.Built for ARM (
multi_v7_defconfig+CONFIG_GPIO_LOGICVC) with LLVM=1;drivers/gpio/gpio-logicvc.ocompiles cleanly.
That's interesting because I'm seeing this:
drivers/gpio/gpio-logicvc.c: In function ‘logicvc_gpio_probe’:drivers/gpio/gpio-logicvc.c:93:13: error: unused variable ‘ret’ [-Werror=unused-variable]
93 | int ret;
| ^~~
Bart