Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753256AbbGWJ2n (ORCPT ); Thu, 23 Jul 2015 05:28:43 -0400 Received: from e23smtp04.au.ibm.com ([202.81.31.146]:34020 "EHLO e23smtp04.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753069AbbGWJ1y (ORCPT ); Thu, 23 Jul 2015 05:27:54 -0400 X-Helo: d23dlp01.au.ibm.com X-MailFrom: maddy@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Message-ID: <55B0B344.4040407@linux.vnet.ibm.com> Date: Thu, 23 Jul 2015 14:56:28 +0530 From: Madhavan Srinivasan User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Michael Ellerman CC: Daniel Axtens , linux-kernel@vger.kernel.org, Stephane Eranian , Paul Mackerras , Anton Blanchard , Sukadev Bhattiprolu , linuxppc-dev@lists.ozlabs.org, Anshuman Khandual Subject: Re: [PATCH v5 3/7] powerpc/powernv: Nest PMU detection and device tree parser 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> <1437643015.29271.3.camel@ellerman.id.au> In-Reply-To: <1437643015.29271.3.camel@ellerman.id.au> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15072309-0013-0000-0000-0000019DAF5D Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2425 Lines: 69 On Thursday 23 July 2015 02:46 PM, Michael Ellerman wrote: > 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. Ok will change it to use of_property_read_u32. > 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. Have posted new version in the skiboot mailinglist based on the reviews. hoping to get it reviewed soon. Maddy > 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/