From nobody Fri Jul 4 20:26:09 2025 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 4bYlX23cTJz60lC0; Fri, 04 Jul 2025 20:26:10 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bYlX16ZMGz3t4Z; Fri, 04 Jul 2025 20:26:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751660769; 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=VUcVd91vdELQUi6d1Ea9V9tG5Lqi1fMc2D8eL5WFTrA=; b=rKQ9BHAetv6wUD0cdaaLwTRNH+tcKlLRrwYbW6gN0aFlwkkoAgs95MwThvwPG/cfImfsXY daNc8y2nhV6BlfC1a//9jwwrOiYFRrK2+JtxM6lCvfIP7sfHbdzpwP8DS5RRMrWbZZrA7b 5mjs1lRAkUz/KhwZe0uGDSkSgeOyC2btuWhaEUOsN8EBZdAhsPLT9UVrgIbpGpTizcno/7 Prs0rLc1nrl9vZRJ5nC3TB2PJ0Qp2W8eLsEdxVH7W3kdMMo3JQ6KLRGELfzBY8I5vHQEBj 5d+riH6hUPNmI3FmZjmOtGQBPfKwcLMBMuNnNJMxdjMSj23MalsH+y7rm8Jnsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751660769; 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=VUcVd91vdELQUi6d1Ea9V9tG5Lqi1fMc2D8eL5WFTrA=; b=NlHIwc0VQlz2+FyDWABp/cQO7zsPwpx7P6LHyA1Pp3QETGB4Zy4PoA3qxLLNo/FSoimVA7 S52y4Mx+LdcS73MLnViqKzmyTzmogEKsOpCQeNTw4HdvN5NEfRAWiu2ouy+il1atnkZ/yz epueyCagP5f5UAttIA3H2iVbYB7OuoAjsQU4ZP8xZWDxa5Es9HQytMDab6rISJzEG7hJMz INp1cakuE2p9oxWsCdqWlKEjgunFemXQ376ox/eoR9m8dQKnLmlE31CtJ9cNmeVk3GG1Pw Uzrn9uPxLFuT0KB6AnOT9y2UB9czcA8GlKRNRRyBbVwDlrMQ9c9q3saANkQt4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751660769; a=rsa-sha256; cv=none; b=GZtIavnzRO1YAjBWoT6mmbX9lF/4EhY3s55nxl3b0HGjoh5Naftb+Z62e6L6z/0NK/Kuxe NhduG77J9UAc4xxw/+cyy9nTP9Agw+BHHnzx0jXpZb2XlIdThxVRe9SM2M55PMom1zYzSI amBo/e/+mx+wLMm7GwZlBckyOCK+UxgXc/wb1Jwp20GKrKcr2Vlu/wJoQGWC/dp+GY4eWF ZlzclMPaxi+Y2GFpeLM5F8ilnpE4cF28JtQI2FAL4LMoDCOemMD7W44TxaQhlwyliV6FFu BkoN2qq40SnFlvWQhGjgfKKalQN+KYC3AeyLhlBiGiGmQA73nH0sZUvKoOgF+Q== 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 4bYlX15sswz155y; Fri, 04 Jul 2025 20:26:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 564KQ9BZ096865; Fri, 4 Jul 2025 20:26:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 564KQ9to096862; Fri, 4 Jul 2025 20:26:09 GMT (envelope-from git) Date: Fri, 4 Jul 2025 20:26:09 GMT Message-Id: <202507042026.564KQ9to096862@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ahmad Khalifa Subject: git: 4a21713278a8 - main - gpiobus: add gpio_pin_acquire 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vexeduxr X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a21713278a865906e853b69357cf59a379df93a Auto-Submitted: auto-generated The branch main has been updated by vexeduxr: URL: https://cgit.FreeBSD.org/src/commit/?id=4a21713278a865906e853b69357cf59a379df93a commit 4a21713278a865906e853b69357cf59a379df93a Author: Ahmad Khalifa AuthorDate: 2025-07-04 20:03:04 +0000 Commit: Ahmad Khalifa CommitDate: 2025-07-04 20:24:31 +0000 gpiobus: add gpio_pin_acquire In some cases, drivers may need to acquire an existing gpio_pin_t. With the functions gpiobus currently exposes, this isn't possible as they allocate a new pin then acquire that. Add a new gpio_pin_acquire function which accepts an existing gpiobus_pin structure. Reviewed by: mmel, imp Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50869 --- sys/dev/gpio/gpiobus.c | 22 ++++++++++++++++++++++ sys/dev/gpio/gpiobusvar.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index c28fac66115b..84980f3d6546 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -213,6 +213,28 @@ gpio_pin_is_active(gpio_pin_t pin, bool *active) return (0); } +/* + * Note that this function should only + * be used in cases where a pre-existing + * gpiobus_pin structure exists. In most + * cases, the gpio_pin_get_by_* functions + * suffice. + */ +int +gpio_pin_acquire(gpio_pin_t gpio) +{ + device_t busdev; + + KASSERT(gpio != NULL, ("GPIO pin is NULL.")); + KASSERT(gpio->dev != NULL, ("GPIO pin device is NULL.")); + + busdev = GPIO_GET_BUS(gpio->dev); + if (busdev == NULL) + return (ENXIO); + + return (gpiobus_acquire_pin(busdev, gpio->pin)); +} + void gpio_pin_release(gpio_pin_t gpio) { diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h index 975788e84a83..972e1f196399 100644 --- a/sys/dev/gpio/gpiobusvar.h +++ b/sys/dev/gpio/gpiobusvar.h @@ -156,6 +156,8 @@ int gpio_pin_get_by_bus_pinnum(device_t _bus, uint32_t _pinnum, gpio_pin_t *_gp) /* Acquire a pin by child and index (used by direct children of gpiobus). */ int gpio_pin_get_by_child_index(device_t _child, uint32_t _idx, gpio_pin_t *_gp); +/* Acquire a pin from an existing gpio_pin_t. */ +int gpio_pin_acquire(gpio_pin_t gpio); /* Release a pin acquired via any gpio_pin_get_xxx() function. */ void gpio_pin_release(gpio_pin_t gpio);