From patchwork Fri Jan 30 14:47:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5751551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 179AA9F302 for ; Fri, 30 Jan 2015 14:56:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F4F020219 for ; Fri, 30 Jan 2015 14:56:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DCE2201CE for ; Fri, 30 Jan 2015 14:56:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YHCxX-0003FR-NJ; Fri, 30 Jan 2015 14:54:11 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YHCsO-0007CI-Fn for linux-arm-kernel@lists.infradead.org; Fri, 30 Jan 2015 14:48:58 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIZ002KVW02ZC80@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 30 Jan 2015 14:52:50 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-79-54cb993d16de Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id CD.39.07834.D399BC45; Fri, 30 Jan 2015 14:46:22 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NIZ00EV0VSES470@eusync2.samsung.com>; Fri, 30 Jan 2015 14:48:46 +0000 (GMT) From: Krzysztof Kozlowski To: Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , Len Brown , Jiri Kosina , David Herrmann , Cezary Jackiewicz , Darren Hart , Support Opensource , Milo Kim , Julian Andres Klode , Marc Dietrich , Greg Kroah-Hartman , linux-acpi@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org, patches@opensource.wolfsonmicro.com, ac100@lists.launchpad.net, linux-tegra@vger.kernel.org, devel@driverdev.osuosl.org, Linus Walleij , Samuel Ortiz , Lee Jones , linux-arm-kernel@lists.infradead.org, Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King Subject: [PATCH v3 18/20] power_supply: bq2415x_charger: Decrement the power supply's device reference counter Date: Fri, 30 Jan 2015 15:47:56 +0100 Message-id: <1422629278-12202-19-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1422629278-12202-1-git-send-email-k.kozlowski@samsung.com> References: <1422629278-12202-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAAy2RaUjTcRjH++1/bEqDf57/lCQkMYw8KOshwnoh+KMIigRB0LV0HuGmbDrS Xri0LO+z8k6ZuanlLWjOo3mUzSuXUl7lBeaRZ2ZimkfvPt8vny/Pi4dHGL0jLXiBklCRVCIM sqYNSd3O+89nXbJ07o6btyGpZ5kDVZkVFBR9iCch6u8cCWnTSwRoure4oNSbQVyhI6SWpBMQ raygob/8IjyvMofilZc0NOYqSZifdYKeqAUufPvVgaBhYpGGjG0VB1TNyQiqp4Yo+Lq6QYH+ bS4Na4ntCGLXs2kY0fMhtq8QgWqrnISB1oK9weIuDWMfO2go08wS0K0boCB7wRh08RToGkOh 6fEnAmqqnxGwWTlFXbXFj6ITaKxedcDjzW0kTi5fo3BD9hgXL69445mUdC6uUdvh6TkVhatL Y2k8OqSh8c/eXi7O77qFW/Je7wlFkbgjYZS8aeFpeNlXFBQoF0kdXO4YBrRUjJEhtRb3f6yp OQrUaBqHDHgsc55d1i5yD9mM7R+voOOQIc+IeYXYnBwl5zAkcdiEvEHOvkUz59gaVdGBZcIs GrCdSRpyPxDMCGIbNCUHljETwi5vNZP7TDI2bPvTaWqf+Qxmi+tb/9+zYrs60w96g72+cnby gI0YNzZ5MJNOQfwCdKQUmYrCfEJkd/3FTvYyoVgWJvG39wkWV6PDt6/XI2XnJS1ieMj6KP+L UOduRAnlsnCxFrE8wtqEn5G2V/F9heERImmwQBoWJJJpEYdnYKFAWZzhOv2Gs1WtVpK9euGM 4klqxmr3w8TwqojyU6Q2d3wn/4a3nxd/e2b4u8f8b8W6YFjuVydum7C9cqzpXoSzpUuMRJCj cZDU2u9GXre7poiId/3j+cLFpt8RO3u5LQnm5KhQ5M2cWCo7ftJ8pu+N66RaJA9PWH/QZhmT YuNx2pqUBQid7AipTPgPJop9BtQCAAA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150130_064852_940853_9FECBDC8 X-CRM114-Status: GOOD ( 10.48 ) X-Spam-Score: -5.0 (-----) Cc: Krzysztof Kozlowski , Thomas Gleixner , Kyungmin Park , Pavel Machek , Bartlomiej Zolnierkiewicz X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use power_supply_put() to decrement the power supply's device reference counter (increased by power_supply_get_by_name() or power_supply_get_by_phandle()). Signed-off-by: Krzysztof Kozlowski Acked-by: Pavel Machek Reviewed-by: Bartlomiej Zolnierkiewicz Reviewed-by: Sebastian Reichel --- drivers/power/bq2415x_charger.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index cb92022df8eb..4adcd65bef5b 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -1601,27 +1601,27 @@ static int bq2415x_probe(struct i2c_client *client, ret = of_property_read_u32(np, "ti,current-limit", &bq->init_data.current_limit); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,weak-battery-voltage", &bq->init_data.weak_battery_voltage); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,battery-regulation-voltage", &bq->init_data.battery_regulation_voltage); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,charge-current", &bq->init_data.charge_current); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,termination-current", &bq->init_data.termination_current); if (ret) - goto error_2; + goto error_3; ret = of_property_read_u32(np, "ti,resistor-sense", &bq->init_data.resistor_sense); if (ret) - goto error_2; + goto error_3; } else { memcpy(&bq->init_data, pdata, sizeof(bq->init_data)); } @@ -1631,19 +1631,19 @@ static int bq2415x_probe(struct i2c_client *client, ret = bq2415x_power_supply_init(bq); if (ret) { dev_err(bq->dev, "failed to register power supply: %d\n", ret); - goto error_2; + goto error_3; } ret = bq2415x_sysfs_init(bq); if (ret) { dev_err(bq->dev, "failed to create sysfs entries: %d\n", ret); - goto error_3; + goto error_4; } ret = bq2415x_set_defaults(bq); if (ret) { dev_err(bq->dev, "failed to set default values: %d\n", ret); - goto error_4; + goto error_5; } if (bq->notify_psy) { @@ -1651,7 +1651,7 @@ static int bq2415x_probe(struct i2c_client *client, ret = power_supply_reg_notifier(&bq->nb); if (ret) { dev_err(bq->dev, "failed to reg notifier: %d\n", ret); - goto error_5; + goto error_6; } /* Query for initial reported_mode and set it */ @@ -1671,11 +1671,14 @@ static int bq2415x_probe(struct i2c_client *client, dev_info(bq->dev, "driver registered\n"); return 0; +error_6: error_5: -error_4: bq2415x_sysfs_exit(bq); -error_3: +error_4: bq2415x_power_supply_exit(bq); +error_3: + if (!IS_ERR(bq->notify_psy)) + power_supply_put(bq->notify_psy); error_2: kfree(name); error_1: @@ -1692,8 +1695,10 @@ static int bq2415x_remove(struct i2c_client *client) { struct bq2415x_device *bq = i2c_get_clientdata(client); - if (bq->notify_psy) + if (bq->notify_psy) { power_supply_unreg_notifier(&bq->nb); + power_supply_put(bq->notify_psy); + } bq2415x_sysfs_exit(bq); bq2415x_power_supply_exit(bq);