From patchwork Thu Nov 22 03:52:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 10693461 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 A7A2C16B1 for ; Thu, 22 Nov 2018 03:52:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C112CB58 for ; Thu, 22 Nov 2018 03:52:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9206E2CBE7; Thu, 22 Nov 2018 03:52:38 +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 29B3D2CB58 for ; Thu, 22 Nov 2018 03:52:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731213AbeKVOaE (ORCPT ); Thu, 22 Nov 2018 09:30:04 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:34679 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730904AbeKVOaE (ORCPT ); Thu, 22 Nov 2018 09:30:04 -0500 Received: by mail-pl1-f196.google.com with SMTP id f12-v6so8423542plo.1 for ; Wed, 21 Nov 2018 19:52:35 -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:in-reply-to:references; bh=ekzR+yHCCoQc9XKif9a/Xi5cUJgPOvS46llIcWaMrYU=; b=BqkCpdGIrkba6n4YkPcHqPdq5X7Z0LnwGVk6CPjFhpq1bArlh2zj4h7eBZ/qEjON11 nkWIpLNhkgrSxg0Z0M51wxFYbK3p6ByLCG8KpZAYS0CuuSvuNa1lSgy5owxIbX8s//7G rdZzqjC0DWKhY7zL1xrefi8/mOHgHx7gJot28= 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:in-reply-to :references; bh=ekzR+yHCCoQc9XKif9a/Xi5cUJgPOvS46llIcWaMrYU=; b=XzmEcx+7Tz1SPBX7LOgrNxgQxJFD54N7xwICZwWsQ7siF8AGnVNuT0jTZpR7zMUrYZ KkPHfAIRl7ILohXMwpkaePBxtEvPLP/TLSW0VcxmmOUEtEQr3vpeWT5FonvvxF1pTZds NPN0NYP5jI0yiMlaaP/+b/hY+lrLsWzWF6yOFRAWaRnWsenXSu/6Sk76u50sOAysCntq ztOksIA4Y8wwDKj+QfyahdTUwdtV9apdLCreJoAKuTW9suiffLVYKBkmqiXAh5PbTzhy /INs4M/9afKx6obs/wVrqcR7nWa7amaRdwrMzSmsfd2ImqNDm/Bt6vJel8WLXySGFjMU W9+A== X-Gm-Message-State: AA+aEWYK3NJXf6dOhvxO5sgopw4YtBP0WrGInMKL0Upd9qwa0D+DcRTF AdGFU+vQF2PqyAEJL+uKBgBNdqJTs8WPiQ== X-Google-Smtp-Source: AFSGD/XPlekH+87PxYL9orzIYY0BWWAym5OlBWSekYY/YS3ybt4mfzMW+Z3s6wSPa1550GHe/85ggg== X-Received: by 2002:a63:fd0a:: with SMTP id d10mr8684648pgh.164.1542858755483; Wed, 21 Nov 2018 19:52:35 -0800 (PST) Received: from virtualbox.hsd1.wa.comcast.net (c-67-171-239-254.hsd1.wa.comcast.net. [67.171.239.254]) by smtp.gmail.com with ESMTPSA id p5-v6sm58275500pfb.109.2018.11.21.19.52.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 19:52:34 -0800 (PST) From: Matt Ranostay To: linux-media@vger.kernel.org Cc: Matt Ranostay Subject: [PATCH v2 1/2] media: video-i2c: check if chip struct has set_power function Date: Wed, 21 Nov 2018 19:52:28 -0800 Message-Id: <20181122035229.3630-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181122035229.3630-1-matt.ranostay@konsulko.com> References: <20181122035229.3630-1-matt.ranostay@konsulko.com> 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. Signed-off-by: Matt Ranostay --- drivers/media/i2c/video-i2c.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index 981166010c9b..a64e1a725a20 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,8 @@ 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 +794,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 +809,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 +819,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); }