Skip to content

Commit

Permalink
pinctrl: allocate sizeof(*p) instead of sizeof(struct foo)
Browse files Browse the repository at this point in the history
This hopefully makes it harder to take the sizeof the wrong type.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Dong Aisheng <dong.aisheng@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
nvswarren authored and linusw committed Feb 24, 2012
1 parent 95dcd4a commit 02f5b98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions drivers/pinctrl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ static struct pinctrl *pinctrl_get_locked(struct device *dev, const char *name)
* mapping, this is what consumers will get when requesting
* a pin control handle with pinctrl_get()
*/
p = kzalloc(sizeof(struct pinctrl), GFP_KERNEL);
p = kzalloc(sizeof(*p), GFP_KERNEL);
if (p == NULL) {
dev_err(dev, "failed to alloc struct pinctrl\n");
return ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -726,7 +726,7 @@ static int pinctrl_hog_map(struct pinctrl_dev *pctldev,
struct pinctrl *p;
int ret;

hog = kzalloc(sizeof(struct pinctrl_hog), GFP_KERNEL);
hog = kzalloc(sizeof(*hog), GFP_KERNEL);
if (!hog) {
dev_err(pctldev->dev, "failed to alloc struct pinctrl_hog\n");
return -ENOMEM;
Expand Down Expand Up @@ -1160,7 +1160,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
if (pctldesc->name == NULL)
return NULL;

pctldev = kzalloc(sizeof(struct pinctrl_dev), GFP_KERNEL);
pctldev = kzalloc(sizeof(*pctldev), GFP_KERNEL);
if (pctldev == NULL) {
dev_err(dev, "failed to alloc struct pinctrl_dev\n");
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/pinctrl/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
p->func_selector = func_selector;

/* Now add this group selector, we may have many of them */
grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL);
grp = kmalloc(sizeof(*grp), GFP_KERNEL);
if (!grp)
return -ENOMEM;
grp->group_selector = group_selector;
Expand Down

0 comments on commit 02f5b98

Please sign in to comment.