From patchwork Fri Feb 18 07:07:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12751005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41637C433F5 for ; Fri, 18 Feb 2022 07:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CO/KfhwGbwH9Z/eXLCsxCh8pX7RYFG0COGrwz02UbqA=; b=NsHiZEo9OJnnAa aZsqMEdShN9nRTmwFm2lolZeb3Ngw6zvChOjXci9zTjb8SWffyLm+kESmi70VGhayoO5TOTCP0WUW DjJT1GpOqsQJrBPeFTNsPJ9NQmnaBJgUwc+txy8OgaXur5rf/2z/lYK7jSTRzO0Cr3P0o0g0n/gRA g856aPIkOCuSetOPCXQxdQE4CNCU3ZYw6cbFJLf46kydekfZBJhbQ2AKsWRNRTZun23yxIvs12aml S+Ourcm1acMgifhAop+wtU043NwraOUoI7Ydi+KeYootvx7sUmFZ3M4U988gJqwuxgrXjz+b5Lrit dhc4sctWe75s5UCqxPuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxNR-00D8RG-0x; Fri, 18 Feb 2022 07:08:25 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxMw-00D8Ic-RM for linux-arm-kernel@lists.infradead.org; Fri, 18 Feb 2022 07:07:56 +0000 Received: by mail-lf1-x131.google.com with SMTP id i11so3658658lfu.3 for ; Thu, 17 Feb 2022 23:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tX9YbbK4wZDYd/1rJF+Fsl9cu8MwUvaAy3wkrzRgdck=; b=pxTGNtwoQqXXXR2NQW0yIPEwzA0QmPkCsh3TL6HrB99Tf4HSx4B99Dqicg+E+RHzC4 MHVO+WtCge/ccF+M4pDhmB+OD4gvoQIUaWPxzX5LNEvLfpsBaQVMP8fhanBREMlxHQ5E ZdNRPw0yRGsymvyZkIp1f+lCFpsngd3NFTe7zgypaZr8kw1W8gcuioLuvcbUG/YW02Vg Gisz5pm04fQLQuetkLKo5JcrTCmFE08MjcSuSeRa3UDe8sOu+okvGvlfJJc9FkH8OQRW qUBLmGNGZGFsQc3a7ViJMZUUZyVUeahBQTItXu0/PqWVLKKFJp/uB5ta0zEpLyVc60qg wjBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tX9YbbK4wZDYd/1rJF+Fsl9cu8MwUvaAy3wkrzRgdck=; b=ggrzH3+AMVwceJasnjgFIpn8RjE0J6eRZ5SS2oGt6jBTY6SSrCdR+i8tZwnvnnMTnM QHSZMGg8eV+qmxfQ8GDcABdzjzxfZSKd3jHQc4dFboxsx1Ebz4GfqVXeuQGc0B27Tvj1 Yx3sXFRkOrp3LaEuXybZE41csZXm5AO/JyMnfDfWmQEc0lencVrUNO6YPAj2oaPZYxQZ WNPr9dVbW/5MKLbHfh7jab0+ApzsVf3Qbt5Q+991qzL36aPiwVtxE955DD4AqjULfF5u 3C7BjmGnfsIPn5GccNbmlSg+GWinOt9b2l0wNquHTtMcKbKXDt4nwzY/2LHPKDsUZ9JP mhIQ== X-Gm-Message-State: AOAM530g9yocfzvCYOyjEQSGQafxymAskbZBpFaJarOYUwKYe1Vjb6mZ k58uVRqBBngkplkOfioujuXN9v05RYE= X-Google-Smtp-Source: ABdhPJxGeC6tp3SeoxUP99YYLkCjtoNxEe4/ANtehLPoJQ2I5YnOQLjx0VpstabDvYhzosZJadeOmw== X-Received: by 2002:ac2:554d:0:b0:443:6539:a299 with SMTP id l13-20020ac2554d000000b004436539a299mr4590089lfk.552.1645168070508; Thu, 17 Feb 2022 23:07:50 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id f2sm216321ljn.11.2022.02.17.23.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 23:07:50 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: Krzysztof Kozlowski , Florian Fainelli , Hauke Mehrtens , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V3 3/3] nvmem: core: add cell name based matching of DT cell nodes Date: Fri, 18 Feb 2022 08:07:29 +0100 Message-Id: <20220218070729.3256-4-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218070729.3256-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220218070729.3256-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220217_230754_914103_0E474460 X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Rafał Miłecki When adding NVMEM cells defined by driver it's important to match them with DT nodes that specify matching names. That way other bindings & drivers can reference such "dynamic" NVMEM cells. Signed-off-by: Rafał Miłecki --- drivers/nvmem/core.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 53a43d843743..a891449c52f1 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -499,6 +499,31 @@ static int nvmem_cell_info_to_nvmem_cell_entry(struct nvmem_device *nvmem, return 0; } +/** + * nvmem_find_cell_of_node() - Find DT node matching nvmem cell + * + * @nvmem: nvmem provider + * @name: nvmem cell name + * + * Runtime created nvmem cells (those not coming from DT) may still need to be + * referenced in DT. This function allows finding DT node referencing nvmem cell + * by its name. Such a DT node can be then used by nvmem consumers. + * + * Return: NULL or pointer to DT node + */ +static struct device_node *nvmem_find_cell_of_node(struct nvmem_device *nvmem, + const char *name) +{ + struct device_node *child; + + for_each_child_of_node(nvmem->dev.of_node, child) { + if (!strcmp(child->name, name)) + return child; + } + + return NULL; +} + /** * nvmem_add_cells() - Add cell information to an nvmem device * @@ -532,6 +557,8 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, goto err; } + cells[i]->np = nvmem_find_cell_of_node(nvmem, cells[i]->name); + nvmem_cell_entry_add(cells[i]); }