From patchwork Mon Jan 24 16:03:00 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: 12722350 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 DCE98C433EF for ; Mon, 24 Jan 2022 16:08:56 +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=BgelLGpGQoyTA55/839erlUZgpd6M02HoHZURkwoyyY=; b=cnkdi+e3+3v0CH 3yRCZIbIdvmc5EcjrdIAEL+HLrw5ROvies2ruyUkhV3/ojj2XhA3GX5f7LxPnrCZBWgcyN1/lMVnk yEIKxDN7laWU24jfR/KVAloB+hbH4DuBGBAXgx92K7iQrpRWZFzX8ZdaIlpcK7XJDUVSJOx9pDkXH m4YedT+HjbYIJeX9rPE+KztBt0OawTJ9vdCO3WU0+4xyttRw36SUUFuYCP9Zrl3fnUe8s/kx2E74K 4dvjFyg55CVnlHcjDHvDYwO2CQD5hF3mPlYDkrCYdAyLEqWEjD24rzlOeMuNk3ALo46jz6/pAPfbp Jgxdjza/COpJmqm+QMUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC1s9-003vEl-5w; Mon, 24 Jan 2022 16:07:13 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nC1oP-003tp8-1T for linux-arm-kernel@lists.infradead.org; Mon, 24 Jan 2022 16:03:22 +0000 Received: by mail-lf1-x134.google.com with SMTP id x23so3863392lfc.0 for ; Mon, 24 Jan 2022 08:03:20 -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=vfS/F/Wf9bu+NmDqBxpkt9bmTl6S69QHI1qpficbqZk=; b=BPJQ7SJ1V0lmwC4C01DIbifBg7ehy+WB5aIuFTp6EjdCDMMOsA6mfQfRV+4UTcrNdP Tdhc3iHt54ivoyVnXU1mWG1lf0abJKqqCwnPElabBBzQHWByy7GqLaXpvkooORBA0tJt xYnkY6QuTkwqjY1Bq0J75UrtLrn4urM2LojwoL00czhU7e+nAvLQmzUmfyTajF7xW+Jo LHFCXOsg5Ey6JaFG3qSVGmym+Uw2qL3l2Zfy+x7yQN3k4k6G0RocYgNZpUiGv71dfVh5 E4ok0tjNlDPOlkhARkh29k7oFo+teAVcWsyeFpgRqTItoVxCUcVbdab0wfAsWctUpEts LXEg== 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=vfS/F/Wf9bu+NmDqBxpkt9bmTl6S69QHI1qpficbqZk=; b=T02FqpvOVCXaXR6hNIYVu3wzivB5M35/bVS2v61dplNyKZMMJcO1+1B+p0FOzzgYTZ C8UT3z/5VNnf3SpClFxQBm9drEeB71rgsZ0CjcHtjy6V1tK/BkZWuTPqG5WtBoJZ+PLT RGBnnLNiR7TMjCrvHiAjZXbuidVGSK4UzOoyxXUF1unfPxh4vPCgtgEq80kBRMzfo7bh khFwfw5jdhxfqxSB59Cs3GsaIusK6Cjp6oG8s1g9/W1Hg7TL5KiXv8dk4SPThTAsKdVg LgQUXBrTJjQUFOjVtrlGjF6m0xcTKBopjQ7XOniR3Ol/ly61ChYP2uosRMJ5ENhVi8zf 4G6A== X-Gm-Message-State: AOAM530udLRNn3yMfXz/uWNMKcgt1mrBCbVV9cZ3WM6gPhgbQxImY3F8 ZAmb0+QgqkPFGXzUSvfD1OU= X-Google-Smtp-Source: ABdhPJxAfwvpekuz53Sh6fCrPpxNEfqZtyyPgqs42/pS7SEszF6KXyJ0UzyTB8S3DJyXgws5ehsBog== X-Received: by 2002:a05:6512:b84:: with SMTP id b4mr4711978lfv.652.1643040199237; Mon, 24 Jan 2022 08:03:19 -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 n21sm674187lji.18.2022.01.24.08.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 08:03:18 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: 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 3/3] nvmem: core: add cell name based matching of DT cell nodes Date: Mon, 24 Jan 2022 17:03:00 +0100 Message-Id: <20220124160300.25131-4-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220124160300.25131-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220124_080321_153680_70ED3281 X-CRM114-Status: GOOD ( 14.92 ) 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 23a38dcf0fc4..9a1299a7f46a 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]); }