lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 10 Oct 2011 19:23:46 +0800
From:	Barry Song <21cnbao@...il.com>
To:	Linus Walleij <linus.walleij@...aro.org>
Cc:	Linus Walleij <linus.walleij@...ricsson.com>,
	linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
	Grant Likely <grant.likely@...retlab.ca>,
	Stephen Warren <swarren@...dia.com>,
	Lee Jones <lee.jones@...aro.org>,
	Joe Perches <joe@...ches.com>,
	Russell King <linux@....linux.org.uk>,
	Linaro Dev <linaro-dev@...ts.linaro.org>,
	Sascha Hauer <s.hauer@...gutronix.de>,
	David Brown <davidb@...eaurora.org>
Subject: Re: [PATCH 2/2] pinmux: add a driver for the U300 pinmux

2011/10/10 Linus Walleij <linus.walleij@...aro.org>:
> On Sat, Oct 8, 2011 at 11:09 AM, Barry Song <21cnbao@...il.com> wrote:
>>> +static void __init u300_pmx_dumpregs(struct u300_pmx *upmx)
>>> +{
>>> +       u16 regval;
>>> +       int i;
>>> +
>>> +       for (i = 0; i < ARRAY_SIZE(u300_pmx_registers); i++) {
>>> +               regval = readw(upmx->virtbase + u300_pmx_registers[i]);
>>> +               dev_info(upmx->dev, "PMX%u: 0x%04x\n", i, regval);
>>> +       }
>>> +}
>>
>> is this a debug information or do you want it to be in mainline?
>
> Debug info, I'll delete it. Not that it hurt, but I'll kill it.
>
>>> +       /* Create state holders etc for this driver */
>>> +       upmx = devm_kzalloc(&pdev->dev, sizeof(struct u300_pmx), GFP_KERNEL);
>>
>> and this would be "devm_kzalloc(&pdev->dev, sizeof(*upmx), GFP_KERNEL); " ?
>
> Same semantic effect, but if you prefer it that way, sure :-)
>
> I've seen both used in the kernel before...

coding style document says :
"
                  Chapter 14: Allocating memory

  The kernel provides the following general purpose memory allocators:
  kmalloc(), kzalloc(), kcalloc(), vmalloc(), and vzalloc().  Please refer to
  the API documentation for further information about them.

 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.
"
>
> Can I have your Reviewed-by: tag after this?

yes. of course.

>
> Linus Walleij
>
Thanks
barry
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ