From patchwork Thu Mar 12 07:44:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5991831 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0927CBF911 for ; Thu, 12 Mar 2015 07:52:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31441200CF for ; Thu, 12 Mar 2015 07:52:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 364662034F for ; Thu, 12 Mar 2015 07:52:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753512AbbCLHpW (ORCPT ); Thu, 12 Mar 2015 03:45:22 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:60112 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753222AbbCLHpG (ORCPT ); Thu, 12 Mar 2015 03:45:06 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NL3003EK9PPQT50@mailout4.w1.samsung.com>; Thu, 12 Mar 2015 07:49:02 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-93-5501436e5a0f Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 9C.FA.07834.E6341055; Thu, 12 Mar 2015 07:42:38 +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 <0NL300KWS9IOZC60@eusync2.samsung.com>; Thu, 12 Mar 2015 07:45:03 +0000 (GMT) From: Krzysztof Kozlowski To: Jiri Kosina , Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RESEND PATCH v6 20/22] power_supply: bq2415x_charger: Decrement the power supply's device reference counter Date: Thu, 12 Mar 2015 08:44:18 +0100 Message-id: <1426146260-30081-21-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1426146260-30081-1-git-send-email-k.kozlowski@samsung.com> References: <1426146260-30081-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnluLIzCtJLcpLzFFi42I5/e/4Fd08Z8ZQg9PHzSwmPXnPbDFx5WRm i91zFrNYvH5haHHz0zdWi8u75rBZfO49wmhx4ts0JovTu0scOD0+r3rF6rFz1l12j80rtDw2 repk8+jbsorR48yCI+wenzfJBbBHcdmkpOZklqUW6dslcGV8eP6VvWC1VMX6Bd/ZGhg3iXYx cnJICJhIHHm1nhHCFpO4cG89WxcjF4eQwFJGibu3j7JDOH1MEqt62tlBqtgEjCU2L18CViUi MJ9Jon/VCVaQBLOAocTPd3/AioQFyiVevjrCBmKzCKhK3LvbBxbnFfCQmLHmPdQ6OYmTxyYD 9XJwcALFXy/iAQkLCbhLzFz2iX0CI+8CRoZVjKKppckFxUnpuYZ6xYm5xaV56XrJ+bmbGCGB 92UH4+JjVocYBTgYlXh4I/oYQoVYE8uKK3MPMUpwMCuJ8HJYMYYK8aYkVlalFuXHF5XmpBYf YmTi4JRqYEztLX1Q2p/SuVel9H1M9Z64P6kT7fmKBRv/tXy3fJET/EXy4fwrd8UmyGqGng0M OfHmr77mDvE3LE5dsd5Tnj8Mfz+rTpiBc8/VPZ/uM747IHVMkmvDSy7WF38XzDVRnSblMblm VrOa2sO2ry5f9yqourxt3WR8e9KmhekyfBcc/0WWBrmI6CqxFGckGmoxFxUnAgD1veFfGgIA AA== Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 c745d278815d..6c534dcbc19c 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -1594,27 +1594,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)); } @@ -1624,19 +1624,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) { @@ -1644,7 +1644,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 */ @@ -1664,11 +1664,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 (bq->notify_psy) + power_supply_put(bq->notify_psy); error_2: kfree(name); error_1: @@ -1685,8 +1688,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);