Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp214929ybe; Wed, 18 Sep 2019 15:49:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKwsiJiSXexvv+zO3wGwsKJ1kF8JUnagR+4SEzVijWDfZ5qEu5PfDEa26dFQ14cFfPB6/D X-Received: by 2002:a17:906:7089:: with SMTP id b9mr11453728ejk.282.1568846991223; Wed, 18 Sep 2019 15:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568846991; cv=none; d=google.com; s=arc-20160816; b=Yb1LKQKsAObZU94QQJXe/MvxVc12Ki3Hp6inFF8WDSWpehBeIrRjx/ccoFwy1DvPpi PMCNqT6S1n3sIbnDBmtgliuvetLx2y9fVIjKA98IhwJ4hoMobh28fOM7fnpmF/cxZEii CFchYo650E1O6Fcf6+TaJqmEWqkbZ0bZyhIcizTUeTwtiLpNuA2w221HqnZ1yKGUDOA+ YgeKfKV7P5hgbvn8QRFylxWBBbSHRyhSfYUkwQ1IbL0SDWB+LABcRiwNZhWhNE0ZxcN2 XV6siqkwjsBQkfvENL8pVdE1IVsmUdMFrQVkV9Lc5sPD+OvnZ2wP+3cPKIbCDQGKVSrO PrIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SNcETyYu6j2Jzyek2OLhtDtO5ytxFaxP7zSRdqV2SoU=; b=hYLYJsm7lvOodha8hd/PW0En400wGqYGbVbVN5CewWs7qgTBhjbXN0hq9SNZqqozld eowzzIMMgVmVy9AaGRqPzxKm5PeNkh5I75SB/MCsCJJK0vxU6VfcWWcKgGD8NVtZk0Ke Ykr8ntXPmsgW2kGWgHm0q8+oqXiy+Mp783RblHYiDDks05ROZeZnZTlOQNb/23ZIXmgc UUUx5cS8i/IfXujyhaXV29WntGFoiTVQWSf7kvP7HYtIrv3uZOeuZTbGvzXDFiLM2DA6 4kyW4evRZCLmpjo0OFvmVX8GLMQGI/YP2XwQsDGDKEQJ4risfVygj8psj1WFa96UP9wo w1Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JlSwulvY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si4008870edp.247.2019.09.18.15.49.28; Wed, 18 Sep 2019 15:49:51 -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=@kernel.org header.s=default header.b=JlSwulvY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391175AbfIRUNS (ORCPT + 99 others); Wed, 18 Sep 2019 16:13:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:33632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391137AbfIRUNS (ORCPT ); Wed, 18 Sep 2019 16:13:18 -0400 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6F3021BE5; Wed, 18 Sep 2019 20:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568837596; bh=7yqTiFhnfOQD1ehV4j3dV3361bQH6KOjLCmrP9XuYao=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JlSwulvYPbZcQ+Kx888pCMj/MpNfLeCJBzzVzKM5RgftKgq6k71CdfOnqLUo9c7v2 zaRIwbkhoyGSeG9Ok/bo6UpgUj5JM8xcoOORRd4RDTt+Uv+WA9x+dWc/dNRazg+RE6 fZH2fI/pqosb98SZEuYG16sh8Y6wBh1hFuZdcXk0= Received: by mail-qt1-f175.google.com with SMTP id n7so1327947qtb.6; Wed, 18 Sep 2019 13:13:16 -0700 (PDT) X-Gm-Message-State: APjAAAVWA/bSjuIL9eKGR67EXJKuca7+p+/1dwNBPKuRaUvuxVx4e0Fa paJaFEopBlOMaLAvIee5AxVRocj+jnB+72CF9g== X-Received: by 2002:ac8:100d:: with SMTP id z13mr6081504qti.224.1568837595963; Wed, 18 Sep 2019 13:13:15 -0700 (PDT) MIME-Version: 1.0 References: <20190918184656.7633-1-rananta@codeaurora.org> In-Reply-To: <20190918184656.7633-1-rananta@codeaurora.org> From: Rob Herring Date: Wed, 18 Sep 2019 15:13:04 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] of: Add of_get_memory_prop() To: Raghavendra Rao Ananta Cc: Frank Rowand , Trilok Soni , Android Kernel Team , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + 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 >