From nobody Sat Nov 27 08:49:53 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D992918BAC8F; Sat, 27 Nov 2021 08:49:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J1QKY2f6Bz4hRF; Sat, 27 Nov 2021 08:49:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 20CF318FBE; Sat, 27 Nov 2021 08:49:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AR8nrQC070281; Sat, 27 Nov 2021 08:49:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AR8nrMW070279; Sat, 27 Nov 2021 08:49:53 GMT (envelope-from git) Date: Sat, 27 Nov 2021 08:49:53 GMT Message-Id: <202111270849.1AR8nrMW070279@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: f537b3056421 - stable/13 - icee: allow configuration via hints on FDT-based systems List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f537b30564210708cea309de6e2ba54cf18e52b1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638002993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mZNH44f0XUujf0WpiZEdVAmTvWw9VsPXtGMKUVidLdU=; b=o9ydl/L9jMX4UTnkuU9nCl8D4PDNVH9Y/0jMxugF+Ug40IdgV/uk8V3+WWGas7r528wJAO IKswLO7mMBo0jIFnyLnprgf164dUiQqL513bku5uPI8Pb+xjUfbZ9AFyIwJufoVfY5aZj6 z6V0b6+m5v+EhHSCv375y+zbFIjUjh82+YypAdISFqk5wo62MRpJ0YxzHkWGpGYw4cgSIk PKXHlAoDmCSxwyiiMH32lvYO3lq04Tk/jUyW2nXbGecn0VeG2tWQE23KYDHuVRQ3grBhaD FOwITXN3yQzvF2/6c/muCdGC7HhbceQX2KjWotSeUa8Ns0s1Zzllylw6slp8mw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638002993; a=rsa-sha256; cv=none; b=nd9ECiah28uQpWWj/RlvSOKThXUSCi+EsDytLQr/9a0gI9Sfv0goQKbYV2CZtGGMIs7sn/ EDcTdbgo+AsXWvt3biKdn6t33z0SvA/uLw9HoeAfSNB1yZW5de+n9eJRTPS+i5zMAQtDEO k2nih8S418Z2zciBxFW/7J4sVXNQvRWqArh8kFGpMx0ClC2/btdQw9T3HGEgZj7Dzr2QsX HPIMFrEuSH41mQC6YSA2ds+yPlswuVzxtlkoMxfTsibE+rVILRc7Xy4SK78UGPt5desaEh a5GBkv/Z8hIzaBO1l+DkrV1D5++LoVj+kgj+q3a5i0OvQjHu+cbfyyGj5t2hKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=f537b30564210708cea309de6e2ba54cf18e52b1 commit f537b30564210708cea309de6e2ba54cf18e52b1 Author: Andriy Gapon AuthorDate: 2021-11-04 11:56:22 +0000 Commit: Andriy Gapon CommitDate: 2021-11-27 08:47:25 +0000 icee: allow configuration via hints on FDT-based systems On-board devices should be configured via the FDT and overlays. Hints are primarily useful for external and temporarily attached devices. Adding hints is much easier and faster than writing and compiling an overlay. (cherry picked from commit 01e3492337cb48484e03be38340cc67ac5e30a5b) --- sys/dev/iicbus/icee.c | 64 +++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/sys/dev/iicbus/icee.c b/sys/dev/iicbus/icee.c index 19aff78bf45a..a658d73cb875 100644 --- a/sys/dev/iicbus/icee.c +++ b/sys/dev/iicbus/icee.c @@ -123,10 +123,10 @@ static struct cdevsw icee_cdevsw = .d_write = icee_write }; -#ifdef FDT static int icee_probe(device_t dev) { +#ifdef FDT struct eeprom_desc *d; if (!ofw_bus_status_okay(dev)) @@ -134,49 +134,42 @@ icee_probe(device_t dev) d = (struct eeprom_desc *) ofw_bus_search_compatible(dev, compat_data)->ocd_data; - if (d == NULL) - return (ENXIO); - - device_set_desc(dev, d->name); - return (BUS_PROBE_DEFAULT); -} - -static void -icee_init(struct icee_softc *sc) -{ - struct eeprom_desc *d; - - d = (struct eeprom_desc *) - ofw_bus_search_compatible(sc->dev, compat_data)->ocd_data; - if (d == NULL) - return; /* attach will see sc->size == 0 and return error */ - - sc->size = d->size; - sc->type = d->type; - sc->wr_sz = d->wr_sz; -} -#else /* !FDT */ -static int -icee_probe(device_t dev) -{ - + if (d != NULL) { + device_set_desc(dev, d->name); + return (BUS_PROBE_DEFAULT); + } +#endif device_set_desc(dev, "I2C EEPROM"); return (BUS_PROBE_NOWILDCARD); } -static void +static int icee_init(struct icee_softc *sc) { const char *dname; int dunit; +#ifdef FDT + struct eeprom_desc *d; + d = (struct eeprom_desc *) + ofw_bus_search_compatible(sc->dev, compat_data)->ocd_data; + if (d != NULL) { + sc->size = d->size; + sc->type = d->type; + sc->wr_sz = d->wr_sz; + return (0); + } +#endif dname = device_get_name(sc->dev); dunit = device_get_unit(sc->dev); - resource_int_value(dname, dunit, "size", &sc->size); - resource_int_value(dname, dunit, "type", &sc->type); - resource_int_value(dname, dunit, "wr_sz", &sc->wr_sz); + if (resource_int_value(dname, dunit, "type", &sc->type) != 0) + return (ENOENT); + if (resource_int_value(dname, dunit, "size", &sc->size) != 0) + return (ENOENT); + if (resource_int_value(dname, dunit, "wr_sz", &sc->wr_sz) != 0) + return (ENOENT); + return (0); } -#endif /* FDT */ static int icee_attach(device_t dev) @@ -187,13 +180,8 @@ icee_attach(device_t dev) sc->dev = dev; sc->addr = iicbus_get_addr(dev); - icee_init(sc); - if (sc->size == 0 || sc->type == 0 || sc->wr_sz == 0) { - device_printf(sc->dev, "Missing config data, " - "these cannot be zero: size %d type %d wr_sz %d\n", - sc->size, sc->type, sc->wr_sz); + if (icee_init(sc) != 0) return (EINVAL); - } if (bootverbose) device_printf(dev, "size: %d bytes, addressing: %d-bits\n", sc->size, sc->type);