From patchwork Sun Jun 3 14:14:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 10445341 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 14F49601BC for ; Sun, 3 Jun 2018 14:14:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E646E28ABC for ; Sun, 3 Jun 2018 14:14:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D82DE28AED; Sun, 3 Jun 2018 14:14:45 +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, FREEMAIL_FROM, 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 8BD8D28ABC for ; Sun, 3 Jun 2018 14:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751235AbeFCOOi (ORCPT ); Sun, 3 Jun 2018 10:14:38 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:33079 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbeFCOOh (ORCPT ); Sun, 3 Jun 2018 10:14:37 -0400 Received: by mail-pl0-f67.google.com with SMTP id n10-v6so18034262plp.0 for ; Sun, 03 Jun 2018 07:14:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=R3TdcGrt/IJRxP9TM586ddXqvZ2MmVWXRUoxAGLORHQ=; b=A8CSo3iyEiTBBn6PqLy2cnrrp2iZ3vcOITXdmzqZzLRTusa40mEQR8bMWpLBdvNO1y HHfN2MNHwor6vLESGUez6md3Aii9Mp37VDNyylX+N3C89/vsB4l/lh8IcYzGmKjItRxB kIMhA9TQPISpWN7bJDBncO3DyPW19pP/nkAB3ec+PAXIqYgg4iz09XECTcdVJFkb4FSV Tx5O8O9nervq0dk3ci6VZdLjW6IbeACOOo7NpJX4fALkzXpwMcj7KBCkBK3CUc2d8Tlu irtlBz1KdhUSD4BH8YJBU/qVGVI6qvwv/Xpo1MuJa45bNBL3JgwMSjifeHhJrSAzYLPB 9E/w== 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=R3TdcGrt/IJRxP9TM586ddXqvZ2MmVWXRUoxAGLORHQ=; b=Qn3yGjswSdSmfOloha2alqK0ah/nsGF9htCdHwjMKm4x+6vCRYQ8jCd9QTMhIMM/Cu h36xKqeWYUSqSZk0+AxWME8b0SRXWifaEWlbETef8nYHlvhRZ3rYhPx8yf7uVFdPltLC sNygCZBMbrjssNp9MSg7bWvyxv3D6LoFvJB9S70BzaXB1dIqsN+hr5snOO7l31v7elP8 650SCQevTAC8vWRhJHWufN+3/wXHvSKCO1spNRqxVmww2CpPX+CrzZz34+3ryWOtNVVO N1PyD4MJMwAv+DqXR4DjxRkFQDARaiKjbwQrNpDY3r8otYdG94sBXKO8Dy62O8nkLP1M 9ozg== X-Gm-Message-State: ALKqPwfWhnfyKjs+DhIACtNaDwFCFJIfCdq/fFYlMDYqpwVIZVMKz/cw cgKkUe7yXNG22wrnEN9d0CP5ig== X-Google-Smtp-Source: ADUXVKI8bCX2yPSof7teiVMCgfJx/3r+VeSNg0PdSrYggLsdf1kvIHuUxDghpv4/Ve6A0pCK5MhBkA== X-Received: by 2002:a17:902:8d85:: with SMTP id v5-v6mr18300590plo.93.1528035276772; Sun, 03 Jun 2018 07:14:36 -0700 (PDT) Received: from localhost.localdomain ([240f:4:c2bc:1:ad34:6ec7:f00d:7072]) by smtp.gmail.com with ESMTPSA id h8-v6sm57714181pgq.56.2018.06.03.07.14.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 Jun 2018 07:14:35 -0700 (PDT) From: Akinobu Mita To: linux-media@vger.kernel.org Cc: Akinobu Mita , Hans Verkuil , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH] media: pxa_camera: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power Date: Sun, 3 Jun 2018 23:14:25 +0900 Message-Id: <1528035265-14404-1-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.7.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 When the subdevice doesn't provide s_power core ops callback, the v4l2_subdev_call for s_power returns -ENOIOCTLCMD. If the subdevice doesn't have the special handling for its power saving mode, the s_power isn't required. So -ENOIOCTLCMD from the v4l2_subdev_call should be ignored. Actually the -ENOIOCTLCMD is ignored in this driver's suspend/resume, but the others treat the -ENOIOCTLCMD as an error. This prepares a wrapper function to ignore -ENOIOCTLCMD and replaces all s_power calls with it. This also adds warning message when s_power() is failed. Cc: Hans Verkuil Cc: Sakari Ailus Cc: Mauro Carvalho Chehab Signed-off-by: Akinobu Mita --- drivers/media/platform/pxa_camera.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c index c792cb1..4d5a26b 100644 --- a/drivers/media/platform/pxa_camera.c +++ b/drivers/media/platform/pxa_camera.c @@ -2030,6 +2030,22 @@ static int pxac_vidioc_s_input(struct file *file, void *priv, unsigned int i) return 0; } +static int pxac_sensor_set_power(struct pxa_camera_dev *pcdev, int on) +{ + int ret; + + ret = sensor_call(pcdev, core, s_power, on); + if (ret == -ENOIOCTLCMD) + ret = 0; + if (ret) { + dev_warn(pcdev_to_dev(pcdev), + "Failed to put subdevice in %s mode: %d\n", + on ? "normal operation" : "power saving", ret); + } + + return ret; +} + static int pxac_fops_camera_open(struct file *filp) { struct pxa_camera_dev *pcdev = video_drvdata(filp); @@ -2043,7 +2059,7 @@ static int pxac_fops_camera_open(struct file *filp) if (!v4l2_fh_is_singular_file(filp)) goto out; - ret = sensor_call(pcdev, core, s_power, 1); + ret = pxac_sensor_set_power(pcdev, 1); if (ret) v4l2_fh_release(filp); out: @@ -2064,7 +2080,7 @@ static int pxac_fops_camera_release(struct file *filp) ret = _vb2_fop_release(filp, NULL); if (fh_singular) - ret = sensor_call(pcdev, core, s_power, 0); + ret = pxac_sensor_set_power(pcdev, 0); mutex_unlock(&pcdev->mlock); @@ -2167,7 +2183,7 @@ static int pxa_camera_sensor_bound(struct v4l2_async_notifier *notifier, pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc; v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code); - err = sensor_call(pcdev, core, s_power, 1); + err = pxac_sensor_set_power(pcdev, 1); if (err) goto out; @@ -2194,7 +2210,7 @@ static int pxa_camera_sensor_bound(struct v4l2_async_notifier *notifier, } out_sensor_poweroff: - err = sensor_call(pcdev, core, s_power, 0); + err = pxac_sensor_set_power(pcdev, 0); out: mutex_unlock(&pcdev->mlock); return err; @@ -2249,11 +2265,8 @@ static int pxa_camera_suspend(struct device *dev) pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR3); pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR4); - if (pcdev->sensor) { - ret = sensor_call(pcdev, core, s_power, 0); - if (ret == -ENOIOCTLCMD) - ret = 0; - } + if (pcdev->sensor) + ret = pxac_sensor_set_power(pcdev, 0); return ret; } @@ -2270,9 +2283,7 @@ static int pxa_camera_resume(struct device *dev) __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR4); if (pcdev->sensor) { - ret = sensor_call(pcdev, core, s_power, 1); - if (ret == -ENOIOCTLCMD) - ret = 0; + ret = pxac_sensor_set_power(pcdev, 1); } /* Restart frame capture if active buffer exists */