From patchwork Thu Sep 27 20:08:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11776 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 793C824140 for ; Thu, 27 Sep 2012 20:09:26 +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 9228EA19120 for ; Thu, 27 Sep 2012 20:09:25 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234855iej.11 for ; Thu, 27 Sep 2012 13:09:25 -0700 (PDT) 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 :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/KanN5JpaKAa6wJlfFge4xwD6xY+DL+pJ+90rLYuo5g=; b=XwhO7ZLovlrP74tsv5vcaO6g9jaXG6kkCqfSp6bGsrmBHNvKnsaY95h4rcgdtwEu4Y myRFqr/H0mLL13fRp/hJsWB84h3AnW1kJMiB9UodkBZOBlJ0ZO5iZCrC48GJ9xG8bufK Zs7RL7oO2rBTXWZDPBYoiIV6puHKh/zIBgd3Rabncaoxn2Vp/O/xRf3XAAUsEn+FRevN AbOQ5N6ump+d5pq9/ZLe7JGeWQqB5bx8r6UvQIZ0sS2gja4EGgwfUnJeeLaxDIhdN6f9 321aX6iwlC75ZNgI8KvDK42URfiw4NXbkoGtIo++clpoXJGObv65JqVGimmA4hex5Aiy 3uiA== Received: by 10.42.84.69 with SMTP id k5mr3974233icl.5.1348776565373; Thu, 27 Sep 2012 13:09:25 -0700 (PDT) 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.184.232 with SMTP id ex8csp436264igc; Thu, 27 Sep 2012 13:09:24 -0700 (PDT) Received: by 10.68.232.70 with SMTP id tm6mr14420233pbc.104.1348776564726; Thu, 27 Sep 2012 13:09:24 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pi9si5467641pbb.12.2012.09.27.13.09.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md4so1686045pbc.37 for ; Thu, 27 Sep 2012 13:09:24 -0700 (PDT) Received: by 10.66.73.100 with SMTP id k4mr12130000pav.49.1348776564303; Thu, 27 Sep 2012 13:09:24 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.09.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:23 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 03/57] power: ab8500_btemp: Detect battery type in workqueue Date: Thu, 27 Sep 2012 14:08:20 -0600 Message-Id: <1348776554-10019-4-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQkLsn2BLI1KkZD9xI74sg6LK+oc9ouro1rGfdZvwy6XZw7oM/vFrJciLNwyhnF1/PvSdt9e 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: Mathieu Poirier Reviewed-by: Karl KOMIEROWSKI --- drivers/power/ab8500_btemp.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index bba3cca..94a3ee8 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -83,6 +83,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) { @@ -981,6 +990,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; + /* get btemp specific platform data */ di->pdata = plat_data->btemp; if (!di->pdata) { @@ -1021,10 +1032,6 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev) INIT_DELAYED_WORK_DEFERRABLE(&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;