From nobody Tue Mar 29 23:00:01 2022 X-Original-To: dev-commits-src-branches@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 E8FC91A34D02; Tue, 29 Mar 2022 23:00:01 +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 4KSlQ95LMYz4TbR; Tue, 29 Mar 2022 23:00:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648594801; 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=mA8z+YctoEMEN5UTUbqXnX0FPtxbRZO4Ew/0cHZ5Zpc=; b=MdzyBax/0RQq+1fjVnGqcl6rmEIPiEbQCaLSfaIOXHT9e1Bjmjm/MiLSgC/UrLC/a0arzQ /0wZ3RWx9Xbl1HaKzwnkjeQdPzbLkVwnW3Fq7tEHrWGc7aWWE1pZlV6Fcif0P72sUohhY/ ArHosS7rln/X0XxQ7pk3BILes4u4siDN5RjdpL+r9gD8nF5Dg8xtH21+PHXHZN6nh+HYYV xf/ekrNE5g1+xOgBJEOKgmkWPu35/7ivqJrFX/d/fseTCZIBY3kr+N387xZTpTW5Pvb4kl C6gvHlK67BXROHkzls65Vm5G+teJ2P0z/tpf93Oef98XCpk5bwKBsye7FL5+RA== 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 66B5026DF0; Tue, 29 Mar 2022 23:00:01 +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 22TN01wg052167; Tue, 29 Mar 2022 23:00:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22TN01fE052160; Tue, 29 Mar 2022 23:00:01 GMT (envelope-from git) Date: Tue, 29 Mar 2022 23:00:01 GMT Message-Id: <202203292300.22TN01fE052160@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: a2bd4cd7863c - stable/13 - bus_if: Add a default implementation of get_property List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a2bd4cd7863c2fefe4e91443b84f63468d7138c0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648594801; 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=mA8z+YctoEMEN5UTUbqXnX0FPtxbRZO4Ew/0cHZ5Zpc=; b=M+FFdZiMWp8BB+o3iwt4ZxD3Vrb8EHZt3QtHhXo+dt0RvCaZHBR4agQXR8BdMaMFftmiI/ +VXLUVo2n4QAxI3aB7lsuZttuj2u+uC4oWNFR1Az5AM5HdC06yaRTLmCi9ifEMsGGAqYeW vsg9F24/wxlsXSduLP6VgmJIk9AffTMqGhNi1rhb4bmS+0YpW99J5cunf4WqjE/OWIiMOR F2ZH7DD0ZFIjN+u4FEnmKTjeJDXC98pgINcqdSTaOb3aVvCF8VzwE3FBkiW6TnjqRGbQUG aF2Oy9O7FttxjjFZu3QpKJ6Y7etjKuYR+mPyjtPdX1t6Ouu4EPdzY+29PBdy5w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648594801; a=rsa-sha256; cv=none; b=v24uETR7G8EFJYPJZpEPCibf/dKEZbipYgyVoBPk6xK25rzh25mLlC1J5wPkZnzEvoykp4 kvzu+8HlLfieOFDNDIvMejMb6PxrXXilhtBdU+mysVux/w8tl+SvB0uPWALgYR3s6Nv94F LySR0YSuz0pg/IQ4Sd7cqGjJsVJ5SUj0Y56tgUXAgYdsiLEc6k2vN09FCIJC0UXd3ejcfn hYLdgm9UAJndiqnK+P4XhJKQMC9DJUgm2sxT+GQhtL2pKoJpbSlzfKYdIIcvV4gPk2G8tN 9E4S1PRx9mHnNj2nAz4GHamftv+tmnHjBWFzUknDWQJmRx+VQUUAngwCajXhyw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=a2bd4cd7863c2fefe4e91443b84f63468d7138c0 commit a2bd4cd7863c2fefe4e91443b84f63468d7138c0 Author: Kornel Duleba AuthorDate: 2022-01-25 10:10:55 +0000 Commit: Marcin Wojtas CommitDate: 2022-03-29 22:24:28 +0000 bus_if: Add a default implementation of get_property There are multiple buses that pretend to be ofw compatible, e.g ofw_pci, mii_fdt. We now need to provide an implementation of BUS_GET_PROPERTY for every one of them. Instead of modifying them one by one it's better to just provide a default implementation that simply traverses up the device tree. Remove the now unneeded BUS_GET_PROPERTY implementation in mii_fdt. Reviewed by: andrew, bz Obtained from: Semihalf MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D34031 (cherry picked from commit 206dc82bc3fc5e1d90200e189ce5f2240dfec874) --- sys/dev/mii/mii_fdt.c | 15 --------------- sys/kern/bus_if.m | 9 +-------- sys/kern/subr_bus.c | 17 +++++++++++++++++ sys/sys/bus.h | 3 +++ 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/sys/dev/mii/mii_fdt.c b/sys/dev/mii/mii_fdt.c index 387b02f69504..9cf3fd2fab37 100644 --- a/sys/dev/mii/mii_fdt.c +++ b/sys/dev/mii/mii_fdt.c @@ -326,20 +326,6 @@ miibus_fdt_get_devinfo(device_t bus, device_t child) return (&ma->obd); } -static ssize_t -miibus_fdt_get_property(device_t bus, device_t child, const char *propname, - void *buf, size_t size) -{ - struct mii_attach_args *ma; - - ma = device_get_ivars(child); - - if (ma->obd.obd_node == 0) - return (-1); - - return (OF_getencprop(ma->obd.obd_node, propname, buf, size)); -} - static device_method_t miibus_fdt_methods[] = { DEVMETHOD(device_probe, miibus_fdt_probe), DEVMETHOD(device_attach, miibus_fdt_attach), @@ -362,7 +348,6 @@ static device_method_t miibus_fdt_methods[] = { DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_get_resource_list, miibus_fdt_get_resource_list), - DEVMETHOD(bus_get_property, miibus_fdt_get_property), DEVMETHOD_END }; diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m index 463d3fe38872..5b6577b963ec 100644 --- a/sys/kern/bus_if.m +++ b/sys/kern/bus_if.m @@ -88,13 +88,6 @@ CODE { *newstart = start; return (0); } - - static ssize_t - null_get_property(device_t dev, device_t child, const char *propname, - void *propvalue, size_t size) - { - return (-1); - } }; /** @@ -962,4 +955,4 @@ METHOD ssize_t get_property { const char *_propname; void *_propvalue; size_t _size; -} DEFAULT null_get_property; +} DEFAULT bus_generic_get_property; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 3949e0b29220..0139eb31f976 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -4062,6 +4062,23 @@ bus_generic_write_ivar(device_t dev, device_t child, int index, return (ENOENT); } +/** + * @brief Helper function for implementing BUS_GET_PROPERTY(). + * + * This simply calls the BUS_GET_PROPERTY of the parent of dev, + * until a non-default implementation is found. + */ +ssize_t +bus_generic_get_property(device_t dev, device_t child, const char *propname, + void *propvalue, size_t size) +{ + if (device_get_parent(dev) != NULL) + return (BUS_GET_PROPERTY(device_get_parent(dev), child, + propname, propvalue, size)); + + return (-1); +} + /** * @brief Stub function for implementing BUS_GET_RESOURCE_LIST(). * diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 4c7d094c24b0..6500a283a7f5 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -441,6 +441,9 @@ bus_dma_tag_t bus_space_tag_t bus_generic_get_bus_tag(device_t dev, device_t child); int bus_generic_get_domain(device_t dev, device_t child, int *domain); +ssize_t bus_generic_get_property(device_t dev, device_t child, + const char *propname, void *propvalue, + size_t size); struct resource_list * bus_generic_get_resource_list (device_t, device_t); int bus_generic_map_resource(device_t dev, device_t child, int type,