From patchwork Fri Nov 30 11:57:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13307 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 3506623FCD for ; Fri, 30 Nov 2012 11:58:03 +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 C077CA1916F for ; Fri, 30 Nov 2012 11:58:02 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so449749ieb.11 for ; Fri, 30 Nov 2012 03:58:02 -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=SNGo1ANoyOxzEMxEzmg9e93nxXf3MkjaTOq4aPnkqFg=; b=dz64xf/jaBzOSMxY1DH3rvnTx+xVax859T57AxYmyicrafdql/gwOrvVUmHyBkqrjV WKIpBd0ADE+AgfzzUEUVkJlJvcNDmth13sczJbc73Urvu0TPQcCRHrNg1gRx3Z+CLnvo tZ5o7MjuQUYY75lX/J2b0feJHRw6sZfRH8t9Ay1C7IL4KZbndZL0tf977rkT7/0GUa0q 3I+NH+0nSW9xkPKjwrPsAgeN8cADEJED19UysXoCSgDMir1GFD/FVUGh/vdaaoO8Bnl0 PzhtDF+5RhRUY4W2UQFfRf5C+gVy6KPlJfDrByeTBwJruZqV4H7hwrwMoNafvvWeD6zc 5VYw== Received: by 10.50.173.34 with SMTP id bh2mr729806igc.70.1354276682517; Fri, 30 Nov 2012 03:58:02 -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 n20csp1011275igt; Fri, 30 Nov 2012 03:58:01 -0800 (PST) Received: by 10.216.209.130 with SMTP id s2mr434178weo.86.1354276681159; Fri, 30 Nov 2012 03:58:01 -0800 (PST) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by mx.google.com with ESMTPS id fa6si5193001wid.27.2012.11.30.03.58.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 03:58:01 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.176 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.176; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.176 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-f176.google.com with SMTP id hm6so5902499wib.15 for ; Fri, 30 Nov 2012 03:58:00 -0800 (PST) Received: by 10.216.213.84 with SMTP id z62mr401104weo.207.1354276680631; Fri, 30 Nov 2012 03:58:00 -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.59 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 03:57:59 -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 , Samuel Ortiz Subject: [PATCH 07/12] ab8500_bm: Always send platform specific battery information via pdata Date: Fri, 30 Nov 2012 11:57:29 +0000 Message-Id: <1354276654-590-8-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: ALoCoQlByVrLv3E4xsWcGmNXs5q28aJWAKeTDXGpr1IkXuc3ol7gKjS7afI0C+7euH2zvgrmrpRj Currently the AB8500 battery management subsystem receives platform specific information via two different means depending on how the platform is booted. If DT is not enabled, a reference to a *_bm_data data structure containing each platform specific attribute is passed though platform_data. However, if DT is enabled, then platform_data is empty and the reference is gained though a DT specific probe function. There are two issues here 1) the same reference is being collected each time and 2) the DT way doesn't allow any provisions to select different platform specific attributes, which kind of defeats the object. Cc: Samuel Ortiz Signed-off-by: Lee Jones --- drivers/mfd/ab8500-core.c | 8 -------- drivers/power/ab8500_bmdata.c | 33 ++++++++++++++------------------- drivers/power/ab8500_btemp.c | 2 +- drivers/power/ab8500_charger.c | 2 +- drivers/power/ab8500_fg.c | 2 +- drivers/power/abx500_chargalg.c | 2 +- include/linux/mfd/abx500.h | 2 +- 7 files changed, 19 insertions(+), 32 deletions(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 7745c96..757fec8 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -1012,40 +1012,32 @@ static struct mfd_cell __devinitdata ab8500_bm_devs[] = { .of_compatible = "stericsson,ab8500-charger", .num_resources = ARRAY_SIZE(ab8500_charger_resources), .resources = ab8500_charger_resources, -#ifndef CONFIG_OF .platform_data = &ab8500_bm_data, .pdata_size = sizeof(ab8500_bm_data), -#endif }, { .name = "ab8500-btemp", .of_compatible = "stericsson,ab8500-btemp", .num_resources = ARRAY_SIZE(ab8500_btemp_resources), .resources = ab8500_btemp_resources, -#ifndef CONFIG_OF .platform_data = &ab8500_bm_data, .pdata_size = sizeof(ab8500_bm_data), -#endif }, { .name = "ab8500-fg", .of_compatible = "stericsson,ab8500-fg", .num_resources = ARRAY_SIZE(ab8500_fg_resources), .resources = ab8500_fg_resources, -#ifndef CONFIG_OF .platform_data = &ab8500_bm_data, .pdata_size = sizeof(ab8500_bm_data), -#endif }, { .name = "ab8500-chargalg", .of_compatible = "stericsson,ab8500-chargalg", .num_resources = ARRAY_SIZE(ab8500_chargalg_resources), .resources = ab8500_chargalg_resources, -#ifndef CONFIG_OF .platform_data = &ab8500_bm_data, .pdata_size = sizeof(ab8500_bm_data), -#endif }, }; diff --git a/drivers/power/ab8500_bmdata.c b/drivers/power/ab8500_bmdata.c index c2fb2c5..6b772e5 100644 --- a/drivers/power/ab8500_bmdata.c +++ b/drivers/power/ab8500_bmdata.c @@ -454,16 +454,13 @@ struct abx500_bm_data ab8500_bm_data = { int __devinit ab8500_bm_of_probe(struct device *dev, struct device_node *np, - struct abx500_bm_data **battery) + struct abx500_bm_data *bm) { struct batres_vs_temp *tmp_batres_tbl; struct device_node *np_bat_supply; - struct abx500_bm_data *bat; const char *btech; 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) { @@ -477,16 +474,14 @@ int __devinit ab8500_bm_of_probe(struct device *dev, return -EINVAL; } - bat = *battery; - if (strncmp(btech, "LION", 4) == 0) { - bat->no_maintenance = true; - bat->chg_unknown_bat = true; - bat->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; - bat->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; - bat->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; - bat->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; - bat->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; + bm->no_maintenance = true; + bm->chg_unknown_bat = true; + bm->bat_type[BATTERY_UNKNOWN].charge_full_design = 2600; + bm->bat_type[BATTERY_UNKNOWN].termination_vol = 4150; + bm->bat_type[BATTERY_UNKNOWN].recharge_vol = 4130; + bm->bat_type[BATTERY_UNKNOWN].normal_cur_lvl = 520; + bm->bat_type[BATTERY_UNKNOWN].normal_vol_lvl = 4200; } if (of_property_read_bool(np_bat_supply, "thermistor-on-batctrl")) { @@ -495,15 +490,15 @@ int __devinit ab8500_bm_of_probe(struct device *dev, 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; + bm->n_btypes = 4; + bm->bat_type = bat_type_ext_thermistor; + bm->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; + for (i = 0; i < bm->n_btypes; ++i) + bm->bat_type[i].batres_tbl = tmp_batres_tbl; of_node_put(np_bat_supply); diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index 33ed0fc..c0f7dcc 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -988,7 +988,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) di->bm = pdev->mfd_cell->platform_data; if (!di->bm) { if (np) { - ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm); + ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); if (ret) { dev_err(&pdev->dev, "failed to get battery information\n"); diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 21dc842..c1077df 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -2647,7 +2647,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev) di->bm = pdev->mfd_cell->platform_data; if (!di->bm) { if (np) { - ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm); + ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); if (ret) { dev_err(&pdev->dev, "failed to get battery information\n"); diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index 4cf2313..8bb9df9 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c @@ -2460,7 +2460,7 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev) di->bm = pdev->mfd_cell->platform_data; if (!di->bm) { if (np) { - ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm); + ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); if (ret) { dev_err(&pdev->dev, "failed to get battery information\n"); diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index ea2e2eb..22a511c 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -1817,7 +1817,7 @@ static int __devinit abx500_chargalg_probe(struct platform_device *pdev) di->bm = pdev->mfd_cell->platform_data; if (!di->bm) { if (np) { - ret = ab8500_bm_of_probe(&pdev->dev, np, &di->bm); + ret = ab8500_bm_of_probe(&pdev->dev, np, di->bm); if (ret) { dev_err(&pdev->dev, "failed to get battery information\n"); diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h index e10662a..68e5759 100644 --- a/include/linux/mfd/abx500.h +++ b/include/linux/mfd/abx500.h @@ -292,7 +292,7 @@ enum { int ab8500_bm_of_probe(struct device *dev, struct device_node *np, - struct abx500_bm_data **battery); + struct abx500_bm_data *bm); int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg, u8 value);