[PATCH v2 1/5] drm/mipi-dsi: Add dev_is_mipi_dsi function

Maxime Ripard posted 5 patches 3 months, 2 weeks ago
[PATCH v2 1/5] drm/mipi-dsi: Add dev_is_mipi_dsi function
Posted by Maxime Ripard 3 months, 2 weeks ago
This will be especially useful for generic panels (like panel-simple)
which can take different code path depending on if they are MIPI-DSI
devices or platform devices.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
 drivers/gpu/drm/drm_mipi_dsi.c | 3 ++-
 include/drm/drm_mipi_dsi.h     | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index e5184a0c24651756ee0b1eb27d94083d63eb35a7..21fd647f8ce1a6a862e2f8fb5320e701f26f614f 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -89,16 +89,17 @@ static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
 	.thaw = pm_generic_thaw,
 	.poweroff = pm_generic_poweroff,
 	.restore = pm_generic_restore,
 };
 
-static const struct bus_type mipi_dsi_bus_type = {
+const struct bus_type mipi_dsi_bus_type = {
 	.name = "mipi-dsi",
 	.match = mipi_dsi_device_match,
 	.uevent = mipi_dsi_uevent,
 	.pm = &mipi_dsi_device_pm_ops,
 };
+EXPORT_SYMBOL_GPL(mipi_dsi_bus_type);
 
 /**
  * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
  *    device tree node
  * @np: device tree node
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index b37860f4a895c25ef8ba1c5b3f44827ef53aa100..6d2c08e8110151a97620389197f1ef79c058329d 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -221,10 +221,13 @@ struct mipi_dsi_multi_context {
 
 #define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
 
 #define to_mipi_dsi_device(__dev)	container_of_const(__dev, struct mipi_dsi_device, dev)
 
+extern const struct bus_type mipi_dsi_bus_type;
+#define dev_is_mipi_dsi(dev)	((dev)->bus == &mipi_dsi_bus_type)
+
 /**
  * mipi_dsi_pixel_format_to_bpp - obtain the number of bits per pixel for any
  *                                given pixel format defined by the MIPI DSI
  *                                specification
  * @fmt: MIPI DSI pixel format

-- 
2.49.0
Re: [PATCH v2 1/5] drm/mipi-dsi: Add dev_is_mipi_dsi function
Posted by Javier Martinez Canillas 3 months, 1 week ago
Maxime Ripard <mripard@kernel.org> writes:

Hello Maxime,

> This will be especially useful for generic panels (like panel-simple)
> which can take different code path depending on if they are MIPI-DSI
> devices or platform devices.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 3 ++-
>  include/drm/drm_mipi_dsi.h     | 3 +++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index e5184a0c24651756ee0b1eb27d94083d63eb35a7..21fd647f8ce1a6a862e2f8fb5320e701f26f614f 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -89,16 +89,17 @@ static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
>  	.thaw = pm_generic_thaw,
>  	.poweroff = pm_generic_poweroff,
>  	.restore = pm_generic_restore,
>  };
>  
> -static const struct bus_type mipi_dsi_bus_type = {
> +const struct bus_type mipi_dsi_bus_type = {
>  	.name = "mipi-dsi",
>  	.match = mipi_dsi_device_match,
>  	.uevent = mipi_dsi_uevent,
>  	.pm = &mipi_dsi_device_pm_ops,
>  };
> +EXPORT_SYMBOL_GPL(mipi_dsi_bus_type);
>  
>  /**
>   * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
>   *    device tree node
>   * @np: device tree node
> diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> index b37860f4a895c25ef8ba1c5b3f44827ef53aa100..6d2c08e8110151a97620389197f1ef79c058329d 100644
> --- a/include/drm/drm_mipi_dsi.h
> +++ b/include/drm/drm_mipi_dsi.h
> @@ -221,10 +221,13 @@ struct mipi_dsi_multi_context {
>  
>  #define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
>  
>  #define to_mipi_dsi_device(__dev)	container_of_const(__dev, struct mipi_dsi_device, dev)
>  
> +extern const struct bus_type mipi_dsi_bus_type;
> +#define dev_is_mipi_dsi(dev)	((dev)->bus == &mipi_dsi_bus_type)
> +

Usually I prefer to have static inline functions instead of macros to have
type checking. I see that this header has a mix of both, so I don't have a
strong opinion on what to use in this case.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Re: [PATCH v2 1/5] drm/mipi-dsi: Add dev_is_mipi_dsi function
Posted by Maxime Ripard 3 months, 1 week ago
On Fri, Jun 27, 2025 at 11:04:16AM +0200, Javier Martinez Canillas wrote:
> Maxime Ripard <mripard@kernel.org> writes:
> 
> Hello Maxime,
> 
> > This will be especially useful for generic panels (like panel-simple)
> > which can take different code path depending on if they are MIPI-DSI
> > devices or platform devices.
> >
> > Signed-off-by: Maxime Ripard <mripard@kernel.org>
> > ---
> >  drivers/gpu/drm/drm_mipi_dsi.c | 3 ++-
> >  include/drm/drm_mipi_dsi.h     | 3 +++
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> > index e5184a0c24651756ee0b1eb27d94083d63eb35a7..21fd647f8ce1a6a862e2f8fb5320e701f26f614f 100644
> > --- a/drivers/gpu/drm/drm_mipi_dsi.c
> > +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> > @@ -89,16 +89,17 @@ static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
> >  	.thaw = pm_generic_thaw,
> >  	.poweroff = pm_generic_poweroff,
> >  	.restore = pm_generic_restore,
> >  };
> >  
> > -static const struct bus_type mipi_dsi_bus_type = {
> > +const struct bus_type mipi_dsi_bus_type = {
> >  	.name = "mipi-dsi",
> >  	.match = mipi_dsi_device_match,
> >  	.uevent = mipi_dsi_uevent,
> >  	.pm = &mipi_dsi_device_pm_ops,
> >  };
> > +EXPORT_SYMBOL_GPL(mipi_dsi_bus_type);
> >  
> >  /**
> >   * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
> >   *    device tree node
> >   * @np: device tree node
> > diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
> > index b37860f4a895c25ef8ba1c5b3f44827ef53aa100..6d2c08e8110151a97620389197f1ef79c058329d 100644
> > --- a/include/drm/drm_mipi_dsi.h
> > +++ b/include/drm/drm_mipi_dsi.h
> > @@ -221,10 +221,13 @@ struct mipi_dsi_multi_context {
> >  
> >  #define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
> >  
> >  #define to_mipi_dsi_device(__dev)	container_of_const(__dev, struct mipi_dsi_device, dev)
> >  
> > +extern const struct bus_type mipi_dsi_bus_type;
> > +#define dev_is_mipi_dsi(dev)	((dev)->bus == &mipi_dsi_bus_type)
> > +
> 
> Usually I prefer to have static inline functions instead of macros to have
> type checking. I see that this header has a mix of both, so I don't have a
> strong opinion on what to use in this case.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Thanks for your review!

For the record, it's also how the platform bus defines its equivalent
macro, so that's why I went with it.

Maxime
Re: [PATCH v2 1/5] drm/mipi-dsi: Add dev_is_mipi_dsi function
Posted by Javier Martinez Canillas 3 months, 1 week ago
Maxime Ripard <mripard@kernel.org> writes:

> On Fri, Jun 27, 2025 at 11:04:16AM +0200, Javier Martinez Canillas wrote:
>> Maxime Ripard <mripard@kernel.org> writes:
>> 

[...]

>> 
>> Usually I prefer to have static inline functions instead of macros to have
>> type checking. I see that this header has a mix of both, so I don't have a
>> strong opinion on what to use in this case.
>> 
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>
> Thanks for your review!
>
> For the record, it's also how the platform bus defines its equivalent
> macro, so that's why I went with it.
>

Got it. I think is OK.

> Maxime

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat