Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

watchdog: bd9576_wdt: switch to using devm_fwnode_gpiod_get()

I would like to stop exporting OF-specific devm_gpiod_get_from_of_node()
so that gpiolib can be cleaned a bit, so let's switch to the generic
fwnode property API.

While at it, switch the rest of the calls to read properties in
bd9576_wdt_probe() to the generic device property API as well.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220903-gpiod_get_from_of_node-remove-v1-10-b29adfb27a6c@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Dmitry Torokhov and committed by
Wim Van Sebroeck
4f719022 434e5f93

+31 -20
+31 -20
drivers/watchdog/bd9576_wdt.c
··· 9 9 #include <linux/gpio/consumer.h> 10 10 #include <linux/mfd/rohm-bd957x.h> 11 11 #include <linux/module.h> 12 - #include <linux/of.h> 13 12 #include <linux/platform_device.h> 13 + #include <linux/property.h> 14 14 #include <linux/regmap.h> 15 15 #include <linux/watchdog.h> 16 16 ··· 202 202 static int bd9576_wdt_probe(struct platform_device *pdev) 203 203 { 204 204 struct device *dev = &pdev->dev; 205 - struct device_node *np = dev->parent->of_node; 206 205 struct bd9576_wdt_priv *priv; 207 206 u32 hw_margin[2]; 208 207 u32 hw_margin_max = BD957X_WDT_DEFAULT_MARGIN, hw_margin_min = 0; 208 + int count; 209 209 int ret; 210 210 211 211 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ··· 221 221 return -ENODEV; 222 222 } 223 223 224 - priv->gpiod_en = devm_gpiod_get_from_of_node(dev, dev->parent->of_node, 225 - "rohm,watchdog-enable-gpios", 226 - 0, GPIOD_OUT_LOW, 227 - "watchdog-enable"); 224 + priv->gpiod_en = devm_fwnode_gpiod_get(dev, dev_fwnode(dev->parent), 225 + "rohm,watchdog-enable", 226 + GPIOD_OUT_LOW, 227 + "watchdog-enable"); 228 228 if (IS_ERR(priv->gpiod_en)) 229 229 return dev_err_probe(dev, PTR_ERR(priv->gpiod_en), 230 230 "getting watchdog-enable GPIO failed\n"); 231 231 232 - priv->gpiod_ping = devm_gpiod_get_from_of_node(dev, dev->parent->of_node, 233 - "rohm,watchdog-ping-gpios", 234 - 0, GPIOD_OUT_LOW, 235 - "watchdog-ping"); 232 + priv->gpiod_ping = devm_fwnode_gpiod_get(dev, dev_fwnode(dev->parent), 233 + "rohm,watchdog-ping", 234 + GPIOD_OUT_LOW, 235 + "watchdog-ping"); 236 236 if (IS_ERR(priv->gpiod_ping)) 237 237 return dev_err_probe(dev, PTR_ERR(priv->gpiod_ping), 238 238 "getting watchdog-ping GPIO failed\n"); 239 239 240 - ret = of_property_read_variable_u32_array(np, "rohm,hw-timeout-ms", 241 - &hw_margin[0], 1, 2); 242 - if (ret < 0 && ret != -EINVAL) 243 - return ret; 240 + count = device_property_count_u32(dev->parent, "rohm,hw-timeout-ms"); 241 + if (count < 0 && count != -EINVAL) 242 + return count; 244 243 245 - if (ret == 1) 246 - hw_margin_max = hw_margin[0]; 244 + if (count > 0) { 245 + if (count > ARRAY_SIZE(hw_margin)) 246 + return -EINVAL; 247 247 248 - if (ret == 2) { 249 - hw_margin_max = hw_margin[1]; 250 - hw_margin_min = hw_margin[0]; 248 + ret = device_property_read_u32_array(dev->parent, 249 + "rohm,hw-timeout-ms", 250 + hw_margin, count); 251 + if (ret < 0) 252 + return ret; 253 + 254 + if (count == 1) 255 + hw_margin_max = hw_margin[0]; 256 + 257 + if (count == 2) { 258 + hw_margin_max = hw_margin[1]; 259 + hw_margin_min = hw_margin[0]; 260 + } 251 261 } 252 262 253 263 ret = bd957x_set_wdt_mode(priv, hw_margin_max, hw_margin_min); 254 264 if (ret) 255 265 return ret; 256 266 257 - priv->always_running = of_property_read_bool(np, "always-running"); 267 + priv->always_running = device_property_read_bool(dev->parent, 268 + "always-running"); 258 269 259 270 watchdog_set_drvdata(&priv->wdd, priv); 260 271