From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30E6DC28CC0 for ; Thu, 30 May 2019 03:30:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0174524AEB for ; Thu, 30 May 2019 03:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559187050; bh=kMmh6iBL9NQyeey8nZVsGYVS5PhyCz7yCWD11jJUAMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uXjku+sTBGnWwY+0xaWsaZEudLosbA0fUtjWHubGhA+qcpjyLiw4YE2i5Fndsw46Z cZunlolDtWHBzW7pr0o+cZhv7u2BelRVrxx7CUm+QLjgz0vRO0tl/dV7lWw3oSjw2A Iwsn8qHNl3ELG3OSGByEfWKa9tE2XC8SIYw7ZBmQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388659AbfE3Dat (ORCPT ); Wed, 29 May 2019 23:30:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733053AbfE3Dal (ORCPT ); Wed, 29 May 2019 23:30:41 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C379424AF6; Thu, 30 May 2019 03:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559187040; bh=kMmh6iBL9NQyeey8nZVsGYVS5PhyCz7yCWD11jJUAMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y9C3LZOeoVLsOZnMZzKJ/Te6TlmlFd9kRUtqIr6QdkEWULuyX2yBF/PNpM+Z0jkAn sqB0NeW7wHZNeTlucd7eOXov2pFrDd4d38aHACn5aiwxCQN+0JeCkJ4v5QoxRC4KBR 9ninUbr9W1yTc6PaWuxExo1W/2gZDJh3ia1dkeTs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Lad, Prabhakar" , Akinobu Mita , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 124/276] media: ov2659: make S_FMT succeed even if requested format doesnt match Date: Wed, 29 May 2019 20:04:42 -0700 Message-Id: <20190530030533.584869940@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit bccb89cf9cd07a0690d519696a00c00a973b3fe4 ] This driver returns an error if unsupported media bus pixel code is requested by VIDIOC_SUBDEV_S_FMT. But according to Documentation/media/uapi/v4l/vidioc-subdev-g-fmt.rst, Drivers must not return an error solely because the requested format doesn't match the device capabilities. They must instead modify the format to match what the hardware can provide. So select default format code and return success in that case. This is detected by v4l2-compliance. Cc: "Lad, Prabhakar" Signed-off-by: Akinobu Mita Acked-by: Lad, Prabhakar Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov2659.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index 4715edc8ca33e..e6a8b5669b9cc 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -1117,8 +1117,10 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd, if (ov2659_formats[index].code == mf->code) break; - if (index < 0) - return -EINVAL; + if (index < 0) { + index = 0; + mf->code = ov2659_formats[index].code; + } mf->colorspace = V4L2_COLORSPACE_SRGB; mf->field = V4L2_FIELD_NONE; -- 2.20.1