From patchwork Wed Sep 11 15:32:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 2873321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D75429F495 for ; Wed, 11 Sep 2013 15:41:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95FBE2039C for ; Wed, 11 Sep 2013 15:41:06 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B3A1202F9 for ; Wed, 11 Sep 2013 15:41:05 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJmVf-0005nw-9K; Wed, 11 Sep 2013 15:39:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJmQj-0000kj-5b; Wed, 11 Sep 2013 15:34:09 +0000 Received: from mga02.intel.com ([134.134.136.20]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJmQ1-0000cO-Oc for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2013 15:33:28 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 11 Sep 2013 08:33:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,885,1371106800"; d="scan'208";a="401818712" Received: from blue.fi.intel.com ([10.237.72.156]) by orsmga002.jf.intel.com with ESMTP; 11 Sep 2013 08:32:46 -0700 Received: by blue.fi.intel.com (Postfix, from userid 1004) id 022D9E0095; Wed, 11 Sep 2013 18:32:40 +0300 (EEST) From: Mika Westerberg To: linux-i2c@vger.kernel.org Subject: [PATCH v2 5/9] drivers/misc: convert existing I2C clients driver to use I2C core runtime PM Date: Wed, 11 Sep 2013 18:32:36 +0300 Message-Id: <1378913560-2752-6-git-send-email-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1378913560-2752-1-git-send-email-mika.westerberg@linux.intel.com> References: <1378913560-2752-1-git-send-email-mika.westerberg@linux.intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130911_113326_290298_F02D3988 X-CRM114-Status: GOOD ( 16.62 ) X-Spam-Score: -7.7 (-------) Cc: Aaron Lu , Dmitry Torokhov , Mika Westerberg , Samuel Ortiz , Arnd Bergmann , Wolfram Sang , Greg Kroah-Hartman , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Liam Girdwood , linux-acpi@vger.kernel.org, Kyungmin Park , Mark Brown , Lv Zheng , Lee Jones , linux-arm-kernel@lists.infradead.org, Mauro Carvalho Chehab X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The I2C core now prepares runtime PM on behalf of the I2C client device, so only thing the driver needs to do is to call pm_runtime_put() at the end of its ->probe(). This patch converts I2C client drivers under drivers/misc to use this model. Signed-off-by: Mika Westerberg Acked-by: Greg Kroah-Hartman --- drivers/misc/apds9802als.c | 7 +------ drivers/misc/apds990x.c | 16 ++++++---------- drivers/misc/bh1770glc.c | 12 +++++------- drivers/misc/fsa9480.c | 2 -- drivers/misc/isl29020.c | 3 ++- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/drivers/misc/apds9802als.c b/drivers/misc/apds9802als.c index 0c6e037..7a177cd 100644 --- a/drivers/misc/apds9802als.c +++ b/drivers/misc/apds9802als.c @@ -246,8 +246,7 @@ static int apds9802als_probe(struct i2c_client *client, als_set_default_config(client); mutex_init(&data->mutex); - pm_runtime_set_active(&client->dev); - pm_runtime_enable(&client->dev); + pm_runtime_put(&client->dev); return res; als_error1: @@ -264,10 +263,6 @@ static int apds9802als_remove(struct i2c_client *client) als_set_power_state(client, false); sysfs_remove_group(&client->dev.kobj, &m_als_gr); - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); - kfree(data); return 0; } diff --git a/drivers/misc/apds990x.c b/drivers/misc/apds990x.c index 868a30a..3bb87a8 100644 --- a/drivers/misc/apds990x.c +++ b/drivers/misc/apds990x.c @@ -1140,14 +1140,10 @@ static int apds990x_probe(struct i2c_client *client, goto fail3; } - pm_runtime_set_active(&client->dev); - apds990x_configure(chip); apds990x_set_arate(chip, APDS_LUX_DEFAULT_RATE); apds990x_mode_on(chip); - pm_runtime_enable(&client->dev); - if (chip->pdata->setup_resources) { err = chip->pdata->setup_resources(); if (err) { @@ -1173,6 +1169,9 @@ static int apds990x_probe(struct i2c_client *client, client->irq); goto fail5; } + + pm_runtime_put(&client->dev); + return err; fail5: sysfs_remove_group(&chip->client->dev.kobj, @@ -1193,6 +1192,8 @@ static int apds990x_remove(struct i2c_client *client) { struct apds990x_chip *chip = i2c_get_clientdata(client); + pm_runtime_get_sync(&client->dev); + free_irq(client->irq, chip); sysfs_remove_group(&chip->client->dev.kobj, apds990x_attribute_group); @@ -1200,12 +1201,7 @@ static int apds990x_remove(struct i2c_client *client) if (chip->pdata && chip->pdata->release_resources) chip->pdata->release_resources(); - if (!pm_runtime_suspended(&client->dev)) - apds990x_chip_off(chip); - - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); - + apds990x_chip_off(chip); regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); kfree(chip); diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c index 99a0468..7a85328 100644 --- a/drivers/misc/bh1770glc.c +++ b/drivers/misc/bh1770glc.c @@ -1245,8 +1245,6 @@ static int bh1770_probe(struct i2c_client *client, /* Start chip */ bh1770_chip_on(chip); - pm_runtime_set_active(&client->dev); - pm_runtime_enable(&client->dev); chip->lux_corr = bh1770_get_corr_value(chip); if (chip->lux_corr == 0) { @@ -1286,6 +1284,8 @@ static int bh1770_probe(struct i2c_client *client, goto fail5; } regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); + pm_runtime_put(&client->dev); + return err; fail5: sysfs_remove_group(&chip->client->dev.kobj, @@ -1306,6 +1306,8 @@ static int bh1770_remove(struct i2c_client *client) { struct bh1770_chip *chip = i2c_get_clientdata(client); + pm_runtime_get_sync(&client->dev); + free_irq(client->irq, chip); sysfs_remove_group(&chip->client->dev.kobj, @@ -1316,11 +1318,7 @@ static int bh1770_remove(struct i2c_client *client) cancel_delayed_work_sync(&chip->prox_work); - if (!pm_runtime_suspended(&client->dev)) - bh1770_chip_off(chip); - - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); + bh1770_chip_off(chip); regulator_bulk_free(ARRAY_SIZE(chip->regs), chip->regs); kfree(chip); diff --git a/drivers/misc/fsa9480.c b/drivers/misc/fsa9480.c index a725c79..1a7dc8b 100644 --- a/drivers/misc/fsa9480.c +++ b/drivers/misc/fsa9480.c @@ -450,8 +450,6 @@ static int fsa9480_probe(struct i2c_client *client, /* device detection */ fsa9480_detect_dev(usbsw, INT_ATTACH); - pm_runtime_set_active(&client->dev); - return 0; fail2: diff --git a/drivers/misc/isl29020.c b/drivers/misc/isl29020.c index b7f84da..7bf15b8 100644 --- a/drivers/misc/isl29020.c +++ b/drivers/misc/isl29020.c @@ -179,12 +179,13 @@ static int isl29020_probe(struct i2c_client *client, } dev_info(&client->dev, "%s isl29020: ALS chip found\n", client->name); als_set_power_state(client, 0); - pm_runtime_enable(&client->dev); + pm_runtime_put(&client->dev); return res; } static int isl29020_remove(struct i2c_client *client) { + pm_runtime_get(&client->dev); sysfs_remove_group(&client->dev.kobj, &m_als_gr); return 0; }