[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <B168F8A49F4BCF4C84FD23DA5F6363EE010780@NWD2MBX7.ad.analog.com>
Date: Fri, 24 May 2013 04:32:15 +0000
From: "Zhang, Sonic" <Sonic.Zhang@...log.com>
To: Libo Chen <libo.chen@...wei.com>,
"wsa@...-dreams.de" <wsa@...-dreams.de>
CC: "guz.fnst@...fujitsu.com" <guz.fnst@...fujitsu.com>,
"uclinux-dist-devel@...ckfin.uclinux.org"
<uclinux-dist-devel@...ckfin.uclinux.org>,
"linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lizefan@...wei.com" <lizefan@...wei.com>
Subject: RE: [PATCH RFC v3 1/3] i2c: i2c-bfin-twi: convert to devm_* API
Acked-by: Sonic Zhang <sonic.zhang@...log.com>
>-----Original Message-----
>From: Libo Chen [mailto:libo.chen@...wei.com]
>Sent: Thursday, May 23, 2013 8:00 PM
>To: wsa@...-dreams.de
>Cc: guz.fnst@...fujitsu.com; Zhang, Sonic; uclinux-dist-
>devel@...ckfin.uclinux.org; linux-i2c@...r.kernel.org; linux-
>kernel@...r.kernel.org; lizefan@...wei.com; libo.chen@...wei.com
>Subject: [PATCH RFC v3 1/3] i2c: i2c-bfin-twi: convert to devm_* API
>
>peripheral_request_list has got free if any one faild, so no need to free again in err
>case.
>aovid this, convert them to devm_* API
>
>Signed-off-by: Libo Chen <libo.chen@...wei.com>
>---
> drivers/i2c/busses/i2c-bfin-twi.c | 38 +++++++++---------------------------
> 1 files changed, 10 insertions(+), 28 deletions(-)
>
>diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>index 05080c4..2b99c48 100644
>--- a/drivers/i2c/busses/i2c-bfin-twi.c
>+++ b/drivers/i2c/busses/i2c-bfin-twi.c
>@@ -621,35 +621,27 @@ static int i2c_bfin_twi_probe(struct platform_device
>*pdev)
> int rc;
> unsigned int clkhilow;
>
>- iface = kzalloc(sizeof(struct bfin_twi_iface), GFP_KERNEL);
>+ iface = devm_kzalloc(&pdev->dev, sizeof(struct bfin_twi_iface),
>+ GFP_KERNEL);
> if (!iface) {
> dev_err(&pdev->dev, "Cannot allocate memory\n");
>- rc = -ENOMEM;
>- goto out_error_nomem;
>+ return -ENOMEM;
> }
>
> spin_lock_init(&(iface->lock));
>
> /* Find and map our resources */
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>- if (res == NULL) {
>- dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
>- rc = -ENOENT;
>- goto out_error_get_res;
>- }
>-
>- iface->regs_base = ioremap(res->start, resource_size(res));
>- if (iface->regs_base == NULL) {
>+ iface->regs_base = devm_ioremap_resource(&pdev->dev, res);
>+ if (IS_ERR(iface->regs_base)) {
> dev_err(&pdev->dev, "Cannot map IO\n");
>- rc = -ENXIO;
>- goto out_error_ioremap;
>+ return -ENXIO;
> }
>
> iface->irq = platform_get_irq(pdev, 0);
> if (iface->irq < 0) {
> dev_err(&pdev->dev, "No IRQ specified\n");
>- rc = -ENOENT;
>- goto out_error_no_irq;
>+ return -ENOENT;
> }
>
> p_adap = &iface->adap;
>@@ -666,10 +658,10 @@ static int i2c_bfin_twi_probe(struct platform_device
>*pdev)
> "i2c-bfin-twi");
> if (rc) {
> dev_err(&pdev->dev, "Can't setup pin mux!\n");
>- goto out_error_pin_mux;
>+ return rc;
> }
>
>- rc = request_irq(iface->irq, bfin_twi_interrupt_entry,
>+ rc = devm_request_irq(&pdev->dev, iface->irq,
>+bfin_twi_interrupt_entry,
> 0, pdev->name, iface);
> if (rc) {
> dev_err(&pdev->dev, "Can't get IRQ %d !\n", iface->irq); @@ -
>707,16 +699,9 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
> return 0;
>
> out_error_add_adapter:
>- free_irq(iface->irq, iface);
> out_error_req_irq:
>-out_error_no_irq:
> peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>-out_error_pin_mux:
>- iounmap(iface->regs_base);
>-out_error_ioremap:
>-out_error_get_res:
>- kfree(iface);
>-out_error_nomem:
>+
> return rc;
> }
>
>@@ -725,10 +710,7 @@ static int i2c_bfin_twi_remove(struct platform_device
>*pdev)
> struct bfin_twi_iface *iface = platform_get_drvdata(pdev);
>
> i2c_del_adapter(&(iface->adap));
>- free_irq(iface->irq, iface);
> peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>- iounmap(iface->regs_base);
>- kfree(iface);
>
> return 0;
> }
>--
>1.7.1
>
>
--
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