From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 15 Nov 2024 13:30:58 +0100
* Reuse existing functionality from devm_platform_ioremap_resource_byname()
instead of keeping duplicate source code.
This issue was transformed by using the Coccinelle software.
* Omit the local variable “res” which became unnecessary
with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hwmon/npcm750-pwm-fan.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/hwmon/npcm750-pwm-fan.c b/drivers/hwmon/npcm750-pwm-fan.c
index db3b551828eb..d66edb184bca 100644
--- a/drivers/hwmon/npcm750-pwm-fan.c
+++ b/drivers/hwmon/npcm750-pwm-fan.c
@@ -929,7 +929,6 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct device_node *np;
struct npcm7xx_pwm_fan_data *data;
- struct resource *res;
struct device *hwmon;
char name[20];
int ret, cnt;
@@ -948,14 +947,7 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
data->pwm_modules = data->info->pwm_max_channel / NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE;
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm");
- if (!res) {
- dev_err(dev, "pwm resource not found\n");
- return -ENODEV;
- }
-
- data->pwm_base = devm_ioremap_resource(dev, res);
- dev_dbg(dev, "pwm base resource is %pR\n", res);
+ data->pwm_base = devm_platform_ioremap_resource_byname(pdev, "pwm");
if (IS_ERR(data->pwm_base))
return PTR_ERR(data->pwm_base);
@@ -965,14 +957,7 @@ static int npcm7xx_pwm_fan_probe(struct platform_device *pdev)
return PTR_ERR(data->pwm_clk);
}
- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fan");
- if (!res) {
- dev_err(dev, "fan resource not found\n");
- return -ENODEV;
- }
-
- data->fan_base = devm_ioremap_resource(dev, res);
- dev_dbg(dev, "fan base resource is %pR\n", res);
+ data->fan_base = devm_platform_ioremap_resource_byname(pdev, "fan");
if (IS_ERR(data->fan_base))
return PTR_ERR(data->fan_base);
--
2.47.0