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.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 D628EC282CD for ; Mon, 28 Jan 2019 15:50:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A519F21741 for ; Mon, 28 Jan 2019 15:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548690614; bh=uksaXLgZR4CcvzXReguvlIiyqaxIV61NpWhAqSkrdFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0WoWXMmg//Iv941MgwgPudJt8YmoyxyYBkWuNvh2O9/oCRJvGRkteUF6j4cVjYf01 rqNS38UAYFb/f4tl3VxDUYpLepuxtHiKdqfnBTd8MNQX0RoEVmvSbhcRPrlc6DsOdh KM1Cy1Xju0kEzg30UrTIJTzfArACY/2Wd1eCi0XQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728877AbfA1PuM (ORCPT ); Mon, 28 Jan 2019 10:50:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:36270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727590AbfA1PuK (ORCPT ); Mon, 28 Jan 2019 10:50:10 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 11BB420880; Mon, 28 Jan 2019 15:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548690609; bh=uksaXLgZR4CcvzXReguvlIiyqaxIV61NpWhAqSkrdFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dD9x52znGLnAS53YXrPvEuAoWft8JlT1hmEz3VmxSEKbbC1wDy47cZ9RuEAuo10/R gYEphGbGJuGdvit67onW7cMcgBBriUr3WHlNQ+ZzjVnS1RW7prFkz9FZ6NHIT83iW3 DQ/9PrXBbAOqHtmUCt5VL51GT2cCm30xbKSuSMbM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tomasz Figa , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 140/304] media: v4l2-device: Link subdevices to their parent devices if available Date: Mon, 28 Jan 2019 10:40:57 -0500 Message-Id: <20190128154341.47195-140-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128154341.47195-1-sashal@kernel.org> References: <20190128154341.47195-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomasz Figa [ Upstream commit ee494cf377e142f65f202fadf0d859f8e12119fb ] Currently v4l2_device_register_subdev_nodes() does not initialize the dev_parent field of the video_device structs it creates for subdevices being registered. This leads to __video_register_device() falling back to the parent device of associated v4l2_device struct, which often does not match the physical device the subdevice is registered for. Due to the problem above, the links between real devices and v4l-subdev nodes cannot be obtained from sysfs, which might be confusing for the userspace trying to identify the hardware. Fix this by initializing the dev_parent field of the video_device struct with the value of dev field of the v4l2_subdev struct. In case of subdevices without a parent struct device, the field will be NULL and the old behavior will be preserved by the semantics of __video_register_device(). Signed-off-by: Tomasz Figa Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c index df0ac38c4050..e0ddb9a52bd1 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -247,6 +247,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) video_set_drvdata(vdev, sd); strscpy(vdev->name, sd->name, sizeof(vdev->name)); + vdev->dev_parent = sd->dev; vdev->v4l2_dev = v4l2_dev; vdev->fops = &v4l2_subdev_fops; vdev->release = v4l2_device_release_subdev_node; -- 2.19.1