From patchwork Sat Nov 24 22:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 10696575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AC141750 for ; Sat, 24 Nov 2018 22:03:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5771928925 for ; Sat, 24 Nov 2018 22:03:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45CC62897E; Sat, 24 Nov 2018 22:03:56 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 C5FF128925 for ; Sat, 24 Nov 2018 22:03:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbeKYIxP (ORCPT ); Sun, 25 Nov 2018 03:53:15 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42279 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbeKYIxP (ORCPT ); Sun, 25 Nov 2018 03:53:15 -0500 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so13344120lja.9 for ; Sat, 24 Nov 2018 14:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id; bh=U1wf4CQ0peYOUoI6t9SEXTF2VJtTb5M3+k3q3DPkZJ8=; b=OBlEQhaZoCnRKD0BkndYyHv9Ve0De8waL17FIX/JCAlL0T0hAbQpeAw/YOwIco9cSV XaiR3e6I6Ep82A5XaVrAbucmynK94imWV+Oi2e5UP0mXtQc7HQ6t/zoZ/87f5X/fgtR1 q807+vEeCiLTUbLIf6W8svubPldwqXggJzOMs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=U1wf4CQ0peYOUoI6t9SEXTF2VJtTb5M3+k3q3DPkZJ8=; b=qn9Jtid6lS1nTm9Fsiv18uW/OfK/84UWZ/8v9T09IeRA9nfuksdGMclHggMIqyR3Zt qbzIyFJvSfVD1X/cICWBDQpu3SAsXBMjhVyPRS47NCfpvlgPtG0RXoqM5cfxhMYff0Dz +d5GzQQWUoKgi1WVp6dcFWb0JTMK5ulNLTHVJJst5TlOr1l/nBdf8zA0ozThe5pffuhI e6A/0vIg62Oda5Bqs35eDZ7mrViaix19Mv7wnsCCkAb5Mr/VfOtrSvRztN9U5TSTISrU zJjNdG+GDoAVNN3McCwru+PhXd5HeBzExKwZGF9uWbVTe4l+qc/nXow+Mk5JE9jlNeL0 mtuQ== X-Gm-Message-State: AA+aEWZgniueeYectX8XFvN73tDW4veA/Lsm9z08eXYTIG1AbmgmenQD pEuPX7b1IRIOsSanvpTg/Z8mizXAnJPrdA== X-Google-Smtp-Source: AFSGD/X7fyNdvTuwmWSU/rVTFYtcI5jcxL/Qdml21wHthz2kXrdfkMLk0i+T+Z22xGSYJthYl23aag== X-Received: by 2002:a2e:612:: with SMTP id 18-v6mr12831484ljg.125.1543097028843; Sat, 24 Nov 2018 14:03:48 -0800 (PST) Received: from virtualbox.ipredator.se (anon-49-228.vpn.ipredator.se. [46.246.49.228]) by smtp.gmail.com with ESMTPSA id t144sm8157515lff.53.2018.11.24.14.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Nov 2018 14:03:47 -0800 (PST) From: Matt Ranostay To: linux-media@vger.kernel.org Cc: Matt Ranostay , Sakari Ailus , Hans Verkuil , Mauro Carvalho Chehab , Akinobu Mita Subject: [PATCH v3] media: video-i2c: check if chip struct has set_power function Date: Sat, 24 Nov 2018 14:03:23 -0800 Message-Id: <20181124220323.13497-1-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.17.1 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 Not all future supported video chips will always have power management support, and so it is important to check before calling set_power() is defined. Cc: Sakari Ailus Cc: Hans Verkuil Cc: Mauro Carvalho Chehab Cc: Akinobu Mita Signed-off-by: Matt Ranostay Reviewed-by: Akinobu Mita --- Changes from v2: - split out from mlx90640 patch series - added to Cc list Changes from v1: - none drivers/media/i2c/video-i2c.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index b6ebb8d53e90..01dcf179f203 100644 --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -736,9 +736,11 @@ static int video_i2c_probe(struct i2c_client *client, video_set_drvdata(&data->vdev, data); i2c_set_clientdata(client, data); - ret = data->chip->set_power(data, true); - if (ret) - goto error_unregister_device; + if (data->chip->set_power) { + ret = data->chip->set_power(data, true); + if (ret) + goto error_unregister_device; + } pm_runtime_get_noresume(&client->dev); pm_runtime_set_active(&client->dev); @@ -767,7 +769,9 @@ static int video_i2c_probe(struct i2c_client *client, pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); pm_runtime_put_noidle(&client->dev); - data->chip->set_power(data, false); + + if (data->chip->set_power) + data->chip->set_power(data, false); error_unregister_device: v4l2_device_unregister(v4l2_dev); @@ -791,7 +795,9 @@ static int video_i2c_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); pm_runtime_put_noidle(&client->dev); - data->chip->set_power(data, false); + + if (data->chip->set_power) + data->chip->set_power(data, false); video_unregister_device(&data->vdev); @@ -804,6 +810,9 @@ static int video_i2c_pm_runtime_suspend(struct device *dev) { struct video_i2c_data *data = i2c_get_clientdata(to_i2c_client(dev)); + if (!data->chip->set_power) + return 0; + return data->chip->set_power(data, false); } @@ -811,6 +820,9 @@ static int video_i2c_pm_runtime_resume(struct device *dev) { struct video_i2c_data *data = i2c_get_clientdata(to_i2c_client(dev)); + if (!data->chip->set_power) + return 0; + return data->chip->set_power(data, true); }