From patchwork Fri Jul 6 12:50:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 141306 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3076700ljj; Fri, 6 Jul 2018 05:50:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcRjZKEZT0A9EvXAghXnW+6lvI+33LLW2aK4mqScBn8auO06eGiYCTynktRTip0NdHqGFb2 X-Received: by 2002:a63:b02:: with SMTP id 2-v6mr4556080pgl.301.1530881443233; Fri, 06 Jul 2018 05:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530881443; cv=none; d=google.com; s=arc-20160816; b=Rnsx1CPGo0KRZKl8117NnmV1Pev7wetvpSBpLRCGhE5lnhUI5jErPgxwLn2l8oO/ON F4pFRoRovJUvkJcFreGD/kIlF4GzKWUadOYEdE0s8miG7sN4sUz8iUnCTVc3JCgjNEyi 6k4iIyuglyQBjjSsa0vY/zprt+p47lJOAvwSea1p53lKGaifTeej22dR9UX74Z0PvX9k jnZpZyJGciVRGsCBr4GxcJ/kok2m5ljBr6iIZeHhbez50btTMPOmhAFUCm15Op98QdC+ WqBkhg9RP6JAUxhVYCMwLBSAk8IDYqGciIdEQ//z7p5F3NFrqYA5wYlQkahUBXXnc4PW dJlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EpLOG/H2tylj4BK0H8M9argWOzdkuJjoavDKn+fWqMk=; b=UpWbV+5KshW7QM7jMQwqELz1I3SV+/2wje5Rt9bYCcUCtB4GAbNelIM+OTZ5U8W8iL FqsKn1imFUsdcLIx36n2SMc4udGQE8/V2slAUF5V0hd/FECQW/bVhGdejkBvBrp8IRSY JiOM6iP6zaZiOd6up+yaFSIk5vaxaDB7gZK1uM1yorFw9XfMsJ1EjWS3MpDOA1WHyVWY QYTDkVa34bdz/MGXzN4YLIWqCgSjtCpj73mmoDUMYwgzxGSUm6bScRErAzoIGKLuNvaH nr1sKpljA+JkJ4jqH2o3Gjg2S4rEAjt9Uc2LdUr2n45yIGaNggq0TQ3EhtokgFDA9nJx ai5g== 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 r65-v6si8861088pfe.298.2018.07.06.05.50.42; Fri, 06 Jul 2018 05:50:43 -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 S933335AbeGFMul (ORCPT + 30 others); Fri, 6 Jul 2018 08:50:41 -0400 Received: from foss.arm.com ([217.140.101.70]:36066 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932569AbeGFMuk (ORCPT ); Fri, 6 Jul 2018 08:50:40 -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 047B218A; Fri, 6 Jul 2018 05:50:40 -0700 (PDT) Received: from usa.arm.com (unknown [10.1.211.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 19DBD3F5BA; Fri, 6 Jul 2018 05:50:38 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Cc: Sudeep Holla , Andy Shevchenko Subject: [PATCH v2][REPOST] drivers: base: cacheinfo: use OF property_read_u32 instead of get_property, read_number Date: Fri, 6 Jul 2018 13:50:31 +0100 Message-Id: <1530881431-14233-1-git-send-email-sudeep.holla@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org of_property_read_u32 searches for a property in a device node and read a 32-bit value from it. Instead of using of_get_property to get the property and then read 32-bit value using of_read_number, we can simplify it by using of_property_read_u32. Cc: Greg Kroah-Hartman Suggested-by: Andy Shevchenko Signed-off-by: Sudeep Holla --- drivers/base/cacheinfo.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) Hi Greg, Can you pick this up for v4.19 ? It was too late for v4.18 and was not pulled with other changes to this file. Just reposting the same, Andy did say LGTM. Regards, Sudeep -- 2.7.4 diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 2880e2ab01f5..5d5b5988e88b 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -74,52 +74,48 @@ 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; 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_u32(np, propname, &this_leaf->size)) + this_leaf->size = 0; } /* 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; + u32 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_u32(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; 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_u32(np, propname, &this_leaf->number_of_sets)) + this_leaf->number_of_sets = 0; } static void cache_associativity(struct cacheinfo *this_leaf)