From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 1098C3A7F70 for ; Tue, 28 Jul 2026 10:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785235900; cv=none; b=aiv59PtEol3Jwb9uYtOqPdwcWipmCpSYxsVA3jsg7Ze3+sRgrCvHc4tjQIStPuJFvfCl0+B4muABXfRgHXn3FHp2W6D6DllmMCy1/mXh8FBQmH0ZK3mSmb1TuGIEmqDNeaH975aBKEgyK5YpScw4/hlNY0ITZKwJ7ho+A/wx7J8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785235900; c=relaxed/simple; bh=uFRNW+3w9EnOK3PrrtaSrrFmRFgj9UhlYBeXgQfDtfU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VkQ3f5z7eJrESfhTIl8zZCrr0tFetmCcFDZsgQLEZ2BUIH8NbPNoi8TWcKtFnu+3587lq33y+JnLFkmXJHQzrVrnGPef9PrKL5CndnaVRJZa28VNMerg8waifVzCpJKzSB7Z9SEWT2s4z/na//HitCQgGpx26/BcXB9+qUShSeY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=XT0+OBqP; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="XT0+OBqP" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-c1f758014b8so37298766b.3 for ; Tue, 28 Jul 2026 03:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1785235895; x=1785840695; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=s0DjSdXiKBw0ZZEMZd8FTQi9iSoUjrgkZuIJH9PB0eg=; b=XT0+OBqPLlgwsZrZdZioLsy8Z13LP1eySQdC8+FRBOfn2RbaTFDEkVw/Ge/n3+efSk QIQ+O/CirVFyXuT9m5cqgDOqB1Qg+qdQE9h6vzpA55KP1qKM1Z6Ioa7bkIovCcLFKzUH aF39TY6+RG5VGy6EaTgDnBZuLAPBH/I0gqnJwYivYfQXhgokfUy3s5AtUh++xP1H7/Uv FWA+XcQMA1uKiAsHUj4sOXB44hUnk2INPOLQuXt63fWxZa7mFtdMdYn0y8ktrfE5ZAVH jqIsPRUKRnbdmBKB8lay+ibWUoEnjJXW4RE4Z4Lq3oyGNrGc7ei9pPFtMKq4hOvx2raq 0VZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785235895; x=1785840695; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=s0DjSdXiKBw0ZZEMZd8FTQi9iSoUjrgkZuIJH9PB0eg=; b=qkGsQvYbPg0UmytnY0SQhA0SwIN9D/s6l4GkQ8wqAizT27+2EAWsmyOaeHZ3Gb2YhL ygvNB7Vdt+celb6b6KM9zCtYdXapDZynBUr/wIIeHzUS5+uZL/4bFzhw+93Dutb3J3EG elvps+XtARkvAhyzWEk1DqTcReNmxKZm00IeNn1VcerhFJSweBhiHFrU+L7Q5/JuCLDL Dsl0gIKHvt3+VpOCt6JuGBoPJDGQMtVcfAo24KgKgyYQZ9KfmchTk7PA0f6iafkDGF4q 4elNh2XtNVzYJ7wwDfsqDiO+CO7su/8xvmRW9k65G7PgK7qz0o/L0RQ2Oq2/417v2x/L 71xA== X-Forwarded-Encrypted: i=1; AHgh+RrotXOI+Fkf1S1lcCnj95kK5yeVqeoV+eT/O8ME8sloxE/4qZwBKh4FPDiiJV5LfBhjYE3nBjOOUBTXCuI=@vger.kernel.org X-Gm-Message-State: AOJu0YyJUrCSZ62Ouzo45HY1EmoMHCfaNn7NWNS9OOP7ZykpXcEVP5Eg 9V3kqS2tiyhDePCpVnexHwx3Ij+4Yb9P2/6hIzxQ9e8JOI+ZEaCbKPcPNvMfeA2ZYjE= X-Gm-Gg: AR+sD11q5NMVSW5IYgyel4Tna0rpKzEpWYI0xBvMSxwz3O0gpGfbBPmgz4x89h1PDXD mpJZVY932DHP1APhztvFluX8EX2ZntuUV1WDMBI/PzrwoE/Vn63zQR+eiR7LhceuNCQznpYD/yy jcy1kuthD9SCd4L8vKgndkNuLRnnq5HWZZnPXzNdjXei2HE1t5j97RDlnmaRzJzy188rMNdhKnU 5tPVu5Gld+zTI4bSxxnfraK1EgyYKPyGYhIMn9E5V8UtkAD07cP6NBAlbtBtVYwRiI6etGdmRgx vHc6907bRXzC+6fdeDiOal+LEst9ZLmNN5nnNi6XbYeW2T1F7fAyKdWxB48oGnSOTiZC33WnhKL uGBuD5P8iJmRds46E5AGUfpg7K7TMcUTAnVbMJpMdBrUlXuteqfm+CNEMt59Cyf4QDfd53oSpfr 30QoNEKdAOooFN X-Received: by 2002:a17:906:fe43:b0:c15:ce72:9352 with SMTP id a640c23a62f3a-c1f72147fe4mr100806566b.33.1785235894410; Tue, 28 Jul 2026 03:51:34 -0700 (PDT) Received: from [192.168.0.35] ([109.77.204.94]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1c32ebc3c0sm744772166b.51.2026.07.28.03.51.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2026 03:51:33 -0700 (PDT) Message-ID: Date: Tue, 28 Jul 2026 11:51:31 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v13 2/5] phy: core: Add devm_phy_get_by_of_node() To: Dmitry Baryshkov Cc: Bjorn Andersson , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Foss , Todor Tomov , Mauro Carvalho Chehab , Konrad Dybcio , Vladimir Zapolskiy , Bryan O'Donoghue , Loic Poulain , Vinod Koul , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-phy@lists.infradead.org, Krzysztof Kozlowski References: <20260728-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v13-0-ae811e2f0799@linaro.org> <20260728-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v13-2-ae811e2f0799@linaro.org> Content-Language: en-US From: Bryan O'Donoghue In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 28/07/2026 11:46, Dmitry Baryshkov wrote: > On Tue, Jul 28, 2026 at 10:35:33AM +0100, Bryan O'Donoghue wrote: >> Add a devm variant of phy_get_by_of_node() to allow for the familiar >> pattern of having devres automatically release resources on the driver's >> exit path. >> >> Signed-off-by: Bryan O'Donoghue >> --- >> drivers/phy/phy-core.c | 34 ++++++++++++++++++++++++++++++++++ >> include/linux/phy/phy.h | 7 +++++++ >> 2 files changed, 41 insertions(+) >> >> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c >> index ebfad5325072e..7af24f2f4120f 100644 >> --- a/drivers/phy/phy-core.c >> +++ b/drivers/phy/phy-core.c >> @@ -1029,6 +1029,40 @@ struct phy *phy_get_by_of_node(struct device_node *np) >> } >> EXPORT_SYMBOL_GPL(phy_get_by_of_node); >> >> +/** >> + * devm_phy_get_by_of_node() - devm managed lookup and obtain phy reference by device node >> + * @dev: device requesting the PHY >> + * @np: device_node of the PHY provider >> + * >> + * Returns phy associated with the device_node or ERR_PTR. devres manages >> + * releasing resources. >> + */ >> +struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np) >> +{ >> + struct phy **ptr, *phy; >> + struct device_link *link; >> + >> + ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL); >> + if (!ptr) >> + return ERR_PTR(-ENOMEM); >> + >> + phy = phy_get_by_of_node(np); >> + if (IS_ERR(phy)) { >> + devres_free(ptr); >> + return phy; >> + } >> + >> + *ptr = phy; >> + devres_add(dev, ptr); >> + link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS); > Why are you adding devlink here? Looking at 987351e1ea77 ("phy: core: Add consumer device link support") - adds this link to phy_get()/devm_of_phy_get()/devm_of_phy_get_by_index() to enforce suspend/resume ordering between PHY consumer and provider. So the get_by_of_node() replicates that logic. --- bod