Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp260000ybe; Wed, 18 Sep 2019 16:46:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqXuVHQ5Hi8p6HKad1kW5ewrQH12kTXWssWDv2Z3DnvXKUqbyHMgyXyOvotBKjOy3q4USb X-Received: by 2002:a17:906:4051:: with SMTP id y17mr11730883ejj.203.1568850394425; Wed, 18 Sep 2019 16:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568850394; cv=none; d=google.com; s=arc-20160816; b=DT6nl8ttOJ7X4I6LNTUneJmsbZLzpkFi2htOMLO3DPDQrqkw2wvKbGtFX+4qcAMv3T iMeL5iVb3Ehjk1SA96Q+EirOR3YXPuSTN18L8+njnGRnd2dFo/kBEVACZZtjPS9jmy+5 WgfccdSA6t99mhNzkTeNEpko9MXJzGQ5J/B6RZ73iWFlsOIG7hLOzzevfwPEO3HnJxCE A8xhT0smYk7xYXOqLXQqxnitKuJSQ73y/ejzSPmTCBEAHCy3rvGybIdI5/NK5v/hkiYo xjEoq6/YQZnq3d2f1QtImqonBFBOe/MjUiD9gyd7mLG5pk1QbpOvngNyWZcnV+e2DYoL 1Uvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=LegD9f+nKhyGCum0R9zptU8sQ+darIt5ZfcyKVFTNEE=; b=glxGg+z2C3MBMW4Ij4GefjVZDXxAi7+NhBPxQIQuLoYMvczIefxPj9baL8C0l91vLi bvdOo36z832u04n8p7amj1/qQPNbXWhQuY/pFgpl9GXyzco4h3qnInXZCgdIh8lb37Yd wq5cmOPjKzlSoGHMiyLeraxfyKf+tD5BTrupcuqKNfbFasRpfZuHli0ARjehqbqWrR3r 6DiGS0mfs+Jxydk/CUBxsOcUU6/VU6uvbA/IN7BN9hwskYVR/62jTecb4INqDqmQkTBM eKzdunNR1/aq7Sy3U73ptQ9uH5zW0VWhuitv0xv+BIOl3Vvq3oCmJ0bcfHaj8ZuWS1Xg 16lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=OAguUzqo; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ao+QsFJR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si3497811ejk.376.2019.09.18.16.46.11; Wed, 18 Sep 2019 16:46:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=OAguUzqo; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ao+QsFJR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731028AbfIRWcQ (ORCPT + 99 others); Wed, 18 Sep 2019 18:32:16 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44830 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730847AbfIRWcQ (ORCPT ); Wed, 18 Sep 2019 18:32:16 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 38CC5611CE; Wed, 18 Sep 2019 22:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1568845935; bh=Nn2KgLmrM9Q93wmCCCAjiSFicJ0JbQsJ0LmX1D/4XY4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OAguUzqoK/ugGzIxirfunhIKhnIlkT+D9gy4gHfSTFf2DXUhLi0oTF6RaF05r3bR3 EF9YncIT19x/peVRYwf8G6mV+OYESM4wNEgf3C1EDPk/AVDV8CohnV7vgKYKMbsIWx K9cW7dcD5AGirHlvN3Wn/PldRxmJ+hIduVZITdYY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id B039260A60; Wed, 18 Sep 2019 22:32:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1568845934; bh=Nn2KgLmrM9Q93wmCCCAjiSFicJ0JbQsJ0LmX1D/4XY4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ao+QsFJRbm18x3FwzvGWCr36fGLRBW8Tq84u71Fz3Jtcyn1ve5EkHYdhE/0yM/Dk9 HQC/WeCQ69LpHM5D3Y6Jmd4SuvmzjDswaN0BehE/dHlYbmE8nu1NW9TOUkeGX2FYwx bmzukqqanpxSU0TWMx+uVyL2EwaaP7tERM5f5P/M= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 18 Sep 2019 15:32:14 -0700 From: rananta@codeaurora.org To: Rob Herring Cc: Frank Rowand , Trilok Soni , Android Kernel Team , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] of: Add of_get_memory_prop() In-Reply-To: References: <20190918184656.7633-1-rananta@codeaurora.org> Message-ID: <19d727bbfce08e59294920ba8097be7a@codeaurora.org> X-Sender: rananta@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-09-18 13:13, Rob Herring wrote: > On Wed, Sep 18, 2019 at 1:47 PM Raghavendra Rao Ananta > wrote: >> >> On some embedded systems, the '/memory' dt-property gets updated >> by the bootloader (for example, the DDR configuration) and then >> gets passed onto the kernel. The device drivers may have to read >> the properties at runtime to make decisions. Hence, add >> of_get_memory_prop() for the device drivers to query the requested > > Function name doesn't match. Device drivers don't need to access the > FDT. > >> properties. >> >> Signed-off-by: Raghavendra Rao Ananta >> --- >> drivers/of/fdt.c | 27 +++++++++++++++++++++++++++ >> include/linux/of_fdt.h | 1 + >> 2 files changed, 28 insertions(+) > > We don't add kernel api's without users. > >> >> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c >> index 223d617ecfe1..925cf2852433 100644 >> --- a/drivers/of/fdt.c >> +++ b/drivers/of/fdt.c >> @@ -79,6 +79,33 @@ void __init of_fdt_limit_memory(int limit) >> } >> } >> >> +/** >> + * of_fdt_get_memory_prop - Return the requested property from the >> /memory node >> + * >> + * On match, returns a non-zero positive value which represents the >> property >> + * value. Otherwise returns -ENOENT. >> + */ >> +int of_fdt_get_memory_prop(const char *pname) >> +{ >> + int memory; >> + int len; >> + fdt32_t *prop = NULL; >> + >> + if (!pname) >> + return -EINVAL; >> + >> + memory = fdt_path_offset(initial_boot_params, "/memory"); > > Memory nodes should have a unit-address, so this won't work frequently. Sorry, can you please elaborate more on this? What do you mean by unit-address and working frequently? > >> + if (memory > 0) >> + prop = fdt_getprop_w(initial_boot_params, memory, >> + pname, &len); >> + >> + if (!prop || len != sizeof(u32)) >> + return -ENOENT; >> + >> + return fdt32_to_cpu(*prop); >> +} >> +EXPORT_SYMBOL_GPL(of_fdt_get_memory_prop); >> + >> static bool of_fdt_device_is_available(const void *blob, unsigned >> long node) >> { >> const char *status = fdt_getprop(blob, node, "status", NULL); >> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h >> index acf820e88952..537f29373358 100644 >> --- a/include/linux/of_fdt.h >> +++ b/include/linux/of_fdt.h >> @@ -38,6 +38,7 @@ extern char __dtb_end[]; >> /* Other Prototypes */ >> extern u64 of_flat_dt_translate_address(unsigned long node); >> extern void of_fdt_limit_memory(int limit); >> +extern int of_fdt_get_memory_prop(const char *pname); >> #endif /* CONFIG_OF_FLATTREE */ >> >> #ifdef CONFIG_OF_EARLY_FLATTREE >> -- >> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora >> Forum, >> a Linux Foundation Collaborative Project >> - Raghavendra