Re: [PATCH] leds-88pm860x: use devm_kzalloc function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Mon, Jul 2, 2012 at 6:15 PM, Devendra Naga <devendra.aaru@xxxxxxxxx> wrote:
> Using devm_kzalloc will remove all the error checks and the frees are automatically done at the driver unload side.
>
> Signed-off-by: Devendra Naga <devendra.aaru@xxxxxxxxx>

Great, Applied to my for-next branch. Thanks,

-Bryan

> ---
>
> Thanks Bryan for advising me.. ;-)
>
>  drivers/leds/leds-88pm860x.c |    9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c
> index 5b61aaf..61897cf 100644
> --- a/drivers/leds/leds-88pm860x.c
> +++ b/drivers/leds/leds-88pm860x.c
> @@ -209,7 +209,7 @@ static int pm860x_led_probe(struct platform_device *pdev)
>                 return -EINVAL;
>         }
>
> -       data = kzalloc(sizeof(struct pm860x_led), GFP_KERNEL);
> +       data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL);
>         if (data == NULL)
>                 return -ENOMEM;
>         strncpy(data->name, res->name, MFD_NAME_SIZE - 1);
> @@ -220,7 +220,6 @@ static int pm860x_led_probe(struct platform_device *pdev)
>         data->port = pdata->flags;
>         if (data->port < 0) {
>                 dev_err(&pdev->dev, "check device failed\n");
> -               kfree(data);
>                 return -EINVAL;
>         }
>
> @@ -233,13 +232,10 @@ static int pm860x_led_probe(struct platform_device *pdev)
>         ret = led_classdev_register(chip->dev, &data->cdev);
>         if (ret < 0) {
>                 dev_err(&pdev->dev, "Failed to register LED: %d\n", ret);
> -               goto out;
> +               return ret;
>         }
>         pm860x_led_set(&data->cdev, 0);
>         return 0;
> -out:
> -       kfree(data);
> -       return ret;
>  }
>
>  static int pm860x_led_remove(struct platform_device *pdev)
> @@ -247,7 +243,6 @@ static int pm860x_led_remove(struct platform_device *pdev)
>         struct pm860x_led *data = platform_get_drvdata(pdev);
>
>         led_classdev_unregister(&data->cdev);
> -       kfree(data);
>
>         return 0;
>  }
> --
> 1.7.9.5
>



-- 
Bryan Wu <bryan.wu@xxxxxxxxxxxxx>
Kernel Developer    +86.186-168-78255 Mobile
Canonical Ltd.      www.canonical.com
Ubuntu - Linux for human beings | www.ubuntu.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[Other Archives]     [Linux Kernel Newbies]     [Linux Driver Development]     [Linux Kbuild]     [Fedora Kernel]     [Linux Kernel Testers]     [Linux SH]     [Linux Omap]     [Linux Tape]     [Linux Input]     [Linux Kernel Janitors]     [Linux Kernel Packagers]     [Linux Doc]     [Linux Man Pages]     [Linux API]     [Linux Memory Management]     [Linux Modules]     [Linux Standards]     [Kernel Announce]     [Netdev]     [Git]     [Linux PCI]     Linux CAN Development     [Linux I2C]     [Linux RDMA]     [Linux NUMA]     [Netfilter]     [Netfilter Devel]     [SELinux]     [Bugtraq]     [FIO]     [Linux Perf Users]     [Linux Serial]     [Linux PPP]     [Linux ISDN]     [Linux Next]     [Kernel Stable Commits]     [Linux Tip Commits]     [Kernel MM Commits]     [Linux Security Module]     [AutoFS]     [Filesystem Development]     [Ext3 Filesystem]     [Linux bcache]     [Ext4 Filesystem]     [Linux BTRFS]     [Linux CEPH Filesystem]     [Linux XFS]     [XFS]     [Linux NFS]     [Linux CIFS]     [Ecryptfs]     [Linux NILFS]     [Linux Cachefs]     [Reiser FS]     [Initramfs]     [Linux FB Devel]     [Linux OpenGL]     [DRI Devel]     [Fastboot]     [Linux RT Users]     [Linux RT Stable]     [eCos]     [Corosync]     [Linux Clusters]     [LVS Devel]     [Hot Plug]     [Linux Virtualization]     [KVM]     [KVM PPC]     [KVM ia64]     [Linux Containers]     [Linux Hexagon]     [Linux Cgroups]     [Util Linux]     [Wireless]     [Linux Bluetooth]     [Bluez Devel]     [Ethernet Bridging]     [Embedded Linux]     [Barebox]     [Linux MMC]     [Linux IIO]     [Sparse]     [Smatch]     [Linux Arch]     [x86 Platform Driver]     [Linux ACPI]     [Linux IBM ACPI]     [LM Sensors]     [CPU Freq]     [Linux Power Management]     [Linmodems]     [Linux DCCP]     [Linux SCTP]     [ALSA Devel]     [Linux USB]     [Linux PA RISC]     [Linux Samsung SOC]     [MIPS Linux]     [IBM S/390 Linux]     [ARM Linux]     [ARM Kernel]     [ARM MSM]     [Tegra Devel]     [Sparc Linux]     [Linux Security]     [Linux Sound]     [Linux Media]     [Video 4 Linux]     [Linux IRDA Users]     [Linux for the blind]     [Linux RAID]     [Linux ATA RAID]     [Device Mapper]     [Linux SCSI]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Linux IDE]     [Linux SMP]     [Linux AXP]     [Linux Alpha]     [Linux M68K]     [Linux ia64]     [Linux 8086]     [Linux x86_64]     [Linux Config]     [Linux Apps]     [Linux MSDOS]     [Linux X.25]     [Linux Crypto]     [DM Crypt]     [Linux Trace Users]     [Linux Btrace]     [Linux Watchdog]     [Utrace Devel]     [Linux C Programming]     [Linux Assembly]     [Dash]     [DWARVES]     [Hail Devel]     [Linux Kernel Debugger]     [Linux gcc]     [Gcc Help]     [X.Org]     [Wine]

Add to Google Powered by Linux

[Older Kernel Discussion]     [Yosemite National Park Forum]     [Large Format Photos]     [Gimp]     [Yosemite Photos]     [Stuff]