dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/sun4i: use sun4i_tcon_of_table to check if a device node is a TCON
@ 2017-11-27  8:46 Chen-Yu Tsai
  2017-11-28 10:01 ` Maxime Ripard
  0 siblings, 1 reply; 4+ messages in thread
From: Chen-Yu Tsai @ 2017-11-27  8:46 UTC (permalink / raw)
  To: Maxime Ripard, David Airlie; +Cc: Chen-Yu Tsai, dri-devel

The sun4i DRM driver maintains a list of compatible strings it uses to
check if a device node within the display component graph is a TCON.
The TCON driver also has this list, used to bind the TCON driver to
the device. These two lists are identical.

Instead of maintaining two identical lists, export the list from the
TCON driver for the DRM driver to use.

Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/gpu/drm/sun4i/sun4i_drv.c  | 8 +-------
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 4 +++-
 drivers/gpu/drm/sun4i/sun4i_tcon.h | 2 ++
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 75c76cdd82bc..49215d91c853 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -187,13 +187,7 @@ static bool sun4i_drv_node_is_frontend(struct device_node *node)
 
 static bool sun4i_drv_node_is_tcon(struct device_node *node)
 {
-	return of_device_is_compatible(node, "allwinner,sun4i-a10-tcon") ||
-		of_device_is_compatible(node, "allwinner,sun5i-a13-tcon") ||
-		of_device_is_compatible(node, "allwinner,sun6i-a31-tcon") ||
-		of_device_is_compatible(node, "allwinner,sun6i-a31s-tcon") ||
-		of_device_is_compatible(node, "allwinner,sun7i-a20-tcon") ||
-		of_device_is_compatible(node, "allwinner,sun8i-a33-tcon") ||
-		of_device_is_compatible(node, "allwinner,sun8i-v3s-tcon");
+	return !!of_match_node(sun4i_tcon_of_table, node);
 }
 
 static int compare_of(struct device *dev, void *data)
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index e122f5b2a395..a1ed462c2430 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -900,7 +900,8 @@ static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
 	/* nothing is supported */
 };
 
-static const struct of_device_id sun4i_tcon_of_table[] = {
+/* sun4i_drv uses this list to check if a device node is a TCON */
+const struct of_device_id sun4i_tcon_of_table[] = {
 	{ .compatible = "allwinner,sun4i-a10-tcon", .data = &sun4i_a10_quirks },
 	{ .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks },
 	{ .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
@@ -911,6 +912,7 @@ static const struct of_device_id sun4i_tcon_of_table[] = {
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table);
+EXPORT_SYMBOL(sun4i_tcon_of_table);
 
 static struct platform_driver sun4i_tcon_platform_driver = {
 	.probe		= sun4i_tcon_probe,
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
index f61bf6d83b4a..839266a38505 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
@@ -197,4 +197,6 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
 void sun4i_tcon_set_status(struct sun4i_tcon *crtc,
 			   const struct drm_encoder *encoder, bool enable);
 
+extern const struct of_device_id sun4i_tcon_of_table[];
+
 #endif /* __SUN4I_TCON_H__ */
-- 
2.15.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/sun4i: use sun4i_tcon_of_table to check if a device node is a TCON
  2017-11-27  8:46 [PATCH] drm/sun4i: use sun4i_tcon_of_table to check if a device node is a TCON Chen-Yu Tsai
@ 2017-11-28 10:01 ` Maxime Ripard
  2017-11-29  3:43   ` Chen-Yu Tsai
  0 siblings, 1 reply; 4+ messages in thread
From: Maxime Ripard @ 2017-11-28 10:01 UTC (permalink / raw)
  To: Chen-Yu Tsai; +Cc: David Airlie, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 3482 bytes --]

Hi,

On Mon, Nov 27, 2017 at 04:46:32PM +0800, Chen-Yu Tsai wrote:
> The sun4i DRM driver maintains a list of compatible strings it uses to
> check if a device node within the display component graph is a TCON.
> The TCON driver also has this list, used to bind the TCON driver to
> the device. These two lists are identical.
> 
> Instead of maintaining two identical lists, export the list from the
> TCON driver for the DRM driver to use.
> 
> Suggested-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  drivers/gpu/drm/sun4i/sun4i_drv.c  | 8 +-------
>  drivers/gpu/drm/sun4i/sun4i_tcon.c | 4 +++-
>  drivers/gpu/drm/sun4i/sun4i_tcon.h | 2 ++
>  3 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> index 75c76cdd82bc..49215d91c853 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -187,13 +187,7 @@ static bool sun4i_drv_node_is_frontend(struct device_node *node)
>  
>  static bool sun4i_drv_node_is_tcon(struct device_node *node)
>  {
> -	return of_device_is_compatible(node, "allwinner,sun4i-a10-tcon") ||
> -		of_device_is_compatible(node, "allwinner,sun5i-a13-tcon") ||
> -		of_device_is_compatible(node, "allwinner,sun6i-a31-tcon") ||
> -		of_device_is_compatible(node, "allwinner,sun6i-a31s-tcon") ||
> -		of_device_is_compatible(node, "allwinner,sun7i-a20-tcon") ||
> -		of_device_is_compatible(node, "allwinner,sun8i-a33-tcon") ||
> -		of_device_is_compatible(node, "allwinner,sun8i-v3s-tcon");
> +	return !!of_match_node(sun4i_tcon_of_table, node);
>  }
>  
>  static int compare_of(struct device *dev, void *data)
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> index e122f5b2a395..a1ed462c2430 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> @@ -900,7 +900,8 @@ static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
>  	/* nothing is supported */
>  };
>  
> -static const struct of_device_id sun4i_tcon_of_table[] = {
> +/* sun4i_drv uses this list to check if a device node is a TCON */
> +const struct of_device_id sun4i_tcon_of_table[] = {
>  	{ .compatible = "allwinner,sun4i-a10-tcon", .data = &sun4i_a10_quirks },
>  	{ .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks },
>  	{ .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
> @@ -911,6 +912,7 @@ static const struct of_device_id sun4i_tcon_of_table[] = {
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table);
> +EXPORT_SYMBOL(sun4i_tcon_of_table);
>  
>  static struct platform_driver sun4i_tcon_platform_driver = {
>  	.probe		= sun4i_tcon_probe,
> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
> index f61bf6d83b4a..839266a38505 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
> @@ -197,4 +197,6 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
>  void sun4i_tcon_set_status(struct sun4i_tcon *crtc,
>  			   const struct drm_encoder *encoder, bool enable);
>  
> +extern const struct of_device_id sun4i_tcon_of_table[];
> +

I'm not very fond of that approach. Maybe we can place the structure
in the tcon header?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/sun4i: use sun4i_tcon_of_table to check if a device node is a TCON
  2017-11-28 10:01 ` Maxime Ripard
@ 2017-11-29  3:43   ` Chen-Yu Tsai
  2017-11-30 15:46     ` Maxime Ripard
  0 siblings, 1 reply; 4+ messages in thread
From: Chen-Yu Tsai @ 2017-11-29  3:43 UTC (permalink / raw)
  To: Maxime Ripard; +Cc: David Airlie, Chen-Yu Tsai, dri-devel

On Tue, Nov 28, 2017 at 6:01 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Mon, Nov 27, 2017 at 04:46:32PM +0800, Chen-Yu Tsai wrote:
>> The sun4i DRM driver maintains a list of compatible strings it uses to
>> check if a device node within the display component graph is a TCON.
>> The TCON driver also has this list, used to bind the TCON driver to
>> the device. These two lists are identical.
>>
>> Instead of maintaining two identical lists, export the list from the
>> TCON driver for the DRM driver to use.
>>
>> Suggested-by: Rob Herring <robh@kernel.org>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> ---
>>  drivers/gpu/drm/sun4i/sun4i_drv.c  | 8 +-------
>>  drivers/gpu/drm/sun4i/sun4i_tcon.c | 4 +++-
>>  drivers/gpu/drm/sun4i/sun4i_tcon.h | 2 ++
>>  3 files changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
>> index 75c76cdd82bc..49215d91c853 100644
>> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
>> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
>> @@ -187,13 +187,7 @@ static bool sun4i_drv_node_is_frontend(struct device_node *node)
>>
>>  static bool sun4i_drv_node_is_tcon(struct device_node *node)
>>  {
>> -     return of_device_is_compatible(node, "allwinner,sun4i-a10-tcon") ||
>> -             of_device_is_compatible(node, "allwinner,sun5i-a13-tcon") ||
>> -             of_device_is_compatible(node, "allwinner,sun6i-a31-tcon") ||
>> -             of_device_is_compatible(node, "allwinner,sun6i-a31s-tcon") ||
>> -             of_device_is_compatible(node, "allwinner,sun7i-a20-tcon") ||
>> -             of_device_is_compatible(node, "allwinner,sun8i-a33-tcon") ||
>> -             of_device_is_compatible(node, "allwinner,sun8i-v3s-tcon");
>> +     return !!of_match_node(sun4i_tcon_of_table, node);
>>  }
>>
>>  static int compare_of(struct device *dev, void *data)
>> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
>> index e122f5b2a395..a1ed462c2430 100644
>> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
>> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
>> @@ -900,7 +900,8 @@ static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
>>       /* nothing is supported */
>>  };
>>
>> -static const struct of_device_id sun4i_tcon_of_table[] = {
>> +/* sun4i_drv uses this list to check if a device node is a TCON */
>> +const struct of_device_id sun4i_tcon_of_table[] = {
>>       { .compatible = "allwinner,sun4i-a10-tcon", .data = &sun4i_a10_quirks },
>>       { .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks },
>>       { .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
>> @@ -911,6 +912,7 @@ static const struct of_device_id sun4i_tcon_of_table[] = {
>>       { }
>>  };
>>  MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table);
>> +EXPORT_SYMBOL(sun4i_tcon_of_table);
>>
>>  static struct platform_driver sun4i_tcon_platform_driver = {
>>       .probe          = sun4i_tcon_probe,
>> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
>> index f61bf6d83b4a..839266a38505 100644
>> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
>> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
>> @@ -197,4 +197,6 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
>>  void sun4i_tcon_set_status(struct sun4i_tcon *crtc,
>>                          const struct drm_encoder *encoder, bool enable);
>>
>> +extern const struct of_device_id sun4i_tcon_of_table[];
>> +
>
> I'm not very fond of that approach. Maybe we can place the structure
> in the tcon header?

Doesn't that mean you get one copy of everything wherever they are referenced?
This is assuming the compiler trims unused ones from files that include the
header file.

ChenYu
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/sun4i: use sun4i_tcon_of_table to check if a device node is a TCON
  2017-11-29  3:43   ` Chen-Yu Tsai
@ 2017-11-30 15:46     ` Maxime Ripard
  0 siblings, 0 replies; 4+ messages in thread
From: Maxime Ripard @ 2017-11-30 15:46 UTC (permalink / raw)
  To: Chen-Yu Tsai; +Cc: David Airlie, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4197 bytes --]

On Wed, Nov 29, 2017 at 11:43:14AM +0800, Chen-Yu Tsai wrote:
> On Tue, Nov 28, 2017 at 6:01 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > Hi,
> >
> > On Mon, Nov 27, 2017 at 04:46:32PM +0800, Chen-Yu Tsai wrote:
> >> The sun4i DRM driver maintains a list of compatible strings it uses to
> >> check if a device node within the display component graph is a TCON.
> >> The TCON driver also has this list, used to bind the TCON driver to
> >> the device. These two lists are identical.
> >>
> >> Instead of maintaining two identical lists, export the list from the
> >> TCON driver for the DRM driver to use.
> >>
> >> Suggested-by: Rob Herring <robh@kernel.org>
> >> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> >> ---
> >>  drivers/gpu/drm/sun4i/sun4i_drv.c  | 8 +-------
> >>  drivers/gpu/drm/sun4i/sun4i_tcon.c | 4 +++-
> >>  drivers/gpu/drm/sun4i/sun4i_tcon.h | 2 ++
> >>  3 files changed, 6 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
> >> index 75c76cdd82bc..49215d91c853 100644
> >> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> >> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> >> @@ -187,13 +187,7 @@ static bool sun4i_drv_node_is_frontend(struct device_node *node)
> >>
> >>  static bool sun4i_drv_node_is_tcon(struct device_node *node)
> >>  {
> >> -     return of_device_is_compatible(node, "allwinner,sun4i-a10-tcon") ||
> >> -             of_device_is_compatible(node, "allwinner,sun5i-a13-tcon") ||
> >> -             of_device_is_compatible(node, "allwinner,sun6i-a31-tcon") ||
> >> -             of_device_is_compatible(node, "allwinner,sun6i-a31s-tcon") ||
> >> -             of_device_is_compatible(node, "allwinner,sun7i-a20-tcon") ||
> >> -             of_device_is_compatible(node, "allwinner,sun8i-a33-tcon") ||
> >> -             of_device_is_compatible(node, "allwinner,sun8i-v3s-tcon");
> >> +     return !!of_match_node(sun4i_tcon_of_table, node);
> >>  }
> >>
> >>  static int compare_of(struct device *dev, void *data)
> >> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> >> index e122f5b2a395..a1ed462c2430 100644
> >> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
> >> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
> >> @@ -900,7 +900,8 @@ static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
> >>       /* nothing is supported */
> >>  };
> >>
> >> -static const struct of_device_id sun4i_tcon_of_table[] = {
> >> +/* sun4i_drv uses this list to check if a device node is a TCON */
> >> +const struct of_device_id sun4i_tcon_of_table[] = {
> >>       { .compatible = "allwinner,sun4i-a10-tcon", .data = &sun4i_a10_quirks },
> >>       { .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks },
> >>       { .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
> >> @@ -911,6 +912,7 @@ static const struct of_device_id sun4i_tcon_of_table[] = {
> >>       { }
> >>  };
> >>  MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table);
> >> +EXPORT_SYMBOL(sun4i_tcon_of_table);
> >>
> >>  static struct platform_driver sun4i_tcon_platform_driver = {
> >>       .probe          = sun4i_tcon_probe,
> >> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
> >> index f61bf6d83b4a..839266a38505 100644
> >> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
> >> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
> >> @@ -197,4 +197,6 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
> >>  void sun4i_tcon_set_status(struct sun4i_tcon *crtc,
> >>                          const struct drm_encoder *encoder, bool enable);
> >>
> >> +extern const struct of_device_id sun4i_tcon_of_table[];
> >> +
> >
> > I'm not very fond of that approach. Maybe we can place the structure
> > in the tcon header?
> 
> Doesn't that mean you get one copy of everything wherever they are referenced?
> This is assuming the compiler trims unused ones from files that include the
> header file.

Indeed. I've applied this patch, thanks!
Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-30 15:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27  8:46 [PATCH] drm/sun4i: use sun4i_tcon_of_table to check if a device node is a TCON Chen-Yu Tsai
2017-11-28 10:01 ` Maxime Ripard
2017-11-29  3:43   ` Chen-Yu Tsai
2017-11-30 15:46     ` Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).