From patchwork Fri Nov 23 12:41:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tushar Behera X-Patchwork-Id: 13157 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5C2EA23FC2 for ; Fri, 23 Nov 2012 12:48:12 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id ECD15A194CC for ; Fri, 23 Nov 2012 12:48:11 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so1760039ieb.11 for ; Fri, 23 Nov 2012 04:48:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=BluWN+QXf3hcjHg4lcZxPz/PBt24Ixtqusp7cVkcKfc=; b=bV+MbtmhvIPA0JK3NWR1V9jZeTAY0vimHd9p9sfn3sme/xhXyl9JV/lbjkdreZS+4i uTuCXnkhFYhH1Nhua1H50YfxcTd7MU/Lxqsjb5JO/Ov2E2sTbvm+TC9QlHhlMuTv7jsy +YdHdMzX4ACyZ7LjlK4/owWmpjzrAt3b214z3LuymtLG4+SuGp+RXVTP4GcTM9B45LiH +sUgyG6Y53RpsVvlmG3Hh7TZUyPB7l7VvgAoOXYHs8U0rl59Qzf2VkAZSLvJkwbr+u/w 83NP++xXCkahgICY0ZM4UVADLtjyRn5OUlqsOFaUYq5/ShtOO722VcNSGcox6Qlwvwp3 CIbQ== Received: by 10.43.46.2 with SMTP id um2mr3008808icb.18.1353674891409; Fri, 23 Nov 2012 04:48:11 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp346990igt; Fri, 23 Nov 2012 04:48:11 -0800 (PST) Received: by 10.68.213.33 with SMTP id np1mr13959464pbc.64.1353674890837; Fri, 23 Nov 2012 04:48:10 -0800 (PST) Received: from mail-da0-f50.google.com (mail-da0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id q6si7891631pay.23.2012.11.23.04.48.10 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Nov 2012 04:48:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of tushar.behera@linaro.org) smtp.mail=tushar.behera@linaro.org Received: by mail-da0-f50.google.com with SMTP id h15so1215818dan.37 for ; Fri, 23 Nov 2012 04:48:10 -0800 (PST) Received: by 10.66.89.9 with SMTP id bk9mr9999651pab.67.1353674890518; Fri, 23 Nov 2012 04:48:10 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id se4sm3794184pbb.13.2012.11.23.04.48.07 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 23 Nov 2012 04:48:09 -0800 (PST) From: Tushar Behera To: linux-kernel@vger.kernel.org Cc: dwmw2@infradead.org, cbou@mail.ru, patches@linaro.org Subject: [PATCH] power: 88pm860x_battery: Add a few more devm_* APIs Date: Fri, 23 Nov 2012 18:11:52 +0530 Message-Id: <1353674512-16119-1-git-send-email-tushar.behera@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQktPBJpsP5JankQ3W6lQXv9Mw5B+ztefJj+uaaeyT7if+oZTjfDHpgwFYF+XqpadfDLssRP Add devm_* APIs for threaded IRQ. Also since devres managed objects are removed when the device gets detached, remove explicit freeing of them. Signed-off-by: Tushar Behera --- drivers/power/88pm860x_battery.c | 25 ++++++++----------------- 1 files changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/88pm860x_battery.c index beed5ecf..a245aa4 100644 --- a/drivers/power/88pm860x_battery.c +++ b/drivers/power/88pm860x_battery.c @@ -915,15 +915,13 @@ static __devinit int pm860x_battery_probe(struct platform_device *pdev) info->irq_cc = platform_get_irq(pdev, 0); if (info->irq_cc <= 0) { dev_err(&pdev->dev, "No IRQ resource!\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } info->irq_batt = platform_get_irq(pdev, 1); if (info->irq_batt <= 0) { dev_err(&pdev->dev, "No IRQ resource!\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } info->chip = chip; @@ -957,10 +955,10 @@ static __devinit int pm860x_battery_probe(struct platform_device *pdev) ret = power_supply_register(&pdev->dev, &info->battery); if (ret) - goto out; + return ret; info->battery.dev->parent = &pdev->dev; - ret = request_threaded_irq(info->irq_cc, NULL, + ret = devm_request_threaded_irq(&pdev->dev, info->irq_cc, NULL, pm860x_coulomb_handler, IRQF_ONESHOT, "coulomb", info); if (ret < 0) { @@ -969,23 +967,19 @@ static __devinit int pm860x_battery_probe(struct platform_device *pdev) goto out_reg; } - ret = request_threaded_irq(info->irq_batt, NULL, pm860x_batt_handler, - IRQF_ONESHOT, "battery", info); + ret = devm_request_threaded_irq(&pdev->dev, info->irq_batt, NULL, + pm860x_batt_handler, IRQF_ONESHOT, + "battery", info); if (ret < 0) { dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", info->irq_batt, ret); - goto out_coulomb; + goto out_reg; } - return 0; -out_coulomb: - free_irq(info->irq_cc, info); out_reg: power_supply_unregister(&info->battery); -out: - kfree(info); return ret; } @@ -994,9 +988,6 @@ static int __devexit pm860x_battery_remove(struct platform_device *pdev) struct pm860x_battery_info *info = platform_get_drvdata(pdev); power_supply_unregister(&info->battery); - free_irq(info->irq_batt, info); - free_irq(info->irq_cc, info); - kfree(info); platform_set_drvdata(pdev, NULL); return 0; }