From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5260F33F8A1 for ; Thu, 20 Nov 2025 13:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763645067; cv=none; b=V5Z/BoUuncOY/fVbr9A5kPQjTbmGzUWAVlrxoomTAy43Kf/s7CuTT+Hm/f3nPKx1yyA3wETjU7a8FmbNBXNOY7bhM6DJ/2BWHXdPhk2gA7VZ2rWuwFrzYSnEEbpbyGA58ocz05w4ctl5ek3keltCJcjRSfGYXgEXoOFtSn/zl4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763645067; c=relaxed/simple; bh=xH0CG842SvjgRIU9+ZvI7SWECNKFgSlkkOq1ntKdt0M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BbOuAOpGNlM5zzRGxgrftfHADK9TG7EMS4fvFIADCA5PEtuS801vkEnfmrRtNOkQ7+efY3e+npPtoX6jAXPSgs1EVRBqyVpxGMYFmWcR5CyNhuEFn/88c8absrspJXh70rskbl6SJnojlAyYeGGyG+VtIpt4T2hOinIWGdARyQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=n7B5i7X/; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="n7B5i7X/" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-47118259fd8so7366935e9.3 for ; Thu, 20 Nov 2025 05:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1763645059; x=1764249859; 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=31em30QMLEREEBSvcPXeWYIA2k37w8MVjGybg5HKctM=; b=n7B5i7X/3eNHhGxZqXrpKpn1GjBY27/y0ju9S+Vt6XarErvlB4cSNsccVOxN17Sd3J k0Xch9axtn7aX7LrZkScKKOpDxrHR6J0SubxZO5n1TcdxbKZ9tuA7Kh/Yc+0jsPkBNJu ULy6gFze72EEreznjeT+neDJEnO+D0xQJ0tCIJ5qlFUNw482GFTFL2ELmeV3oCDsgYoi dXMMSH7Z8tqN96zt3JmaC+ZejUyZWFifA0a0+wScOlGAoGWcr06Z7JZoQ6V45Kdr9Vle 3/Nb4qUF4ekL/iqTmjQnf0ImCaM0MC5o+ZBwooxYCIoeXCgeyP+K061Ygm0hzHpvp1Pg NJCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763645059; x=1764249859; 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=31em30QMLEREEBSvcPXeWYIA2k37w8MVjGybg5HKctM=; b=p36UfUHg0UsauH2eYgyFRf6+lRKvdYkrBbtJish/lOnMDHASKz3Xy/ILKQ5mXp4cE2 ygepBOVku6N3NlYQa64uKLkPx3Ne2SbVLSoK6jGNe+qdOP++O7aWn0u43afT2LrdubKV 1XWbY1EagLF3rmFbeVDbz42LZ4f0SP477hKK3i0BnNpY+Ej6Rc/mfzwW+YjOsaAVx948 XPkV4hJxFu9WFMXwGRjjlB8lFk0r/AyqMRcaEqi4n0Q8LwxyQovb/n9NSR6/f3lDBzVW Q6yqSdM2Jx33GzB9Onr5DNA0s7vD0Yd0I6rxkKwPZGYu1c3bGOlP+pwbbsTSs0kUtDac ZgTA== X-Gm-Message-State: AOJu0YxOUBYA006+JUr9krNU1zhnebzY2I27DJAufPISMuSIAhsLiOq5 WnA6VQ0vm2zaoc5bXyexf4M3kjwX3JfB79grjkHjsyTascwqpfOYImJ19ex+Tj27Qpk= X-Gm-Gg: ASbGncvwcYRdL1OxQGods5K0s0f1kvnFCEtErJKOsGEnVu18vshCVgr4FVEaBnvr7Qz c/Q13YbUAlf79xh632Y7l9IlfbByaqY+Rui5Fkg1kIn6GraLPcnQp1j2n0Yl2jZaDZpwzJCvd9u 2H5rqYLhTMilJT6YyWEoxA5Wc1ET/jKyjR9DD2+FnyGCUFF0SIuHGq+JsTaStH02+vLQpj2UAZl 4ydsiB/xtlo9u2fL2KPSvMMnSPLQIgHF+a18YD0FXTcUMTRZd/QQ6q415GEQDlXR0B61P4XJVg3 hTMMFJAW64bWrMFvzp2RpubudYPfcnauMfyHJ+Nwdvz4iUhzhodLwy8599cQNjsTOt5DVe95e2g QqJjJpSy1OeEkqzmaFie8h+Rr4PkU+TbBwg7pDm2EF7sJY7Mha6Guelc2wC64zKtnFifd9rl4Ht aOJDQ= X-Google-Smtp-Source: AGHT+IEXecxg5QFk63mFO+FspplntioJsgDc9pqGDG5H5xEPtvWbefQmM8ZTCVargBiZYfg5G09reA== X-Received: by 2002:a05:600c:190a:b0:477:9a28:b0a4 with SMTP id 5b1f17b1804b1-477b8355eb2mr41764215e9.0.1763645059186; Thu, 20 Nov 2025 05:24:19 -0800 (PST) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:37af:6c1f:28a:47d2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-477b82cc72dsm46762935e9.1.2025.11.20.05.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 05:24:18 -0800 (PST) From: Bartosz Golaszewski Date: Thu, 20 Nov 2025 14:24:02 +0100 Subject: [PATCH v7 7/9] reset: make the provider of reset-gpios the parent of the reset device Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251120-reset-gpios-swnodes-v7-7-a100493a0f4b@linaro.org> References: <20251120-reset-gpios-swnodes-v7-0-a100493a0f4b@linaro.org> In-Reply-To: <20251120-reset-gpios-swnodes-v7-0-a100493a0f4b@linaro.org> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Philipp Zabel , Krzysztof Kozlowski , David Rhodes , Richard Fitzgerald , Mark Brown , Maciej Strozek , Charles Keepax , Andy Shevchenko , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-sound@vger.kernel.org, patches@opensource.cirrus.com, linux-spi@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3115; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=FhmNonzpYHgRFKsuekRiAhccBMXMP9k+uDJyjRxj7Ok=; b=owEBbQKS/ZANAwAKAQWdLsv/NoTDAcsmYgBpHxZ0WP52PZD2bEnzAEa+WWNWxyYU1nUOtyWS3 5400vW/PNuJAjMEAAEKAB0WIQSR5RMt5bVGHXuiZfwFnS7L/zaEwwUCaR8WdAAKCRAFnS7L/zaE w64nEACk3w/L1UOykoTfQ3nBiRV3xyrul9xLO6AQmJmsiY+ds+Z45OaQA15VzYrkrdLmHsxBCcT f8Y08HLZVsZIqYf0YKV4TLBoJQnRuPgVzlm8QfTwfCO1Kduf7wBpYReJGZMAcxooiQ4BG4wRBhZ UoK0BywjWsQ5tVX4qPMEq3GEv5zMhWtTb0QPu+Qc2vVlVJQmDdWOM/k54i2BMFIumG1JRR+FVKB MNU17clQQMnheah2PUyjSLOk26dFvneF1HjrzHQA4P0qtPP5m+ZCIfq8028gVPsolO1PRizrVyQ Td22bMHRYIkYKgBmf+uF09oel9NESSJjzSkJbwI/IcsrKWZadc0i2MertOTGI4ijwiq3n8IyFm2 h+yrmIr9sY0RhMu3ZeKB+mzMJolfmLnTODbxi/A0Tabc51JmWE2B1jDxCa3Emundby0RuFUd6sT OujPW6uxgVGB2y7jiA5JX3jkqwNOHLAWUIS2lbwavf5Sl8X15EH3lZRjADMQtJd5gcRFTbAX9/o LJflkD5hVZM++f8eGkWaNWDa8qG7nGO8wXr9v2NaOjmAc80vhehqOrE8MoEASmuzfIjB88adXMK QRQhuTu4RQGIEqsEEhXoI9aPY2TOM0TBBjQLWqszgO9Ue6Q7hz4h3uw/FRlP5bJZmz9NtLXsrHJ zat+pdXbwPhYV5Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Auxiliary devices really do need a parent so ahead of converting the reset-gpios driver to registering on the auxiliary bus, make the GPIO device that provides the reset GPIO the parent of the reset-gpio device. To that end move the lookup of the GPIO device by fwnode to the beginning of __reset_add_reset_gpio_device() which has the added benefit of bailing out earlier, before allocating resources for the virtual device, if the chip is not up yet. Reviewed-by: Philipp Zabel Acked-by: Linus Walleij Acked-by: Greg Kroah-Hartman Signed-off-by: Bartosz Golaszewski --- drivers/reset/core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 5b6f314bdbdde84a1cf613fbf70ae39cbb5e20e2..50ff078dea7fd84d59e505fc1f607f593ec6381f 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -819,11 +819,11 @@ static void __reset_control_put_internal(struct reset_control *rstc) kref_put(&rstc->refcnt, __reset_control_release); } -static int __reset_add_reset_gpio_lookup(int id, struct device_node *np, +static int __reset_add_reset_gpio_lookup(struct gpio_device *gdev, int id, + struct device_node *np, unsigned int gpio, unsigned int of_flags) { - const struct fwnode_handle *fwnode = of_fwnode_handle(np); unsigned int lookup_flags; const char *label_tmp; @@ -838,10 +838,6 @@ static int __reset_add_reset_gpio_lookup(int id, struct device_node *np, return -EINVAL; } - struct gpio_device *gdev __free(gpio_device_put) = gpio_device_find_by_fwnode(fwnode); - if (!gdev) - return -EPROBE_DEFER; - label_tmp = gpio_device_get_label(gdev); if (!label_tmp) return -EINVAL; @@ -896,6 +892,11 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) */ lockdep_assert_not_held(&reset_list_mutex); + struct gpio_device *gdev __free(gpio_device_put) = + gpio_device_find_by_fwnode(of_fwnode_handle(args->np)); + if (!gdev) + return -EPROBE_DEFER; + guard(mutex)(&reset_gpio_lookup_mutex); list_for_each_entry(rgpio_dev, &reset_gpio_lookup_list, list) { @@ -916,7 +917,7 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) goto err_ida_free; } - ret = __reset_add_reset_gpio_lookup(id, args->np, args->args[0], + ret = __reset_add_reset_gpio_lookup(gdev, id, args->np, args->args[0], args->args[1]); if (ret < 0) goto err_kfree; @@ -928,7 +929,8 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args) * Hold reference as long as rgpio_dev memory is valid. */ of_node_get(rgpio_dev->of_args.np); - pdev = platform_device_register_data(NULL, "reset-gpio", id, + pdev = platform_device_register_data(gpio_device_to_device(gdev), + "reset-gpio", id, &rgpio_dev->of_args, sizeof(rgpio_dev->of_args)); ret = PTR_ERR_OR_ZERO(pdev); -- 2.51.0