[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120304055500.GC10743@S2101-09.ap.freescale.net>
Date: Sun, 4 Mar 2012 13:55:04 +0800
From: Shawn Guo <shawn.guo@...aro.org>
To: "Ying-Chun Liu (PaulLiu)" <paul.liu@...aro.org>
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linaro-dev@...ts.linaro.org, patches@...aro.org,
Samuel Ortiz <sameo@...ux.intel.com>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Venu Byravarasu <vbyravarasu@...dia.com>,
Peter Korsgaard <jacmet@...site.dk>
Subject: Re: [PATCH v7 1/2] mfd: Add anatop mfd driver
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists