* [PATCH] drivers: mfd: sec-code: Fix sizeof argument @ 2013-05-15 10:53 Leon Romanovsky 2013-05-16 22:13 ` Samuel Ortiz 0 siblings, 1 reply; 5+ messages in thread From: Leon Romanovsky @ 2013-05-15 10:53 UTC (permalink / raw) To: sbkim73, sameo; +Cc: linux-kernel, Leon Romanovsky Signed-off-by: Leon Romanovsky <leon@leon.nu> --- drivers/mfd/sec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index 77ee26ef..5b740a3 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c @@ -121,7 +121,7 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( { struct sec_platform_data *pd; - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); + pd = devm_kzalloc(dev, sizeof(struct sec_platform_data), GFP_KERNEL); if (!pd) { dev_err(dev, "could not allocate memory for pdata\n"); return ERR_PTR(-ENOMEM); -- 1.8.1.5 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: mfd: sec-code: Fix sizeof argument 2013-05-15 10:53 [PATCH] drivers: mfd: sec-code: Fix sizeof argument Leon Romanovsky @ 2013-05-16 22:13 ` Samuel Ortiz 2013-05-17 17:50 ` Leon Romanovsky 0 siblings, 1 reply; 5+ messages in thread From: Samuel Ortiz @ 2013-05-16 22:13 UTC (permalink / raw) To: Leon Romanovsky; +Cc: sbkim73, linux-kernel Hi Leon, On Wed, May 15, 2013 at 01:53:56PM +0300, Leon Romanovsky wrote: > Signed-off-by: Leon Romanovsky <leon@leon.nu> > --- > drivers/mfd/sec-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c > index 77ee26ef..5b740a3 100644 > --- a/drivers/mfd/sec-core.c > +++ b/drivers/mfd/sec-core.c > @@ -121,7 +121,7 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( > { > struct sec_platform_data *pd; > > - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); > + pd = devm_kzalloc(dev, sizeof(struct sec_platform_data), GFP_KERNEL); How is that fixing anything ? Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: mfd: sec-code: Fix sizeof argument 2013-05-16 22:13 ` Samuel Ortiz @ 2013-05-17 17:50 ` Leon Romanovsky 2013-05-17 17:58 ` Joe Perches 0 siblings, 1 reply; 5+ messages in thread From: Leon Romanovsky @ 2013-05-17 17:50 UTC (permalink / raw) To: Samuel Ortiz; +Cc: sbkim73, linux-kernel On Fri, May 17, 2013 at 1:13 AM, Samuel Ortiz <sameo@linux.intel.com> wrote: > Hi Leon, > > On Wed, May 15, 2013 at 01:53:56PM +0300, Leon Romanovsky wrote: >> Signed-off-by: Leon Romanovsky <leon@leon.nu> >> --- >> drivers/mfd/sec-core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c >> index 77ee26ef..5b740a3 100644 >> --- a/drivers/mfd/sec-core.c >> +++ b/drivers/mfd/sec-core.c >> @@ -121,7 +121,7 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( >> { >> struct sec_platform_data *pd; >> >> - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); >> + pd = devm_kzalloc(dev, sizeof(struct sec_platform_data), GFP_KERNEL); > How is that fixing anything ? Technically you are right, this fix brings code to be align to common code convention and allows to automatic tools correctly parse it. > > Cheers, > Samuel. > > -- > Intel Open Source Technology Centre > http://oss.intel.com/ -- Leon Romanovsky | Independent Linux Consultant www.leon.nu | leon@leon.nu ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: mfd: sec-code: Fix sizeof argument 2013-05-17 17:50 ` Leon Romanovsky @ 2013-05-17 17:58 ` Joe Perches 2013-05-17 18:16 ` Leon Romanovsky 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2013-05-17 17:58 UTC (permalink / raw) To: Leon Romanovsky; +Cc: Samuel Ortiz, sbkim73, linux-kernel On Fri, 2013-05-17 at 20:50 +0300, Leon Romanovsky wrote: > On Fri, May 17, 2013 at 1:13 AM, Samuel Ortiz <sameo@linux.intel.com> wrote: > > On Wed, May 15, 2013 at 01:53:56PM +0300, Leon Romanovsky wrote: > >> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c [] > >> @@ -121,7 +121,7 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( [] > >> - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); > >> + pd = devm_kzalloc(dev, sizeof(struct sec_platform_data), GFP_KERNEL); > > How is that fixing anything ? > Technically you are right, this fix brings code to be align to common > code convention and allows to automatic tools correctly parse it. Not really. Common coding convention is actually the original code. from: Documentation/CodingStyle: Chapter 14: Allocating memory [] The preferred form for passing a size of a struct is the following: p = kmalloc(sizeof(*p), ...); ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drivers: mfd: sec-code: Fix sizeof argument 2013-05-17 17:58 ` Joe Perches @ 2013-05-17 18:16 ` Leon Romanovsky 0 siblings, 0 replies; 5+ messages in thread From: Leon Romanovsky @ 2013-05-17 18:16 UTC (permalink / raw) To: Joe Perches; +Cc: Samuel Ortiz, sbkim73, linux-kernel On Fri, May 17, 2013 at 8:58 PM, Joe Perches <joe@perches.com> wrote: > On Fri, 2013-05-17 at 20:50 +0300, Leon Romanovsky wrote: >> On Fri, May 17, 2013 at 1:13 AM, Samuel Ortiz <sameo@linux.intel.com> wrote: >> > On Wed, May 15, 2013 at 01:53:56PM +0300, Leon Romanovsky wrote: >> >> diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c > [] >> >> @@ -121,7 +121,7 @@ static struct sec_platform_data *sec_pmic_i2c_parse_dt_pdata( > [] >> >> - pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); >> >> + pd = devm_kzalloc(dev, sizeof(struct sec_platform_data), GFP_KERNEL); >> > How is that fixing anything ? >> Technically you are right, this fix brings code to be align to common >> code convention and allows to automatic tools correctly parse it. > > Not really. > Common coding convention is actually the original code. > > from: Documentation/CodingStyle: > > Chapter 14: Allocating memory > [] > The preferred form for passing a size of a struct is the following: > > p = kmalloc(sizeof(*p), ...); > > Thanks Joe, it is good to know, but from my simple grep, most developers doesn't follow with this guide: leon@tux ~/dev/kernel/linux-staging $ grep -r "sizeof(struct" * | wc -l 25865 leon@tux ~/dev/kernel/linux-staging $ grep -r "sizeof(\*" * | wc -l 14568 -- Leon Romanovsky | Independent Linux Consultant www.leon.nu | leon@leon.nu ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-05-17 18:17 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-05-15 10:53 [PATCH] drivers: mfd: sec-code: Fix sizeof argument Leon Romanovsky 2013-05-16 22:13 ` Samuel Ortiz 2013-05-17 17:50 ` Leon Romanovsky 2013-05-17 17:58 ` Joe Perches 2013-05-17 18:16 ` Leon Romanovsky
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox