Skip to contentSkip to conversation

drm/bridge: adv7533: make array clock_div_by_lanes static const

PATCH Applied Colin Ian King 3 participants 3 messages Jan 9, 2022 – Jan 12, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/bridge: adv7533: make array clock_div_by_lanes static const

Don't populate the read-only array clock_div_by_lanes on the stack but instead it static const. Also makes the object code a little smaller.

---
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/adv7511/adv7533.c +1 -1
index eb7579dec40a..ef6270806d1d 100644
@@ -29,7 +29,7 @@ static void adv7511_dsi_config_timing_gen(struct adv7511 *adv)
 	struct mipi_dsi_device *dsi = adv->dsi;
 	struct drm_display_mode *mode = &adv->curr_mode;
 	unsigned int hsw, hfp, hbp, vsw, vfp, vbp;
-	u8 clock_div_by_lanes[] = { 6, 4, 3 };	/* 2, 3, 4 lanes */
+	static const u8 clock_div_by_lanes[] = { 6, 4, 3 };	/* 2, 3, 4 lanes */
 
 	hsw = mode->hsync_end - mode->hsync_start;
 	hfp = mode->hsync_start - mode->hdisplay;
Signature · 1 line
2.32.0
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Colin,

Thank you for the patch.

Quoted 13 lines · Colin Ian King

Don't populate the read-only array clock_div_by_lanes on the stack but instead it static const. Also makes the object code a little smaller.

---
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/adv7511/adv7533.c +0 -0
index eb7579dec40a..ef6270806d1d 100644

drivers/gpu/drm/bridge/adv7511/adv7533.c static void adv7511_dsi_config_timing_gen(struct adv7511 *adv) · line 32

Quoted 5 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +1 -1
@@ -29,7 +29,7 @@ static void adv7511_dsi_config_timing_gen(struct adv7511 *adv)
 	struct mipi_dsi_device *dsi = adv->dsi;
 	struct drm_display_mode *mode = &adv->curr_mode;
 	unsigned int hsw, hfp, hbp, vsw, vfp, vbp;
-	u8 clock_div_by_lanes[] = { 6, 4, 3 };	/* 2, 3, 4 lanes */
+	static const u8 clock_div_by_lanes[] = { 6, 4, 3 };	/* 2, 3, 4 lanes */

It's not mandatory, but I have a tendency to declare static const variable first before all mutable variables.

drivers/gpu/drm/bridge/adv7511/adv7533.c static void adv7511_dsi_config_timing_gen(struct adv7511 *adv) · line 35

Quoted 3 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +0 -0
 	hsw = mode->hsync_end - mode->hsync_start;
 	hfp = mode->hsync_start - mode->hdisplay;

I wonder if

	/* set pixel clock divider mode */
	regmap_write(adv->regmap_cec, 0x16, (12 / dsi->lanes) << 3);

would be even better, or if it would be too much black magic. Either way,

Signature · 3 lines
Regards,

Laurent Pinchart
Applied
#2 lore raw
Quoted 34 lines · Laurent Pinchart

Hi Colin,

Thank you for the patch.

Quoted 13 lines · Colin Ian King

Don't populate the read-only array clock_div_by_lanes on the stack but instead it static const. Also makes the object code a little smaller.

---
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/adv7511/adv7533.c +0 -0
index eb7579dec40a..ef6270806d1d 100644

drivers/gpu/drm/bridge/adv7511/adv7533.c static void adv7511_dsi_config_timing_gen(struct adv7511 *adv) · line 32

Quoted 5 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +1 -1
@@ -29,7 +29,7 @@ static void adv7511_dsi_config_timing_gen(struct adv7511 *adv)
      struct mipi_dsi_device *dsi = adv->dsi;
      struct drm_display_mode *mode = &adv->curr_mode;
      unsigned int hsw, hfp, hbp, vsw, vfp, vbp;
-     u8 clock_div_by_lanes[] = { 6, 4, 3 };  /* 2, 3, 4 lanes */
+     static const u8 clock_div_by_lanes[] = { 6, 4, 3 };     /* 2, 3, 4 lanes */

It's not mandatory, but I have a tendency to declare static const variable first before all mutable variables.

drivers/gpu/drm/bridge/adv7511/adv7533.c static void adv7511_dsi_config_timing_gen(struct adv7511 *adv) · line 35

Quoted 3 lines
drivers/gpu/drm/bridge/adv7511/adv7533.c +0 -0
      hsw = mode->hsync_end - mode->hsync_start;
      hfp = mode->hsync_start - mode->hdisplay;

I wonder if

Quoted 7 lines
        /* set pixel clock divider mode */
        regmap_write(adv->regmap_cec, 0x16, (12 / dsi->lanes) << 3);

would be even better, or if it would be too much black magic. Either way,

Applied to drm-misc-next.