From patchwork Thu Nov 1 04:15:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 10663481 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 9825D109C for ; Thu, 1 Nov 2018 04:15:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EF932ACA4 for ; Thu, 1 Nov 2018 04:15:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F9CC2AC69; Thu, 1 Nov 2018 04:15:41 +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 1D6672AC69 for ; Thu, 1 Nov 2018 04:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbeKANQx (ORCPT ); Thu, 1 Nov 2018 09:16:53 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38008 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727203AbeKANQx (ORCPT ); Thu, 1 Nov 2018 09:16:53 -0400 Received: by mail-pl1-f195.google.com with SMTP id p7-v6so8304589plk.5 for ; Wed, 31 Oct 2018 21:15:39 -0700 (PDT) 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=OwybVgDJVsQ3C5lGqv4V3W9aKF6t/usafN8N1+AXD6A=; b=S5EBeaxzoUb22fyYTyYZ/kDUmb3N1nEVo5169XXV1dK9h/+8sF0Af/i6Gqz1Dmt3cq Bei1tQcPI6B7rr0AWAzn/uzwzi+wgdgEoSr7bRCtlU2akcB8oAuetXUUxF8phgwJCgps jTmiZ/mTvrd7HRfhkAgFZhdo6BYRizbJ/Qllg= 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=OwybVgDJVsQ3C5lGqv4V3W9aKF6t/usafN8N1+AXD6A=; b=JXvdoJdkZclqphRxcS/7BHsY9PXUKHcs+TAC63d+qh1wIbYm7Gg9J5hwfErADYHwf7 E7nkZS6LbDaEmFc+/ezFZtW/JJNiiZHG5iTBCfbGKMEoATgBZaZMwY0MGZqv9XLeK4hb D1V0oplai1GhTrJ48Dtql0k7I7S1O8gLLq6HSKqIJDY5CDBEyaS/RLrHocrdU3xvIHk8 c8GiodXTd5+dQugqUZxRGfxs8kspnd9qpUwFO1UNhq89J48I1UeDs53ZiF67LKNM09Cm q5M3DrZa/RbBKmrbR8NmoNjdy3Cqg4iM2wlHvJ2RDbEKenWsKdtBGofTGPpU7vSYLaCy jhUA== X-Gm-Message-State: AGRZ1gL/zDHbS2kocJWx2xHbSmjHPZ6M5bdSpNMyOSib3S3zsWaZ91T9 hr5+g9XUNaTv2cLSLqdHNcyJn0dR5w8= X-Google-Smtp-Source: AJdET5fXzdO3F8u+Ihk0Jvfe278NMBh7w/1mPjjGcXNK0w6S8DM0LLro9v98HuaRjC0MMoej3z5o9Q== X-Received: by 2002:a17:902:8306:: with SMTP id bd6-v6mr6092949plb.321.1541045739427; Wed, 31 Oct 2018 21:15:39 -0700 (PDT) Received: from roguebox.hsd1.wa.comcast.net ([2601:1c2:4001:b280:bcd5:f572:3a40:d56d]) by smtp.gmail.com with ESMTPSA id f6-v6sm11468488pfg.128.2018.10.31.21.15.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 21:15:38 -0700 (PDT) From: Matt Ranostay To: linux-media@vger.kernel.org Cc: Matt Ranostay Subject: [PATCH 1/2] media: video-i2c: check if chip struct has set_power function Date: Wed, 31 Oct 2018 21:15:33 -0700 Message-Id: <20181101041534.5913-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181101041534.5913-1-matt.ranostay@konsulko.com> References: <20181101041534.5913-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 cb5db5bdab12..6d3b6df0b634 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); }