From nobody Mon Feb 9 00:31:11 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF77717DFE7 for ; Mon, 5 Jan 2026 14:16:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767622569; cv=none; b=LRXW/L9QuIRQGU3fFE+FpGKv6lDDbkoLvyJB0MQVnXG5qNbQWvvBtTnUnjJSIBqrFn5m/F493GkYYLFcRpf+pjFqNEFzV9akZ5978LpbD9f4xWCAv4Fw3idONZuTF//S3YxOMovUcmXrsQ2oXjJoyKQLw6Npo5OS1Ds+G6IuKUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767622569; c=relaxed/simple; bh=xNW/rBF6v8gJiP8mr+QmeWgvap8QGFLJIXuErBmXIPk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=emUeu54eUAUKWH/180X1FKDbMhUM36cqiOSNMyJkpROU/oD+tKvf6mBIYSw5bsTMQO/uwXBCQ/gzDNjtJEAzT/09/vZHEBe/2t1zpRjVod9gmaeyFQqL5kh6R+Y8gZjwIBtLvEDw5v+Q4D83TO1Wl2xG2RuXNZMDu9MvQypkSkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=O/vWWWfi; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=NmFpmLXG; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="O/vWWWfi"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="NmFpmLXG" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6058LDv53684516 for ; Mon, 5 Jan 2026 14:16:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Olhx4ltTdN32Pv6Wp/cHcKEI98UY9I/iwG2k5PztNvo=; b=O/vWWWfibxadwnGt uCOxh/AG9ueVjF/tUmSc6sIXFyLUmmNDe65MgQTzEtdYDwiZhQ5WePQ0aRh4uQlw FOnmi2P7hxEYoBOe1hY8VcjQk4eItb3SPVfoRmH7rwfjz2qqtJzRx3ONcBno2T/E 6yA55w8hoLZu86x4M1bGVkMht7GKYjplV0svU1wAA40bSmdwgcMfMdexIhDNEVGL KtcIKfnpKdAgmB6d2jdBK+6d4WXMdIurpKAcpQsRgbpTwoMiPISyQuXkAxhGDRbL plPEcZIT5G+rNlHjXoXdqwGtNU+OwzrwHP76YbTzDLDvvM1Vv4+MOnOjpG2/rD8g W3GSsw== Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bet2qvwha-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 05 Jan 2026 14:16:06 +0000 (GMT) Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-55b16794625so11398939e0c.2 for ; Mon, 05 Jan 2026 06:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1767622565; x=1768227365; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Olhx4ltTdN32Pv6Wp/cHcKEI98UY9I/iwG2k5PztNvo=; b=NmFpmLXG0B+mhrwDZtZmEmNZ8/xQ/tWSfnQqQoZlzD+3TN9T+Ut7b7BSl+gz2sxbs3 vKt7+5YTDpYdcWzen8omlyZp4uni/mn21WLnqmtjo72h80fzPPQIhQRzT0cDSybX0T/H mNFMrfifiKbhrRJBUngseN+5X+57nGD1AwH5vpBN3m3nVLiu4vLg+5XrwoIdJNjcsXXE CiFmTYMilfhtWoXCGZ4rB95pPR4tRsRjbgdHzuProA7KO2mXXA3GxLgKPbXZ00nout/p lxV+SxOi7H7bJEEQcNAXiMMAXn9wzN06Yele2QrtkNWcykRt6ERzIJJ997sZRdAz1RyR BvZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767622565; x=1768227365; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Olhx4ltTdN32Pv6Wp/cHcKEI98UY9I/iwG2k5PztNvo=; b=VqTTOTuxVAD66IvZgOZghDn3QjxHxfdmVLAVJVvjdMGXyiQOgZphORII3yZ1YDfZEG 4xFcWyBVDjt7B5ErAupGFRg9XUoVvywvVHVj++nv1AjbMP7opqV40djZke2rFSV6kO4G +wOKg6TgQ/9KMwoQ3N74J3/vnbtYZhPmyR10Ypg3wrcVwYhTWGHBwTaJY82kvIYdAxVT zd3kqjzTN8aQVPbaXouErMtSwcpcif1bTLqvt6LZjXpYkS84U9VI7QNPLiAoq9BVHXE8 8y27V/lVezfpu5KJt4ei71UzF+L2hHbW8HkZUxYONpVgXUa4RHQTuC6Gp3rcQGYRvYLX 4z5w== X-Gm-Message-State: AOJu0YyYcZg/zdj6y2DP8yaiYOs2DtiM1kntJrVsx6iGu+8ZAJZYEWEH P4CpfYnGM/s8jetsGyI0vhQ4SY7hsxZI2LPdF14oxINuZV9W4Th33xJiB0QqDd6dtgSGUR8jJkq NCymCJ4R2Bfv+Znt9JAtHqUaHc9lmdXuLtyF2Znv4Pza+KKrOXohuGOi2WASPgQpeaBs= X-Gm-Gg: AY/fxX5I3mqCrFlOfVKT9feyCmBF78YSgJqhxNHFemPoGuH9AvRPgupRb8W/D+8Xbmw bYwEv27Zp7WbpFhQrAqgAWCrquRg4w0Gm+WRpMK82LaFG3Hx+LCOh0oR+FwPXW/BxIv7g2WiTDo qiucrztWKlPwLCNp7Dlo8vQ2xbBYaELMmj/nB0rWBaCbm8kY0ZmyohX3q2aRdFhH9UXHYnjz/Zo T8wddX6912lPTRbRUPs2r5PmbJfxgzWloGeToZNi2rcQdkLh4lIs3X8BclLWeZbhE4+X649WNf8 z6ZWMOcvMo0zXC/5En8sF677emcwFrbRJ171+WNVoL1tY9pR4yXYymb8y7eDzXsyJytTdH0VFDy 6JHwiW/IDfxwO3nIs3RruWOY4OFacO/LxulZ5aPg= X-Received: by 2002:a05:6122:2a42:b0:559:5ef5:b196 with SMTP id 71dfb90a1353d-5615be937d8mr13192401e0c.13.1767622565306; Mon, 05 Jan 2026 06:16:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGDHzD04KGWG7AVS+mYE+sUgh5bn28HPYsc2WBrfY1vSImZAsiSYgP968/bEv4zuBgqABw+g== X-Received: by 2002:a05:6122:2a42:b0:559:5ef5:b196 with SMTP id 71dfb90a1353d-5615be937d8mr13192361e0c.13.1767622564668; Mon, 05 Jan 2026 06:16:04 -0800 (PST) Received: from brgl-qcom.local ([2a01:cb1d:dc:7e00:dd3b:c635:dd06:9574]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4324ea1aef7sm100774703f8f.7.2026.01.05.06.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 06:16:04 -0800 (PST) From: Bartosz Golaszewski Date: Mon, 05 Jan 2026 15:15:21 +0100 Subject: [PATCH 02/15] reset: gpio: add a devlink between reset-gpio and its consumer Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260105-reset-core-refactor-v1-2-ac443103498d@oss.qualcomm.com> References: <20260105-reset-core-refactor-v1-0-ac443103498d@oss.qualcomm.com> In-Reply-To: <20260105-reset-core-refactor-v1-0-ac443103498d@oss.qualcomm.com> To: Krzysztof Kozlowski , Philipp Zabel Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6008; i=bartosz.golaszewski@oss.qualcomm.com; h=from:subject:message-id; bh=xNW/rBF6v8gJiP8mr+QmeWgvap8QGFLJIXuErBmXIPk=; b=owEBbQKS/ZANAwAKAQWdLsv/NoTDAcsmYgBpW8eVM/1n5hIT0L8Y5B3wTM+kKYgudSwEoB1s9 fxlWGGUAgmJAjMEAAEKAB0WIQSR5RMt5bVGHXuiZfwFnS7L/zaEwwUCaVvHlQAKCRAFnS7L/zaE wzpZD/40DcijlhGmP2k//1WfcaMMgDQrRql9V0Dd6DrQW077bVBtberYUgMNGDCjoHtgqX6VZEg JwH0d9ImJ6UxPYCTpj6foiaIgbWjR7xzks2qdzN1tREnlW5wW0V235cgOATw7hcHLu2f+8g31h3 0sXkb3N+DYOVZ+FxgNCxdqcMWPVY2qh9EenQzihiCvQnzaGMMJwfkM/yJdX8JdXzDBkGpfvhWwn rZT104XQ5DZTQU/GjHEZ8SbkoPAm+DXXheRgn8bRuC+MMHY+b3qpcPP+JeWHT6CeuzBAqz+EHip IdwdfUjrupqiZW4DGv3AWL592cJsgF1gbx8/SgfDQ67Xy4hr05f6TH+LhL75QwfrWipP5Tj16mm ykUxGVelb3k3VWTKxqQtQKUJacBg3MNIBtD+6OxaKTulZ8IOlCOqW08/uRxFx+TDh7CYVwzhANF H7f6810eNb30W9vNRHzRG+yegfaus7xoXHwWG58QxzAPhfBg0A9zLBDpF8zWWojbdW5GxOJQnFM wLp+Qi+pFNOBRQL81MDTPLFkWusWSoQCL9ucyMpfdrMuYhwsfBbcOyVcmHq2pLo2C7sxa6oeL/n /FfoDPsW2ZpN97inWn9z5IX+hBiNNYYjxJwuCSsAlOLkHCcl7Q9FeOUl/5laBPyYwCZYuo8YTJG 83ONx/SL/kwar5g== X-Developer-Key: i=bartosz.golaszewski@oss.qualcomm.com; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 X-Proofpoint-GUID: nlSsJy7sgWvzI1OOogngfTfJwA3ys8Wn X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA1MDEyNSBTYWx0ZWRfX0TYxipcLgzGn qEYkNX/eexakFI/8wveHjlOHJjoN2vZcYapeZBN0V//L6VEpmhAOe/n1FjYdbnxVqLt2jaxT1Gv vjM6gUbPlMe2h6GkyMGP8ombFwG6/94n2gFBX6M4f2WyAdSN/TOYsKrh8BEcTq5iq7TAEM6a/Yn 8GNlXWCCiz/ZuC6yfHYM12whdk3UV/VmCnIamlDsdm+KyS5OsjcQI2QUnC9lVNVfDTyqZ+mioyl 7RIx4HLMwFZ6BCpTQrw0R0mfrIxPnIEBs1uNeumagmvhFDtzt1je0IstZtdLzgQDlEJsmHfRTLh E0/c1Fca6Pg9EsFBYoX0olljav0jo3q67n3f9jjGO4pTubgoDiSVGo09izfz8+wqBX1ve5Wb/fX vGv92t15l+HCZDj10iZEYbwVW2P1EQVRDwdglNr5U7G2p9Q3n5z6a+wlJeKjKdYz8kSqyEBDlHl sXnfQURDLQzr0diKHtA== X-Authority-Analysis: v=2.4 cv=RKK+3oi+ c=1 sm=1 tr=0 ts=695bc7a6 cx=c_pps a=JIY1xp/sjQ9K5JH4t62bdg==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=gl4R_IGdbvU1KyCt79YA:9 a=QEXdDO2ut3YA:10 a=tNoRWFLymzeba-QzToBc:22 X-Proofpoint-ORIG-GUID: nlSsJy7sgWvzI1OOogngfTfJwA3ys8Wn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-05_01,2026-01-05_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2601050125 The device that requests the reset control managed by the reset-gpio device is effectively its consumer but the devlink is only established between it and the GPIO controller exposing the reset pin. Add a devlink between the consumer of the reset control and its supplier. This will allow us to simplify the GPIOLIB code managing shared GPIOs when handling the corner case of reset-gpio and gpiolib-shared interacting. While at it and since we need to store the address of the auxiliary device: don't allocate memory for the device separately but fold it into struct reset_gpio_lookup instead. Signed-off-by: Bartosz Golaszewski Reviewed-by: Philipp Zabel --- drivers/reset/core.c | 80 ++++++++++++++++++++++++++++++++++++------------= ---- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 0666dfc41ca9af6fbf1768f17157b4faf7849962..813b85cb2758e129c72c09267a3= 87108d7ad683b 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -77,11 +78,13 @@ struct reset_control_array { * @of_args: phandle to the reset controller with all the args like GPIO n= umber * @swnode: Software node containing the reference to the GPIO provider * @list: list entry for the reset_gpio_lookup_list + * @adev: Auxiliary device representing the reset controller */ struct reset_gpio_lookup { struct of_phandle_args of_args; struct fwnode_handle *swnode; struct list_head list; + struct auxiliary_device adev; }; =20 static const char *rcdev_name(struct reset_controller_dev *rcdev) @@ -824,49 +827,72 @@ static void __reset_control_put_internal(struct reset= _control *rstc) =20 static void reset_gpio_aux_device_release(struct device *dev) { - struct auxiliary_device *adev =3D to_auxiliary_dev(dev); =20 - kfree(adev); } =20 -static int reset_add_gpio_aux_device(struct device *parent, - struct fwnode_handle *swnode, - int id, void *pdata) +static int reset_create_gpio_aux_device(struct reset_gpio_lookup *rgpio_de= v, + struct device *parent, int id) { - struct auxiliary_device *adev; + struct auxiliary_device *adev =3D &rgpio_dev->adev; int ret; =20 - adev =3D kzalloc(sizeof(*adev), GFP_KERNEL); - if (!adev) - return -ENOMEM; - adev->id =3D id; adev->name =3D "gpio"; adev->dev.parent =3D parent; - adev->dev.platform_data =3D pdata; + adev->dev.platform_data =3D &rgpio_dev->of_args; adev->dev.release =3D reset_gpio_aux_device_release; - device_set_node(&adev->dev, swnode); + device_set_node(&adev->dev, rgpio_dev->swnode); =20 ret =3D auxiliary_device_init(adev); - if (ret) { - kfree(adev); + if (ret) return ret; - } =20 ret =3D __auxiliary_device_add(adev, "reset"); if (ret) { auxiliary_device_uninit(adev); - kfree(adev); return ret; } =20 - return ret; + return 0; +} + +static void reset_gpio_add_devlink(struct device_node *np, + struct reset_gpio_lookup *rgpio_dev) +{ + struct device *consumer; + + /* + * We must use get_dev_from_fwnode() and not of_find_device_by_node() + * because the latter only considers the platform bus while we want to + * get consumers of any kind that can be associated with firmware + * nodes: auxiliary, soundwire, etc. + */ + consumer =3D get_dev_from_fwnode(of_fwnode_handle(np)); + if (consumer) { + if (!device_link_add(consumer, &rgpio_dev->adev.dev, + DL_FLAG_AUTOREMOVE_CONSUMER)) + pr_warn("Failed to create a device link between reset-gpio and its cons= umer"); + + put_device(consumer); + } + /* + * else { } + * + * TODO: If ever there's a case where we need to support shared + * reset-gpios retrieved from a device node for which there's no + * device present yet, this is where we'd set up a notifier waiting + * for the device to appear in the system. This would be a lot of code + * that would go unused for now so let's cross that bridge when and if + * we get there. + */ } =20 /* - * @args: phandle to the GPIO provider with all the args like GPIO number + * @np: OF-node associated with the consumer + * @args: phandle to the GPIO provider with all the args like GPIO number */ -static int __reset_add_reset_gpio_device(const struct of_phandle_args *arg= s) +static int __reset_add_reset_gpio_device(struct device_node *np, + const struct of_phandle_args *args) { struct property_entry properties[3] =3D { }; unsigned int offset, of_flags, lflags; @@ -916,8 +942,14 @@ static int __reset_add_reset_gpio_device(const struct = of_phandle_args *args) =20 list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) { if (args->np =3D=3D rgpio_dev->of_args.np) { - if (of_phandle_args_equal(args, &rgpio_dev->of_args)) - return 0; /* Already on the list, done */ + if (of_phandle_args_equal(args, &rgpio_dev->of_args)) { + /* + * Already on the list, create the device link + * and stop here. + */ + reset_gpio_add_devlink(np, rgpio_dev); + return 0; + } } } =20 @@ -951,11 +983,11 @@ static int __reset_add_reset_gpio_device(const struct= of_phandle_args *args) goto err_put_of_node; } =20 - ret =3D reset_add_gpio_aux_device(parent, rgpio_dev->swnode, id, - &rgpio_dev->of_args); + ret =3D reset_create_gpio_aux_device(rgpio_dev, parent, id); if (ret) goto err_del_swnode; =20 + reset_gpio_add_devlink(np, rgpio_dev); list_add(&rgpio_dev->list, &reset_gpio_lookup_list); =20 return 0; @@ -1035,7 +1067,7 @@ __of_reset_control_get(struct device_node *node, cons= t char *id, int index, =20 gpio_fallback =3D true; =20 - ret =3D __reset_add_reset_gpio_device(&args); + ret =3D __reset_add_reset_gpio_device(node, &args); if (ret) { rstc =3D ERR_PTR(ret); goto out_put; --=20 2.47.3