From patchwork Mon Sep 19 09:46:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Phil Reid X-Patchwork-Id: 9338915 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DACB060B16 for ; Mon, 19 Sep 2016 09:46:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB76529177 for ; Mon, 19 Sep 2016 09:46:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C00A2291A0; Mon, 19 Sep 2016 09:46:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E91FF29177 for ; Mon, 19 Sep 2016 09:46:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754425AbcISJqb (ORCPT ); Mon, 19 Sep 2016 05:46:31 -0400 Received: from 203-59-230-133.perm.iinet.net.au ([203.59.230.133]:40104 "EHLO preid-centos7.electromag.com.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754796AbcISJq0 (ORCPT ); Mon, 19 Sep 2016 05:46:26 -0400 Received: by preid-centos7.electromag.com.au (Postfix, from userid 1000) id 5B04932B8BCCE; Mon, 19 Sep 2016 17:46:20 +0800 (AWST) From: Phil Reid To: sre@kernel.org, linux-pm@vger.kernel.org Cc: Phil Reid Subject: [PATCH 1/1] power: supply: sbs-battery: Cleanup removal of chip->pdata Date: Mon, 19 Sep 2016 17:46:12 +0800 Message-Id: <1474278372-38077-1-git-send-email-preid@electromag.com.au> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There where still a few lingering references to pdata after commit power: supply: sbs-battery: simplify DT parsing. Remove pdata from struct·sbs_info and conditional checks to ser if this was set from the i2c read / write functions. Instead of call max in each function for incrementing poll_retry_count do it once in the probe function. Fixup null pointer dereference in to pdata in sbs_external_power_changed. Signed-off-by: Phil Reid --- drivers/power/supply/sbs-battery.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c index 248a5dd..3ffa0ec 100644 --- a/drivers/power/supply/sbs-battery.c +++ b/drivers/power/supply/sbs-battery.c @@ -163,7 +163,6 @@ static enum power_supply_property sbs_properties[] = { struct sbs_info { struct i2c_client *client; struct power_supply *power_supply; - struct sbs_platform_data *pdata; bool is_present; struct gpio_desc *gpio_detect; bool enable_detection; @@ -185,8 +184,7 @@ static int sbs_read_word_data(struct i2c_client *client, u8 address) s32 ret = 0; int retries = 1; - if (chip->pdata) - retries = max(chip->i2c_retry_count + 1, 1); + retries = chip->i2c_retry_count + 1; while (retries > 0) { ret = i2c_smbus_read_word_data(client, address); @@ -213,10 +211,8 @@ static int sbs_read_string_data(struct i2c_client *client, u8 address, int retries_length = 1, retries_block = 1; u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; - if (chip->pdata) { - retries_length = max(chip->i2c_retry_count + 1, 1); - retries_block = max(chip->i2c_retry_count + 1, 1); - } + retries_length = chip->i2c_retry_count; + retries_block = chip->i2c_retry_count; /* Adapter needs to support these two functions */ if (!i2c_check_functionality(client->adapter, @@ -280,8 +276,7 @@ static int sbs_write_word_data(struct i2c_client *client, u8 address, s32 ret = 0; int retries = 1; - if (chip->pdata) - retries = max(chip->i2c_retry_count + 1, 1); + retries = max(chip->i2c_retry_count + 1, 1); while (retries > 0) { ret = i2c_smbus_write_word_data(client, address, @@ -707,7 +702,7 @@ static void sbs_external_power_changed(struct power_supply *psy) cancel_delayed_work_sync(&chip->work); schedule_delayed_work(&chip->work, HZ); - chip->poll_time = chip->pdata->poll_retry_count; + chip->poll_time = chip->poll_retry_count; } static void sbs_delayed_work(struct work_struct *work) @@ -791,7 +786,7 @@ static int sbs_probe(struct i2c_client *client, rc = of_property_read_u32(client->dev.of_node, "sbs,i2c-retry-count", &chip->i2c_retry_count); if (rc) - chip->i2c_retry_count = 1; + chip->i2c_retry_count = 0; rc = of_property_read_u32(client->dev.of_node, "sbs,poll-retry-count", &chip->poll_retry_count); @@ -802,6 +797,7 @@ static int sbs_probe(struct i2c_client *client, chip->poll_retry_count = pdata->poll_retry_count; chip->i2c_retry_count = pdata->i2c_retry_count; } + chip->i2c_retry_count = max(chip->i2c_retry_count + 1, 1); chip->gpio_detect = devm_gpiod_get_optional(&client->dev, "sbs,battery-detect", GPIOD_IN);