From patchwork Fri Nov 30 11:57:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13304 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 85B0223FCD for ; Fri, 30 Nov 2012 11:57:59 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id EFC76A1916F for ; Fri, 30 Nov 2012 11:57:58 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so254541iag.11 for ; Fri, 30 Nov 2012 03:57:58 -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:in-reply-to:references :x-gm-message-state; bh=euArGpBf/jj92qHIqGuWBAoAsDuvTQvvCZJxTqaXFEs=; b=pWZVo1YP9Via4hfnnag06C0UG5/4A3o2Ekpp8V5lgoZdfxT8ElpdCDAn+oToBsloP5 ernT6eorXvJSjJ/5WeJzYFBDxk0sonbZgfzHXKJE7GG1ucBzesiwbGCOxDI/EVbE03a9 g7G7ujHJbPtXFNyvmdDWIYzLNhCFaR+jN+6K59oUtvOc6+sKUcZ1jvdjWOY9GrsTh2Sc FvGLohDEvKwHzeCuGFa28cnuGsnqxreYXVkD/LMLiCW4YAg9r2SiexhQ8rm7JAkfz51P fNRNyQWWLMcsVe9RHTTJ0kqraTa8k0Y1xD2c76UZJe1UIc0kuBnkM5CPQmAspfvj0g8n RQhw== Received: by 10.43.49.199 with SMTP id vb7mr725330icb.6.1354276678740; Fri, 30 Nov 2012 03:57:58 -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 n20csp1011260igt; Fri, 30 Nov 2012 03:57:58 -0800 (PST) Received: by 10.180.94.226 with SMTP id df2mr43404008wib.11.1354276677697; Fri, 30 Nov 2012 03:57:57 -0800 (PST) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by mx.google.com with ESMTPS id en3si10960895wib.28.2012.11.30.03.57.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 03:57:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.182; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f182.google.com with SMTP id hn14so177561wib.3 for ; Fri, 30 Nov 2012 03:57:57 -0800 (PST) Received: by 10.180.94.169 with SMTP id dd9mr43365748wib.14.1354276677197; Fri, 30 Nov 2012 03:57:57 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id i6sm14966896wix.5.2012.11.30.03.57.55 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 03:57:56 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: linus.walleij@stericsson.com, arnd@arndb.de, cbou@mail.ru, dwmw2@infradead.org, rajanikanth.hv@linaro.org, Lee Jones Subject: [PATCH 05/12] ab8500-bmdata: Re-jiggle bmdevs_of_probe to be more succinct Date: Fri, 30 Nov 2012 11:57:27 +0000 Message-Id: <1354276654-590-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354276654-590-1-git-send-email-lee.jones@linaro.org> References: <1354276654-590-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnqY75lwWV9t7S3TmrVkIb0SjeeKi+6crX8Rt18J8sH4j2yBzXEjpLYHC+1k7ix3wSkTk3i We can actually write bmdevs_of_probe to be easier to follow, use less lines of code and we can even render a variable unused so that we can remove it completely. Signed-off-by: Lee Jones --- drivers/power/ab8500_bmdata.c | 49 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index 2623b16..df5a590 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -456,38 +456,29 @@ int __devinit bmdevs_of_probe(struct device *dev, struct device_node *np, struct abx500_bm_data **battery) { - struct abx500_battery_type *btype; + struct batres_vs_temp *tmp_batres_tbl; struct device_node *np_bat_supply; struct abx500_bm_data *bat; const char *btech; - int i, thermistor; + int i; *battery = &ab8500_bm_data; /* get phandle to 'battery-info' node */ np_bat_supply = of_parse_phandle(np, "battery", 0); if (!np_bat_supply) { - dev_err(dev, "missing property battery\n"); + dev_err(dev, "battery node or reference missing\n"); return -EINVAL; } - if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) - thermistor = NTC_INTERNAL; - else - thermistor = NTC_EXTERNAL; - - bat = *battery; - if (thermistor == NTC_EXTERNAL) { - bat->n_btypes = 4; - bat->bat_type = bat_type_ext_thermistor; - bat->adc_therm = ABx500_ADC_THERM_BATTEMP; - } - btech = of_get_property(np_bat_supply, "stericsson,battery-type", NULL); if (!btech) { dev_warn(dev, "missing property battery-name/type\n"); return -EINVAL; } + + bat = *battery; + if (strncmp(btech, "LION", 4) == 0) { bat->no_maintenance = true; bat->chg_unknown_bat = true; @@ -498,20 +489,22 @@ int __devinit bmdevs_of_probe(struct device *dev, bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } - /* select the battery resolution table */ - for (i = 0; i < bat->n_btypes; ++i) { - btype = (bat->bat_type + i); - if (thermistor == NTC_EXTERNAL) { - btype->batres_tbl = - temp_to_batres_tbl_ext_thermistor; - } else if (strncmp(btech, "LION", 4) == 0) { - btype->batres_tbl = - temp_to_batres_tbl_9100; - } else { - btype->batres_tbl = - temp_to_batres_tbl_thermistor; - } + if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) { + if (strncmp(btech, "LION", 4) == 0) + tmp_batres_tbl = temp_to_batres_tbl_9100; + else + tmp_batres_tbl = temp_to_batres_tbl_thermistor; + } else { + bat->n_btypes = 4; + bat->bat_type = bat_type_ext_thermistor; + bat->adc_therm = ABx500_ADC_THERM_BATTEMP; + tmp_batres_tbl = temp_to_batres_tbl_ext_thermistor; } + + /* select the battery resolution table */ + for (i = 0; i < bat->n_btypes; ++i) + bat->bat_type[i]->batres_tbl = tmp_batres_tbl; + of_node_put(np_bat_supply); return 0;