Commit e4ba07bf authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Linus Walleij

gpio: mockup: code shrink

Moving a couple of lines around allows us to shrink the code a bit
while keeping the same functionality.
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ca409160
...@@ -92,7 +92,6 @@ static int gpio_mockup_add(struct device *dev, ...@@ -92,7 +92,6 @@ static int gpio_mockup_add(struct device *dev,
const char *name, int base, int ngpio) const char *name, int base, int ngpio)
{ {
struct gpio_chip *gc = &chip->gc; struct gpio_chip *gc = &chip->gc;
int ret;
gc->base = base; gc->base = base;
gc->ngpio = ngpio; gc->ngpio = ngpio;
...@@ -107,21 +106,10 @@ static int gpio_mockup_add(struct device *dev, ...@@ -107,21 +106,10 @@ static int gpio_mockup_add(struct device *dev,
chip->lines = devm_kzalloc(dev, sizeof(*chip->lines) * gc->ngpio, chip->lines = devm_kzalloc(dev, sizeof(*chip->lines) * gc->ngpio,
GFP_KERNEL); GFP_KERNEL);
if (!chip->lines) { if (!chip->lines)
ret = -ENOMEM; return -ENOMEM;
goto err;
}
ret = devm_gpiochip_add_data(dev, &chip->gc, chip);
if (ret)
goto err;
dev_info(dev, "gpio<%d..%d> add successful!", base, base + ngpio);
return 0;
err: return devm_gpiochip_add_data(dev, &chip->gc, chip);
dev_err(dev, "gpio<%d..%d> add failed!", base, base + ngpio);
return ret;
} }
static int gpio_mockup_probe(struct platform_device *pdev) static int gpio_mockup_probe(struct platform_device *pdev)
...@@ -164,15 +152,14 @@ static int gpio_mockup_probe(struct platform_device *pdev) ...@@ -164,15 +152,14 @@ static int gpio_mockup_probe(struct platform_device *pdev)
} }
if (ret) { if (ret) {
if (base < 0) dev_err(dev, "gpio<%d..%d> add failed\n",
dev_err(dev, "gpio<%d..%d> add failed\n", base, base < 0 ? ngpio : base + ngpio);
base, ngpio);
else
dev_err(dev, "gpio<%d..%d> add failed\n",
base, base + ngpio);
return ret; return ret;
} }
dev_info(dev, "gpio<%d..%d> add successful!",
base, base + ngpio);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment