Skip to contentSkip to conversation

drm/sysfb: simpledrm: Fix device upcasts

PATCH In review Thomas Zimmermann 3 participants 7 messages Apr 7, 2025

Subsystems (4)
lore
Share & tools
lore

Thomas Zimmermann

author maintainer
#0 lore raw

cover drm/sysfb: simpledrm: Fix device upcasts

Simpledrm contains invalid upcasts from struct drm_device. Remove upcasting.

Thomas Zimmermann (2):
drm/simpledrm: Do not upcast in release helpers drm/sysfb: simpledrm: Remove unused helper simpledrm_device_of_dev()

 drivers/gpu/drm/sysfb/simpledrm.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 1/2 drm/simpledrm: Do not upcast in release helpers

The res pointer passed to simpledrm_device_release_clocks() and simpledrm_device_release_regulators() points to an instance of struct simpledrm_device. No need to upcast from struct drm_device. The upcast is harmless, as DRM device is the first field in struct simpledrm_device.

Fixes 11e8f5fd223b ("drm: Add simpledrm driver")
Cc <[email protected]> # v5.14+
---
 drivers/gpu/drm/sysfb/simpledrm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +2 -2
index cfb1fe07704d7..78672422bcada 100644
@@ -275,7 +275,7 @@ static struct simpledrm_device *simpledrm_device_of_dev(struct drm_device *dev)
 
 static void simpledrm_device_release_clocks(void *res)
 {
-	struct simpledrm_device *sdev = simpledrm_device_of_dev(res);
+	struct simpledrm_device *sdev = res;
 	unsigned int i;
 
 	for (i = 0; i < sdev->clk_count; ++i) {
@@ -373,7 +373,7 @@ static int simpledrm_device_init_clocks(struct simpledrm_device *sdev)
 
 static void simpledrm_device_release_regulators(void *res)
 {
-	struct simpledrm_device *sdev = simpledrm_device_of_dev(res);
+	struct simpledrm_device *sdev = res;
 	unsigned int i;
 
 	for (i = 0; i < sdev->regulator_count; ++i) {
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] drm/simpledrm: Do not upcast in release helpers

Quoted 10 lines · Thomas Zimmermann

The res pointer passed to simpledrm_device_release_clocks() and simpledrm_device_release_regulators() points to an instance of struct simpledrm_device. No need to upcast from struct drm_device. The upcast is harmless, as DRM device is the first field in struct simpledrm_device.

Fixes 11e8f5fd223b ("drm: Add simpledrm driver")
Cc <[email protected]> # v5.14+

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] drm/simpledrm: Do not upcast in release helpers

In reply to Thomas Zimmermann
Quoted 6 lines · Thomas Zimmermann

The res pointer passed to simpledrm_device_release_clocks() and simpledrm_device_release_regulators() points to an instance of struct simpledrm_device. No need to upcast from struct drm_device. The upcast is harmless, as DRM device is the first field in struct simpledrm_device.

Thanks, it looks good to me.

Quoted 29 lines
Fixes 11e8f5fd223b ("drm: Add simpledrm driver")
Cc <[email protected]> # v5.14+
---
  drivers/gpu/drm/sysfb/simpledrm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +2 -2
index cfb1fe07704d7..78672422bcada 100644
@@ -275,7 +275,7 @@ static struct simpledrm_device *simpledrm_device_of_dev(struct drm_device *dev)
 
  static void simpledrm_device_release_clocks(void *res)
  {
-	struct simpledrm_device *sdev = simpledrm_device_of_dev(res);
+	struct simpledrm_device *sdev = res;
  	unsigned int i;
 
  	for (i = 0; i < sdev->clk_count; ++i) {
@@ -373,7 +373,7 @@ static int simpledrm_device_init_clocks(struct simpledrm_device *sdev)
 
  static void simpledrm_device_release_regulators(void *res)
  {
-	struct simpledrm_device *sdev = simpledrm_device_of_dev(res);
+	struct simpledrm_device *sdev = res;
  	unsigned int i;
 
  	for (i = 0; i < sdev->regulator_count; ++i) {
author maintainer
#4 lore raw

PATCH 2/2 drm/sysfb: simpledrm: Remove unused helper simpledrm_device_of_dev()

In reply to Thomas Zimmermann

After moving most of the mode-setting pipeline into drm_sysfb_helper.c, simpledrm_device_of_dev() is no longer being used. Remove it.

Fixes 177dfbdb7e67 ("drm/sysfb: Merge primary-plane functions")
---
 drivers/gpu/drm/sysfb/simpledrm.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +0 -5
index 78672422bcada..f37b1994de71f 100644
@@ -244,11 +244,6 @@ struct simpledrm_device {
 	struct drm_connector connector;
 };
 
-static struct simpledrm_device *simpledrm_device_of_dev(struct drm_device *dev)
-{
-	return container_of(to_drm_sysfb_device(dev), struct simpledrm_device, sysfb);
-}
-
 /*
  * Hardware
  */
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] drm/sysfb: simpledrm: Remove unused helper simpledrm_device_of_dev()

Quoted 8 lines · Thomas Zimmermann

After moving most of the mode-setting pipeline into drm_sysfb_helper.c, simpledrm_device_of_dev() is no longer being used. Remove it.

Fixes 177dfbdb7e67 ("drm/sysfb: Merge primary-plane functions")

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] drm/sysfb: simpledrm: Remove unused helper simpledrm_device_of_dev()

In reply to Thomas Zimmermann
Quoted 3 lines · Thomas Zimmermann

After moving most of the mode-setting pipeline into drm_sysfb_helper.c, simpledrm_device_of_dev() is no longer being used. Remove it.

Thanks, it looks good to me.

Quoted 24 lines
Fixes 177dfbdb7e67 ("drm/sysfb: Merge primary-plane functions")
---
  drivers/gpu/drm/sysfb/simpledrm.c | 5 -----
  1 file changed, 5 deletions(-)
drivers/gpu/drm/sysfb/simpledrm.c +0 -5
index 78672422bcada..f37b1994de71f 100644
@@ -244,11 +244,6 @@ struct simpledrm_device {
  	struct drm_connector connector;
  };
 
-static struct simpledrm_device *simpledrm_device_of_dev(struct drm_device *dev)
-{
-	return container_of(to_drm_sysfb_device(dev), struct simpledrm_device, sysfb);
-}
-
  /*
   * Hardware
   */