From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751390Ab2CDFkt (ORCPT ); Sun, 4 Mar 2012 00:40:49 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:51582 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108Ab2CDFkt (ORCPT ); Sun, 4 Mar 2012 00:40:49 -0500 Authentication-Results: mr.google.com; spf=pass (google.com: domain of shawn.guo@linaro.org designates 10.50.236.34 as permitted sender) smtp.mail=shawn.guo@linaro.org Date: Sun, 4 Mar 2012 13:55:04 +0800 From: Shawn Guo To: "Ying-Chun Liu (PaulLiu)" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org, Samuel Ortiz , Mark Brown , Venu Byravarasu , Peter Korsgaard Subject: Re: [PATCH v7 1/2] mfd: Add anatop mfd driver Message-ID: <20120304055500.GC10743@S2101-09.ap.freescale.net> References: <1330671641-6439-1-git-send-email-paul.liu@linaro.org> <1330796352-6884-1-git-send-email-paul.liu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1330796352-6884-1-git-send-email-paul.liu@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry, one more missing ... On Sun, Mar 04, 2012 at 01:39:12AM +0800, Ying-Chun Liu (PaulLiu) wrote: ... > +static int of_anatop_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct device_node *np = dev->of_node; > + void *ioreg; > + struct anatop *drvdata; > + > + ioreg = of_iomap(np, 0); > + if (!ioreg) > + return -EINVAL; > + drvdata = devm_kzalloc(dev, sizeof(struct anatop), GFP_KERNEL); sizeof(*drvdata) please. Documentation/CodingStyle, Chapter 14: The preferred form for passing a size of a struct is the following: p = kmalloc(sizeof(*p), ...); The alternative form where struct name is spelled out hurts readability and introduces an opportunity for a bug when the pointer variable type is changed but the corresponding sizeof that is passed to a memory allocator is not. > + if (!drvdata) > + return -EINVAL; > + drvdata->ioreg = ioreg; > + spin_lock_init(&drvdata->reglock); > + platform_set_drvdata(pdev, drvdata); > + of_platform_bus_probe(np, of_anatop_subdevice_match, dev); > + > + return 0; > +} -- Regards, Shawn