@@ -599,6 +599,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
int base = gc->base;
unsigned int i;
int ret = 0;
+ u32 ngpios;
/*
* First: allocate and populate the internal stat container, and
@@ -647,9 +648,17 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
}
if (gc->ngpio == 0) {
- chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
- ret = -EINVAL;
- goto err_free_descs;
+ ret = device_property_read_u32(&gdev->dev, "ngpios", &ngpios);
+ if (ret) {
+ if (ret == -ENODATA) {
+ chip_err(gc, "tried to insert a GPIO chip with zero lines\n");
+ ret = -EINVAL;
+ }
+
+ goto err_free_descs;
+ }
+
+ gc->ngpio = ngpios;
}
if (gc->ngpio > FASTPATH_NGPIO)