From patchwork Fri Nov 18 13:50:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9436507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2795F60238 for ; Fri, 18 Nov 2016 13:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A7F298B7 for ; Fri, 18 Nov 2016 13:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8E57298D1; Fri, 18 Nov 2016 13:50:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68814298B7 for ; Fri, 18 Nov 2016 13:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbcKRNuW (ORCPT ); Fri, 18 Nov 2016 08:50:22 -0500 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:47578 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752174AbcKRNuW (ORCPT ); Fri, 18 Nov 2016 08:50:22 -0500 Received: from lanttu.localdomain (unknown [192.168.15.170]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 75B9B6009F; Fri, 18 Nov 2016 15:50:14 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: arnd@arndb.de Subject: [PATCH 1/1] smiapp: Implement power-on and power-off sequences without runtime PM Date: Fri, 18 Nov 2016 15:50:16 +0200 Message-Id: <1479477016-28450-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Power on the sensor when the module is loaded and power it off when it is removed. Signed-off-by: Sakari Ailus --- Hi Arnd and others, The patch is tested with CONFIG_PM set, as the system does I was testing on did not boot with CONFIG_PM disabled. I'm not really too worried about this though, the patch is very simple. Kind regards, Sakari drivers/media/i2c/smiapp/smiapp-core.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 59872b3..8624dc4 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -2741,8 +2741,6 @@ static const struct v4l2_subdev_internal_ops smiapp_internal_ops = { * I2C Driver */ -#ifdef CONFIG_PM - static int smiapp_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -2783,13 +2781,6 @@ static int smiapp_resume(struct device *dev) return rval; } -#else - -#define smiapp_suspend NULL -#define smiapp_resume NULL - -#endif /* CONFIG_PM */ - static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev) { struct smiapp_hwconfig *hwcfg; @@ -2915,7 +2906,11 @@ static int smiapp_probe(struct i2c_client *client, pm_runtime_enable(&client->dev); +#ifdef CONFIG_PM rval = pm_runtime_get_sync(&client->dev); +#else + rval = smiapp_power_on(&client->dev); +#endif if (rval < 0) { rval = -ENODEV; goto out_power_off; @@ -3113,7 +3108,11 @@ static int smiapp_probe(struct i2c_client *client, smiapp_cleanup(sensor); out_power_off: +#ifdef CONFIG_PM pm_runtime_put(&client->dev); +#else + smiapp_power_off(&client->dev); +#endif pm_runtime_disable(&client->dev); return rval; @@ -3127,7 +3126,11 @@ static int smiapp_remove(struct i2c_client *client) v4l2_async_unregister_subdev(subdev); +#ifdef CONFIG_PM pm_runtime_suspend(&client->dev); +#else + smiapp_power_off(&client->dev); +#endif pm_runtime_disable(&client->dev); for (i = 0; i < sensor->ssds_used; i++) {