All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Douglas Anderson <dianders@chromium.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>, Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: ti-sn65dsi86: Fix multiple instances
Date: Fri, 18 Oct 2024 16:10:35 +0300	[thread overview]
Message-ID: <20241018131035.GA20602@pendragon.ideasonboard.com> (raw)
In-Reply-To: <8c2df6a903f87d4932586b25f1d3bd548fe8e6d1.1729180470.git.geert+renesas@glider.be>

Hi Geert,

Thank you for the patch.

On Fri, Oct 18, 2024 at 09:45:52AM +0200, Geert Uytterhoeven wrote:
> 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.

Isn't this something that should be handled by the AUX core ? The code
below would otherwise need to be duplicated by all drivers, which seems
a burden we should avoid.

> Fixes: bf73537f411b0d4f ("drm/bridge: ti-sn65dsi86: Break GPIO and MIPI-to-eDP bridge into sub-drivers")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> /sys/bus/auxiliary/devices
> ├── ti_sn65dsi86.gpio.0
> ├── ti_sn65dsi86.pwm.0
> ├── ti_sn65dsi86.aux.0
> ├── ti_sn65dsi86.bridge.0
> ├── ti_sn65dsi86.gpio.1
> ├── ti_sn65dsi86.pwm.1
> ├── ti_sn65dsi86.aux.1
> └── ti_sn65dsi86.bridge.1
> ---
>  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> index 9e31f750fd889745..8f6ac48aefdb70b3 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> @@ -13,6 +13,7 @@
>  #include <linux/gpio/consumer.h>
>  #include <linux/gpio/driver.h>
>  #include <linux/i2c.h>
> +#include <linux/idr.h>
>  #include <linux/iopoll.h>
>  #include <linux/module.h>
>  #include <linux/of_graph.h>
> @@ -168,6 +169,7 @@
>   * @pwm_enabled:  Used to track if the PWM signal is currently enabled.
>   * @pwm_pin_busy: Track if GPIO4 is currently requested for GPIO or PWM.
>   * @pwm_refclk_freq: Cache for the reference clock input to the PWM.
> + * @id:           Unique instance ID
>   */
>  struct ti_sn65dsi86 {
>  	struct auxiliary_device		*bridge_aux;
> @@ -202,8 +204,11 @@ struct ti_sn65dsi86 {
>  	atomic_t			pwm_pin_busy;
>  #endif
>  	unsigned int			pwm_refclk_freq;
> +	int				id;
>  };
>  
> +static DEFINE_IDA(ti_sn65dsi86_ida);
> +
>  static const struct regmap_range ti_sn65dsi86_volatile_ranges[] = {
>  	{ .range_min = 0, .range_max = 0xFF },
>  };
> @@ -488,6 +493,7 @@ static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata,
>  		return -ENOMEM;
>  
>  	aux->name = name;
> +	aux->id = pdata->id;
>  	aux->dev.parent = dev;
>  	aux->dev.release = ti_sn65dsi86_aux_device_release;
>  	device_set_of_node_from_dev(&aux->dev, dev);
> @@ -1889,6 +1895,13 @@ static int ti_sn65dsi86_parse_regulators(struct ti_sn65dsi86 *pdata)
>  				       pdata->supplies);
>  }
>  
> +static void ti_sn65dsi86_devm_ida_free(void *data)
> +{
> +	struct ti_sn65dsi86 *pdata = data;
> +
> +	ida_free(&ti_sn65dsi86_ida, pdata->id);
> +}
> +
>  static int ti_sn65dsi86_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
> @@ -1903,6 +1916,17 @@ static int ti_sn65dsi86_probe(struct i2c_client *client)
>  	pdata = devm_kzalloc(dev, sizeof(struct ti_sn65dsi86), GFP_KERNEL);
>  	if (!pdata)
>  		return -ENOMEM;
> +
> +	ret = ida_alloc(&ti_sn65dsi86_ida, GFP_KERNEL);
> +	if (ret < 0)
> +		return ret;
> +
> +	pdata->id = ret;
> +
> +	ret = devm_add_action_or_reset(dev, ti_sn65dsi86_devm_ida_free, pdata);
> +	if (ret)
> +		return ret;
> +
>  	dev_set_drvdata(dev, pdata);
>  	pdata->dev = dev;
>  

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2024-10-18 13:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18  7:45 [PATCH] drm/bridge: ti-sn65dsi86: Fix multiple instances Geert Uytterhoeven
2024-10-18 13:10 ` Laurent Pinchart [this message]
2024-10-18 13:36   ` Geert Uytterhoeven
2024-10-18 14:09     ` Greg KH
2024-10-18 14:25       ` Laurent Pinchart
2024-10-18 14:31         ` Greg KH
2024-10-20 14:36           ` Laurent Pinchart
2024-10-21  6:39             ` Greg KH
2024-10-21  6:58               ` Geert Uytterhoeven
2024-10-21  7:27                 ` Greg KH
2024-10-21  8:23                   ` Geert Uytterhoeven
2024-10-21  8:28                     ` Laurent Pinchart
2024-10-21  8:47                     ` Geert Uytterhoeven
2024-10-22  0:20                       ` Doug Anderson
2024-10-22  7:11                         ` Geert Uytterhoeven
2024-10-22 14:37                           ` Doug Anderson
2024-10-28 13:34                             ` Dmitry Baryshkov
2024-10-30 10:25                               ` Geert Uytterhoeven
2024-10-30 10:28                                 ` Laurent Pinchart
2024-10-31 23:08                                   ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241018131035.GA20602@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert+renesas@glider.be \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linus.walleij@linaro.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.