From patchwork Fri Dec 15 04:32:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 10113827 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 8EE7060231 for ; Fri, 15 Dec 2017 04:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E82129E6D for ; Fri, 15 Dec 2017 04:32:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5221B29E71; Fri, 15 Dec 2017 04:32:36 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 C8BE229E6D for ; Fri, 15 Dec 2017 04:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754930AbdLOEca (ORCPT ); Thu, 14 Dec 2017 23:32:30 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33331 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754714AbdLOEc3 (ORCPT ); Thu, 14 Dec 2017 23:32:29 -0500 Received: by mail-pg0-f66.google.com with SMTP id g7so5018343pgs.0 for ; Thu, 14 Dec 2017 20:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=kFpSr9YrMq/iJIGRfLrJF/BXeXKnvBMt7g0z6t+PC68=; b=gWHS5xNYIsw+k2lCC2MWPu7PVQHfuBEJc1SIhe/c3hXJbycFR3NOXc1G/trdXvRSK1 JEqibLI5XGI1yk5oTyo+qw87szZF4UDJbwdOJ8lwgTQm7rVvbftbLfGcXYBZ5ky264A2 9S+PLwPh7fUyetieJ0ixyXeI8GkQNcrCSUJbA= 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=kFpSr9YrMq/iJIGRfLrJF/BXeXKnvBMt7g0z6t+PC68=; b=bnI8+q4TT2uyX/ZsngXjPouQ6AGpcO76oodC5g7MwuFnM07esoEaTU9S6Haj8vBFef 285IsL+Yb7fwJo2rX5c1u3DEPOzs/JwtpceJRxYI+77qWqG2RKHX5acCAWi/LSx1dlVa RF3OSoNleGKZxAQLu1YCAKpgB1jpMq0PnGoqJahC/7YhdVIHq8hmc7V6Nn6NSmdsOz98 Rns/AataGva//ODV/0cdoCpDL8Ul4LOJEnYAol7E6klbHfEnCewHyVtQ7ba1SSbQXJ7l MjScxyxV9TnfThxBpL76+8loabedsPFdQ+MF87FiA3bqperqdB7tfysZ60fOXDcHBqBF n+og== X-Gm-Message-State: AKGB3mIr1bR6udLR+mKrlWaikVNyW25a1BlO4TFOKbOLT10Jbc9FfxE2 B/vnKyeVjPpXdgGKlfmasZFruKH/75k= X-Google-Smtp-Source: ACJfBov/V/v6MKdJdMmoy2I/yjAR7b90LxMJQ9oZWBYHMW9OBapVvnuH3jnrbbZkNNuPO2VkldKxGg== X-Received: by 10.98.70.17 with SMTP id t17mr12073199pfa.199.1513312348310; Thu, 14 Dec 2017 20:32:28 -0800 (PST) Received: from tfiga.tok.corp.google.com ([2401:fa00:4:1002:3ba3:2aea:6dcf:30b]) by smtp.gmail.com with ESMTPSA id x3sm8737722pgv.73.2017.12.14.20.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 20:32:27 -0800 (PST) From: Tomasz Figa To: linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , Sakari Ailus , Ivaylo Dimitrov , Sebastian Reichel , Laurent Pinchart , Hans Verkuil , Tomasz Figa Subject: [RFC PATCH] media: v4l2-device: Link subdevices to their parent devices if available Date: Fri, 15 Dec 2017 13:32:21 +0900 Message-Id: <20171215043221.242719-1-tfiga@chromium.org> X-Mailer: git-send-email 2.15.1.504.g5279b80103-goog 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 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 --- 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 937c6de85606..450c97caf2c6 100644 --- a/drivers/media/v4l2-core/v4l2-device.c +++ b/drivers/media/v4l2-core/v4l2-device.c @@ -246,6 +246,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) video_set_drvdata(vdev, sd); strlcpy(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;