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

gpio: syscon: do not report bogus error

Do not issue "can't read the data register offset!" when gpio,syscon-dev
is not set albeit unneeded. gpio-syscon is used with rk3328 chip, but
this iomem region is documented in
Documentation/devicetree/bindings/gpio/rockchip,rk3328-grf-gpio.yaml and
does not require gpio,syscon-dev setting.

Signed-off-by: Etienne Buira <etienne.buira@free.fr>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/Zktwd4Y8zu6XSGaE@Z926fQmE5jqhFMgp6
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Etienne Buira and committed by
Bartosz Golaszewski
ca09ce25 e4608bbc

+16 -11
+16 -11
drivers/gpio/gpio-syscon.c
··· 208 208 struct syscon_gpio_priv *priv; 209 209 struct device_node *np = dev->of_node; 210 210 int ret; 211 + bool use_parent_regmap = false; 211 212 212 213 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 213 214 if (!priv) ··· 217 216 priv->data = of_device_get_match_data(dev); 218 217 219 218 priv->syscon = syscon_regmap_lookup_by_phandle(np, "gpio,syscon-dev"); 220 - if (IS_ERR(priv->syscon) && np->parent) 219 + if (IS_ERR(priv->syscon) && np->parent) { 221 220 priv->syscon = syscon_node_to_regmap(np->parent); 221 + use_parent_regmap = true; 222 + } 222 223 if (IS_ERR(priv->syscon)) 223 224 return PTR_ERR(priv->syscon); 224 225 225 - ret = of_property_read_u32_index(np, "gpio,syscon-dev", 1, 226 - &priv->dreg_offset); 227 - if (ret) 228 - dev_err(dev, "can't read the data register offset!\n"); 226 + if (!use_parent_regmap) { 227 + ret = of_property_read_u32_index(np, "gpio,syscon-dev", 1, 228 + &priv->dreg_offset); 229 + if (ret) 230 + dev_err(dev, "can't read the data register offset!\n"); 229 231 230 - priv->dreg_offset <<= 3; 232 + priv->dreg_offset <<= 3; 231 233 232 - ret = of_property_read_u32_index(np, "gpio,syscon-dev", 2, 233 - &priv->dir_reg_offset); 234 - if (ret) 235 - dev_dbg(dev, "can't read the dir register offset!\n"); 234 + ret = of_property_read_u32_index(np, "gpio,syscon-dev", 2, 235 + &priv->dir_reg_offset); 236 + if (ret) 237 + dev_dbg(dev, "can't read the dir register offset!\n"); 236 238 237 - priv->dir_reg_offset <<= 3; 239 + priv->dir_reg_offset <<= 3; 240 + } 238 241 239 242 priv->chip.parent = dev; 240 243 priv->chip.owner = THIS_MODULE;