From owner-svn-src-head@freebsd.org Mon Oct 2 17:20:08 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F4B1E0F277; Mon, 2 Oct 2017 17:20:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BF8C6FAFF; Mon, 2 Oct 2017 17:20:08 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v92HK7mp046516; Mon, 2 Oct 2017 17:20:07 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v92HK7oX046515; Mon, 2 Oct 2017 17:20:07 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201710021720.v92HK7oX046515@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Mon, 2 Oct 2017 17:20:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324214 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 324214 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Oct 2017 17:20:08 -0000 Author: manu Date: Mon Oct 2 17:20:07 2017 New Revision: 324214 URL: https://svnweb.freebsd.org/changeset/base/324214 Log: 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. Modified: head/sys/arm/allwinner/a10_gpio.c Modified: head/sys/arm/allwinner/a10_gpio.c ============================================================================== --- head/sys/arm/allwinner/a10_gpio.c Mon Oct 2 16:39:12 2017 (r324213) +++ head/sys/arm/allwinner/a10_gpio.c Mon Oct 2 17:20:07 2017 (r324214) @@ -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", @@ -830,6 +833,11 @@ a10_gpio_attach(device_t dev) clkp = malloc(sizeof(*clkp), M_DEVBUF, M_WAITOK | M_ZERO); 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);