From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752079AbcCKSzM (ORCPT ); Fri, 11 Mar 2016 13:55:12 -0500 Received: from smtprelay0092.hostedemail.com ([216.40.44.92]:41417 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751564AbcCKSzJ (ORCPT ); Fri, 11 Mar 2016 13:55:09 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2559:2562:2743:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:4321:4385:5007:6261:7576:10004:10400:10848:11026:11232:11658:11783:11914:12043:12296:12438:12517:12519:12740:13069:13311:13357:13439:13894:13972:14659:14721:21080:30054:30064:30080:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: brick27_49b42050eba02 X-Filterd-Recvd-Size: 2882 Message-ID: <1457722505.4654.8.camel@perches.com> Subject: Re: [PATCH v2] bsp: add SoC driver to brcmstb From: Joe Perches To: Justin Chen , linux-kernel@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, f.fainelli@gmail.com, linux-arm-kernel@lists.infradead.org, arnd@arndb.de, Justin Chen Date: Fri, 11 Mar 2016 10:55:05 -0800 In-Reply-To: <1457721579-9646-1-git-send-email-justinpopo6@gmail.com> References: <1457721579-9646-1-git-send-email-justinpopo6@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-03-11 at 10:39 -0800, Justin Chen wrote: > From: Justin Chen > > Value of soc_dev_attributes: > family = chip family id > soc_id = product id > revision = product revision [] > diff --git a/drivers/soc/brcmstb/common.c b/drivers/soc/brcmstb/common.c [] > +static int __init brcmstb_soc_device_init(void) > +{ > + struct soc_device_attribute *soc_dev_attr; > + struct soc_device *soc_dev; > + struct device_node *sun_top_ctrl; > + void __iomem *sun_top_ctrl_base; > + > + sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match); > + if (!sun_top_ctrl) > + return -ENODEV; > + > + sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0); > + if (!sun_top_ctrl_base) > + return -ENODEV; > + > + family_id = readl(sun_top_ctrl_base); > + product_id = readl(sun_top_ctrl_base + 0x4); > + > + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); > + if (!soc_dev_attr) > + return -ENOMEM; > + > + soc_dev_attr->family = kasprintf(GFP_KERNEL, "%x", > + family_id >> 28 ? > + family_id >> 16 : family_id >> 8); > + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%x", > + product_id >> 28 ? > + product_id >> 16 : product_id >> 8); > + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d", > +     (char)(((product_id & 0xff) >> 4) + 65), > +      product_id & 0xf); This might be easier to read as: soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d" ((product_id & 0xf0) >> 4) + 'A', product_id & 0xf); > + > + soc_dev = soc_device_register(soc_dev_attr); > + if (IS_ERR(soc_dev)) { > + kfree(soc_dev_attr->family); > + kfree(soc_dev_attr->soc_id); > + kfree(soc_dev_attr->revision); > + kfree(soc_dev_attr); > + return -1; Mixing GENERIC_ERRNO types and fixed values seems odd. Is -EPERM the correct return here? Maybe -ENODEV? > + } > + > + return 0; > +} > +arch_initcall(brcmstb_soc_device_init);