From patchwork Mon May 21 10:32:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 136451 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp138564lji; Mon, 21 May 2018 03:32:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoDSazFS9CKMzNS5TuJp/EVYj4435GAiVeir/bLtUtiGWFhA/QIaIJCYEbeVXHyxRbDp2Lc X-Received: by 2002:a65:51c4:: with SMTP id i4-v6mr15146624pgq.190.1526898761572; Mon, 21 May 2018 03:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526898761; cv=none; d=google.com; s=arc-20160816; b=CQ1RE8LfVx2Q+8PEGH2Ehmm3Tx6PqdHEzhaABHaJ9nLa5vDle5I3eK05pN6aP/4k4o xrWMPj4H3F8e/TW5F2OBoEXxaI66MpCI4Q8uLP/nP7LvYvIHMKtRVmqllwdgaUV/yt4b dB5zNW/otcZNhuK4Csmy/XrAxemabC9rdZAJutzasuN5cQGuKpiw6TsokRNPOwdv77Mz l29IyP40PxW9ir7V37SaCgKf+XoJBmTbbPfBfovdSOvbp/kVulgn+XdGj6YhL2Iz+6Uy GFMrsyKUELA8b4ZW55xUEPtJ50qfbZH/Jpb/pVJWK3UFIEhKY51hcPpx8KduzL80462h EikQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8CeRZ/QGNPs2N5cd1sVH9XuMRBhyqDVzOJ4j5eiEXGo=; b=T/WdzV12psZAOnq6/stVL9F0++EzyH//ZNXe5xV8lMGrKn0I38nHr/Le7/ANSd9PGp dhZHXP48FoTdWPTAsHXS9NeK8ZZ4YxicD8YQLXkxYBac6/xXV3ofMK5bv5y7D1hQ+kZs AMZu8gbJs21fTbxxsIMFhntJlstmgdJern6eBeKR5aSRne8kmh8P5ar9dSHh8aPEEOOs G0BOPMLnxIQj9WPp77sQ2iq7ViALP4EW3z3EnqBhdObo36F9Jpds+0aOqecNe5FgfAr5 SIOY6lLAiIQL0WH5svM0yBc1T/jimjjZyd4Ep8JHsaG+X5z8e/xkCaiEd65YWyYppEW8 ULUA== ARC-Authentication-Results: i=1; mx.google.com; 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 n2-v6si14471984plk.433.2018.05.21.03.32.41; Mon, 21 May 2018 03:32:41 -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; 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 S1752656AbeEUKck (ORCPT + 29 others); Mon, 21 May 2018 06:32:40 -0400 Received: from foss.arm.com ([217.140.101.70]:46504 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751895AbeEUKch (ORCPT ); Mon, 21 May 2018 06:32:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 40A0E1435; Mon, 21 May 2018 03:32:37 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.210.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 98A1B3F25D; Mon, 21 May 2018 03:32:35 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Andy Shevchenko , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Jeremy Linton , Catalin Marinas , Lorenzo Pieralisi , Greg Kroah-Hartman Subject: [PATCH] drivers: base: cacheinfo: use OF property_read_u64 instead of get_property, read_number Date: Mon, 21 May 2018 11:32:29 +0100 Message-Id: <1526898749-17263-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org of_property_read_u64 searches for a property in a device node and read a 64-bit value from it. Instead of using of_get_property to get the property and then read 64-bit value using of_read_number, we can simplify it by using of_property_read_u64. Cc: Greg Kroah-Hartman Suggested-by: Andy Shevchenko Signed-off-by: Sudeep Holla --- drivers/base/cacheinfo.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 2880e2ab01f5..6704563a9339 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -74,52 +74,50 @@ static inline int get_cacheinfo_idx(enum cache_type type) static void cache_size(struct cacheinfo *this_leaf, struct device_node *np) { const char *propname; - const __be32 *cache_size; + u64 cache_size; int ct_idx; ct_idx = get_cacheinfo_idx(this_leaf->type); propname = cache_type_info[ct_idx].size_prop; - cache_size = of_get_property(np, propname, NULL); - if (cache_size) - this_leaf->size = of_read_number(cache_size, 1); + if (!of_property_read_u64(np, propname, &cache_size)) + this_leaf->size = cache_size; } /* not cache_line_size() because that's a macro in include/linux/cache.h */ static void cache_get_line_size(struct cacheinfo *this_leaf, struct device_node *np) { - const __be32 *line_size; int i, lim, ct_idx; ct_idx = get_cacheinfo_idx(this_leaf->type); lim = ARRAY_SIZE(cache_type_info[ct_idx].line_size_props); for (i = 0; i < lim; i++) { + int ret; + u64 line_size; const char *propname; propname = cache_type_info[ct_idx].line_size_props[i]; - line_size = of_get_property(np, propname, NULL); - if (line_size) + ret = of_property_read_u64(np, propname, &line_size); + if (!ret) { + this_leaf->coherency_line_size = line_size; break; + } } - - if (line_size) - this_leaf->coherency_line_size = of_read_number(line_size, 1); } static void cache_nr_sets(struct cacheinfo *this_leaf, struct device_node *np) { const char *propname; - const __be32 *nr_sets; + u64 nr_sets; int ct_idx; ct_idx = get_cacheinfo_idx(this_leaf->type); propname = cache_type_info[ct_idx].nr_sets_prop; - nr_sets = of_get_property(np, propname, NULL); - if (nr_sets) - this_leaf->number_of_sets = of_read_number(nr_sets, 1); + if (!of_property_read_u64(np, propname, &nr_sets)) + this_leaf->number_of_sets = nr_sets; } static void cache_associativity(struct cacheinfo *this_leaf)