From nobody Wed Feb 14 22:52:38 2024 X-Original-To: dev-commits-src-main@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 4TZtkZ3SZBz53xHy; Wed, 14 Feb 2024 22:52:38 +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 4TZtkZ2hCPz4FCn; Wed, 14 Feb 2024 22:52:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707951158; 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=gV8IRlv7muv6Wx1ee/34b7nMA12JDx0HG+dn4hkSToI=; b=Lauu+8DCV8MtbG6C923boOMC2926X6DPOIXoHQMRj8ZgcGlSAJVRz9v+NMTFxS8PiqDy2u OIyFahYUK+sA5wbhgm3kyPZR5lPhhrZT6G5luTvoQd5AfSnsA0sxwp4gqBrfUelwIvnA7D GxjT2f2iftsbrqARmsSpMvh/IlVO/LmUZ9791UbxKA8ifuFAblsdAI4jq4RY5dUdJg1VR+ ATpoZLNo8KNEnFjQLMJcU79K316RGX6dndBRpjgtZeyhXEsq9NMAKaXlbngoyjFEberv8I 5zxMesplJvxdQ1JjvcicoZ6RPdzDLh4OFDDmZImrWnnVM2sv+bMLEKODyAU+9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707951158; a=rsa-sha256; cv=none; b=dOgwRdALyJBwnKURFJw6b5LW380CqpJWHs0bsGXtX7ZURfrVgt9JgnppVktZrR4kJIsH7O nZ8nt/99Td3D9Okrx5EY2Jjg4sxiqYJJMQEq51oZpqmzVtzXvjIOAGldO6BesgtEPISqad ar6Zs+//W7G/EA7GwScUQdFBiwGsu78KYmTKqnFM6XFuzp5n8f+k9a9sMB//o1RxvSna1f S7LBqA6PtUT+5vhCuVosaqgHDtJu8xBSlzSH6imcd1/EkLIXxxjOl+QQX1suiu2ZdOaFLR VozchQOiwoyeEY9Lzx9vBk/ahiNMUvootK6yrgoB+Zv73o3kl/LZrQd7MURUkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707951158; 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=gV8IRlv7muv6Wx1ee/34b7nMA12JDx0HG+dn4hkSToI=; b=M8AWLCDrY1EsVNAqNK1VG8HWM4IWLxdPZGJTfHz1pY63Ri6ofwzG5Z/6EYyrITqnBNO17n 45Ew2hAkihE6wmNeJYXg52O61wBsOfcTozFG+0QaWv9NnAJdZg4alC0uBFZR26x7AFB+nE vDYAWThu6CRGduj298pjTC4rjGjWTgNaJ9NGTQzWISmOSQ7IjUwg0rHpHzBulq+jppmeOA DWMDkPauNBrDnLk7BGZehXCaTcrV1ijcxWKWjf0CkyekJFkrswWSaHYqinPlzuozprSjW2 35HSP3r7LEcW0T6ScSKbpOtDeojGKntY9iwJO46Drroy0NUF09kAFo1is0OSZg== 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 4TZtkZ1lVszHKd; Wed, 14 Feb 2024 22:52:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41EMqck0086074; Wed, 14 Feb 2024 22:52:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41EMqcLK086071; Wed, 14 Feb 2024 22:52:38 GMT (envelope-from git) Date: Wed, 14 Feb 2024 22:52:38 GMT Message-Id: <202402142252.41EMqcLK086071@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 5bda26333a8e - main - gpiobus: Use bus_generic_rman_* List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5bda26333a8ebf34190e3a9124895e6a18e58e93 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5bda26333a8ebf34190e3a9124895e6a18e58e93 commit 5bda26333a8ebf34190e3a9124895e6a18e58e93 Author: John Baldwin AuthorDate: 2024-02-14 22:07:32 +0000 Commit: John Baldwin CommitDate: 2024-02-14 22:07:32 +0000 gpiobus: Use bus_generic_rman_* Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43887 --- sys/dev/gpio/gpiobus.c | 57 +++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index 99d3114d51da..6d739597b759 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -809,20 +809,29 @@ gpiobus_write_ivar(device_t dev, device_t child, int which, uintptr_t value) return (0); } +static struct rman * +gpiobus_get_rman(device_t bus, int type, u_int flags) +{ + struct gpiobus_softc *sc; + + sc = device_get_softc(bus); + switch (type) { + case SYS_RES_IRQ: + return (&sc->sc_intr_rman); + default: + return (NULL); + } +} + static struct resource * gpiobus_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) { - struct gpiobus_softc *sc; - struct resource *rv; struct resource_list *rl; struct resource_list_entry *rle; int isdefault; - if (type != SYS_RES_IRQ) - return (NULL); isdefault = (RMAN_IS_DEFAULT_RANGE(start, end) && count == 1); - rle = NULL; if (isdefault) { rl = BUS_GET_RESOURCE_LIST(bus, child); if (rl == NULL) @@ -830,40 +839,12 @@ gpiobus_alloc_resource(device_t bus, device_t child, int type, int *rid, rle = resource_list_find(rl, type, *rid); if (rle == NULL) return (NULL); - if (rle->res != NULL) - panic("%s: resource entry is busy", __func__); start = rle->start; count = rle->count; end = rle->end; } - sc = device_get_softc(bus); - rv = rman_reserve_resource(&sc->sc_intr_rman, start, end, count, flags, - child); - if (rv == NULL) - return (NULL); - rman_set_rid(rv, *rid); - if ((flags & RF_ACTIVE) != 0 && - bus_activate_resource(child, type, *rid, rv) != 0) { - rman_release_resource(rv); - return (NULL); - } - - return (rv); -} - -static int -gpiobus_release_resource(device_t bus __unused, device_t child, int type, - int rid, struct resource *r) -{ - int error; - - if (rman_get_flags(r) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, r); - if (error) - return (error); - } - - return (rman_release_resource(r)); + return (bus_generic_rman_alloc_resource(bus, child, type, rid, start, + end, count, flags)); } static struct resource_list * @@ -1060,9 +1041,9 @@ static device_method_t gpiobus_methods[] = { DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_alloc_resource, gpiobus_alloc_resource), - DEVMETHOD(bus_release_resource, gpiobus_release_resource), - DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), - DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_release_resource, bus_generic_rman_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_rman_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_rman_deactivate_resource), DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list), DEVMETHOD(bus_add_child, gpiobus_add_child), DEVMETHOD(bus_rescan, gpiobus_rescan),