Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752770AbbGWJRG (ORCPT ); Thu, 23 Jul 2015 05:17:06 -0400 Received: from ozlabs.org ([103.22.144.67]:59532 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751916AbbGWJQ5 (ORCPT ); Thu, 23 Jul 2015 05:16:57 -0400 Message-ID: <1437643015.29271.3.camel@ellerman.id.au> Subject: Re: [PATCH v5 3/7] powerpc/powernv: Nest PMU detection and device tree parser From: Michael Ellerman To: Madhavan Srinivasan Cc: Daniel Axtens , linux-kernel@vger.kernel.org, Stephane Eranian , Paul Mackerras , Anton Blanchard , Sukadev Bhattiprolu , linuxppc-dev@lists.ozlabs.org, Anshuman Khandual Date: Thu, 23 Jul 2015 19:16:55 +1000 In-Reply-To: <55B081B2.4050001@linux.vnet.ibm.com> References: <1437045206-7491-1-git-send-email-maddy@linux.vnet.ibm.com> <1437045206-7491-4-git-send-email-maddy@linux.vnet.ibm.com> <1437536981.30906.9.camel@axtens.net> <55B081B2.4050001@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2184 Lines: 62 On Thu, 2015-07-23 at 11:24 +0530, Madhavan Srinivasan wrote: > > On Wednesday 22 July 2015 09:19 AM, Daniel Axtens wrote: > > Hi, > > > >> +static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; > >> + > >> +static int nest_ima_dt_parser(void) > >> +{ > >> + const __be32 *gcid; > >> + const __be64 *chip_ima_reg; > >> + const __be64 *chip_ima_size; > >> + struct device_node *dev; > >> + struct perchip_nest_info *p8ni; > >> + int idx; > >> + > >> + /* > >> + * "nest-ima" folder contains two things, > >> + * a) per-chip reserved memory region for Nest PMU Counter data > >> + * b) Support Nest PMU units and their event files > >> + */ > >> + for_each_node_with_property(dev, "ibm,ima-chip") { > >> + gcid = of_get_property(dev, "ibm,chip-id", NULL); > >> + chip_ima_reg = of_get_property(dev, "reg", NULL); > >> + chip_ima_size = of_get_property(dev, "size", NULL); > >> + > >> + if ((!gcid) || (!chip_ima_reg) || (!chip_ima_size)) { > >> + pr_err("Nest_PMU: device %s missing property\n", > >> + dev->full_name); > >> + return -ENODEV; > >> + } > >> + > >> + /* chip id to save reserve memory region */ > >> + idx = (uint32_t)be32_to_cpup(gcid); > > So be32_to_cpup returns a __u32. You're casting to a uint32_t and then > > assigning to an int. > > - Do you need the intermediate cast? > > - Should idx be an unsigned type? > > my bad, sorry abt type case of uint to int. > And your are right, idx can be __u32 (__u32 and uint32_t are same i > guess). It should be u32. Don't use the uintx_t types in kernel code unless there's some good reason for it. The __u32 etc. types are for things that are exposed to userspace, which this is not, so u32 is correct. Having said that, this code should be using of_property_read_u32() etc. And having said that, this is all based on a device tree binding that hasn't been reviewed yet on the OPAL side, so it's subject to change too. cheers -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/