lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <7a68a0e3f927e26edca6040067fb653eb06efb79.1733840089.git.geert+renesas@glider.be>
Date: Tue, 10 Dec 2024 15:18:46 +0100
From: Geert Uytterhoeven <geert+renesas@...der.be>
To: Douglas Anderson <dianders@...omium.org>,
	Andrzej Hajda <andrzej.hajda@...el.com>,
	Neil Armstrong <neil.armstrong@...aro.org>,
	Robert Foss <rfoss@...nel.org>,
	Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
	Jonas Karlman <jonas@...boo.se>,
	Jernej Skrabec <jernej.skrabec@...il.com>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
	Maxime Ripard <mripard@...nel.org>,
	Thomas Zimmermann <tzimmermann@...e.de>,
	David Airlie <airlied@...il.com>,
	Simona Vetter <simona@...ll.ch>,
	Linus Walleij <linus.walleij@...aro.org>,
	Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
	Wolfram Sang <wsa+renesas@...g-engineering.com>,
	Luca Ceresoli <luca.ceresoli@...tlin.com>,
	Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
	Greg KH <gregkh@...uxfoundation.org>
Cc: dri-devel@...ts.freedesktop.org,
	linux-renesas-soc@...r.kernel.org,
	linux-i2c@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Geert Uytterhoeven <geert+renesas@...der.be>
Subject: [PATCH v2] drm/bridge: ti-sn65dsi86: Fix multiple instances

Each bridge instance creates up to four auxiliary devices with different
names.  However, their IDs are always zero, causing duplicate filename
errors when a system has multiple bridges:

    sysfs: cannot create duplicate filename '/bus/auxiliary/devices/ti_sn65dsi86.gpio.0'

Fix this by using a unique instance ID per bridge instance.  The
instance ID is derived from the I2C adapter number and the bridge's I2C
address, to support multiple instances on the same bus.

Fixes: bf73537f411b0d4f ("drm/bridge: ti-sn65dsi86: Break GPIO and MIPI-to-eDP bridge into sub-drivers")
Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
---
On the White Hawk development board:

    /sys/bus/auxiliary/devices/
    |-- ti_sn65dsi86.aux.1068
    |-- ti_sn65dsi86.aux.4140
    |-- ti_sn65dsi86.bridge.1068
    |-- ti_sn65dsi86.bridge.4140
    |-- ti_sn65dsi86.gpio.1068
    |-- ti_sn65dsi86.gpio.4140
    |-- ti_sn65dsi86.pwm.1068
    `-- ti_sn65dsi86.pwm.4140

Discussion after v1:
  - https://lore.kernel.org/8c2df6a903f87d4932586b25f1d3bd548fe8e6d1.1729180470.git.geert+renesas@glider.be

Notes:
  - While the bridge supports only two possible I2C addresses, I2C
    translators may be present, increasing the address space.  Hence the
    instance ID calculation assumes 10-bit addressing.  Perhaps it makes
    sense to introduce a global I2C helper function for this?

  - I think this is the simplest solution.  If/when the auxiliary bus
    receives support à la PLATFORM_DEVID_AUTO, the driver can be
    updated.

v2:
  - Use I2C adapter/address instead of ida_alloc().
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index 9e31f750fd889745..fb452d1b46995673 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -480,6 +480,7 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
 				       const char *name)
 {
 	struct device *dev = pdata->dev;
+	const struct i2c_client *client = to_i2c_client(dev);
 	struct auxiliary_device *aux;
 	int ret;
 
@@ -488,6 +489,7 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
 		return -ENOMEM;
 
 	aux->name = name;
+	aux->id = (client->adapter->nr << 10) | client->addr;
 	aux->dev.parent = dev;
 	aux->dev.release = ti_sn65dsi86_aux_device_release;
 	device_set_of_node_from_dev(&aux->dev, dev);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ