From patchwork Fri Nov 30 11:57:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13303 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 B88A523FCD for ; Fri, 30 Nov 2012 11:57:56 +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 630B8A1915F for ; Fri, 30 Nov 2012 11:57:56 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so254541iag.11 for ; Fri, 30 Nov 2012 03:57:56 -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=F3kjhUlhNmSQ8TdXwNOU0yGhA0kdfkl8Rwd8WJecfjQ=; b=lVpdLSQiea39EoaPRY0mSNuAonJNbP3/Ti2vI8AiPHYtGBIlxFypincfziX0/vxVbU RW7Q91yLh2N3rJrOMTt+Asr0ThntDEIyntJgfn05ynIatOfV/kYek+t1kbjlr0pkXebM 45YsSk/6oE7fvxbioMuOP36GVMi5iAfSVhIFZl2DD8Vn9N/5xlu5v+FreZmme3IhQ2MT ZUl7HRLHvMtyCtmj37TEBc4oxV6NOdzFHRisbqzf5zy9v4wxtWdz0HSfhdtUVFXES5Ia j1aSHSmmfs8SYOMHcVb78tKNMdSSj9KJEvHpsSsL27QuKjPSTl5kZys76Pc0qMYmaXFs iMEQ== Received: by 10.50.42.168 with SMTP id p8mr749590igl.57.1354276676143; Fri, 30 Nov 2012 03:57:56 -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 n20csp1011251igt; Fri, 30 Nov 2012 03:57:54 -0800 (PST) Received: by 10.216.29.138 with SMTP id i10mr425539wea.36.1354276674425; Fri, 30 Nov 2012 03:57:54 -0800 (PST) Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by mx.google.com with ESMTPS id f16si2782112wea.139.2012.11.30.03.57.54 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 03:57:54 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.170 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-we0-f170.google.com with SMTP id r1so240203wey.1 for ; Fri, 30 Nov 2012 03:57:54 -0800 (PST) Received: by 10.216.133.94 with SMTP id p72mr366555wei.82.1354276673927; Fri, 30 Nov 2012 03:57:53 -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.52 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 30 Nov 2012 03:57:53 -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, Jonas Aaberg , Lee Jones Subject: [PATCH 03/12] ab8500_btemp: Detect battery type in workqueue Date: Fri, 30 Nov 2012 11:57:25 +0000 Message-Id: <1354276654-590-4-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: ALoCoQnxajYxgbmSiKwLLeI3tucMt9C935K3gPLGGHbQzyOIujugnY76Lbq3vJd1lPbiMaQ+duax From: Jonas Aaberg Detect battery type in work queue instead of probe. This reduces the system boot time with 1.5s. Signed-off-by: Jonas Aaberg Signed-off-by: Lee Jones Reviewed-by: Karl KOMIEROWSKI --- drivers/power/ab8500_btemp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index 8135542..5d1bf0b 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -84,6 +84,7 @@ struct ab8500_btemp_ranges { * @btemp_ranges: Battery temperature range structure * @btemp_wq: Work queue for measuring the temperature periodically * @btemp_periodic_work: Work for measuring the temperature periodically + * @initialized: True if battery id read. */ struct ab8500_btemp { struct device *dev; @@ -100,6 +101,7 @@ struct ab8500_btemp { struct ab8500_btemp_ranges btemp_ranges; struct workqueue_struct *btemp_wq; struct delayed_work btemp_periodic_work; + bool initialized; }; /* BTEMP power supply properties */ @@ -569,6 +571,13 @@ static void ab8500_btemp_periodic_work(struct work_struct *work) struct ab8500_btemp *di = container_of(work, struct ab8500_btemp, btemp_periodic_work.work); + if (!di->initialized) { + di->initialized = true; + /* Identify the battery */ + if (ab8500_btemp_id(di) < 0) + dev_warn(di->dev, "failed to identify the battery\n"); + } + di->bat_temp = ab8500_btemp_measure_temp(di); if (di->bat_temp != di->prev_bat_temp) { @@ -998,6 +1007,8 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) di->parent = dev_get_drvdata(pdev->dev.parent); di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0"); + di->initialized = false; + /* BTEMP supply */ di->btemp_psy.name = "ab8500_btemp"; di->btemp_psy.type = POWER_SUPPLY_TYPE_BATTERY; @@ -1022,10 +1033,6 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) INIT_DEFERRABLE_WORK(&di->btemp_periodic_work, ab8500_btemp_periodic_work); - /* Identify the battery */ - if (ab8500_btemp_id(di) < 0) - dev_warn(di->dev, "failed to identify the battery\n"); - /* Set BTEMP thermal limits. Low and Med are fixed */ di->btemp_ranges.btemp_low_limit = BTEMP_THERMAL_LOW_LIMIT; di->btemp_ranges.btemp_med_limit = BTEMP_THERMAL_MED_LIMIT;