Allwinner GPIO: Fail if we cannot enable a clock

If we cannot enable a clock (which is required to have the device
working), do not attach the device as it will not work.
This commit is contained in:
Emmanuel Vadot 2017-10-02 17:20:07 +00:00
parent 4168a6e9f1
commit 7bc85edd15
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324214

View File

@ -775,7 +775,7 @@ a10_gpio_attach(device_t dev)
struct clk_list *clkp, *clkp_tmp;
clk_t clk;
hwreset_t rst = NULL;
int off, err;
int off, err, clkret;
sc = device_get_softc(dev);
sc->sc_dev = dev;
@ -815,12 +815,15 @@ a10_gpio_attach(device_t dev)
error = hwreset_deassert(rst);
if (error != 0) {
device_printf(dev, "cannot de-assert reset\n");
return (error);
goto fail;
}
}
TAILQ_INIT(&sc->clk_list);
for (off = 0; clk_get_by_ofw_index(dev, 0, off, &clk) == 0; off++) {
for (off = 0, clkret = 0; clkret == 0; off++) {
clkret = clk_get_by_ofw_index(dev, 0, off, &clk);
if (clkret != 0)
break;
err = clk_enable(clk);
if (err != 0) {
device_printf(dev, "Could not enable clock %s\n",
@ -831,6 +834,11 @@ a10_gpio_attach(device_t dev)
clkp->clk = clk;
TAILQ_INSERT_TAIL(&sc->clk_list, clkp, next);
}
if (clkret != 0 && clkret != ENOENT) {
device_printf(dev, "Could not find clock at offset %d (%d)\n",
off, clkret);
goto fail;
}
sc->sc_busdev = gpiobus_attach_bus(dev);
if (sc->sc_busdev == NULL)