On Thu, Apr 07, 2022 at 12:14:31PM +0300, Jani Nikula wrote: > Avoid casting here and there, and make it const. > > Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx> > --- > drivers/gpu/drm/drm_edid.c | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index 8638e54e0879..ba54701f91f6 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -1967,7 +1967,7 @@ drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len) > } > > static void connector_bad_edid(struct drm_connector *connector, > - u8 *edid, int num_blocks) > + const struct edid *edid, int num_blocks) > { > int i; > u8 last_block; > @@ -1978,22 +1978,19 @@ static void connector_bad_edid(struct drm_connector *connector, > * of 0x7e in the EDID of the _index_ of the last block in the > * combined chunk of memory. > */ > - last_block = edid[0x7e]; > + last_block = edid->extensions; > > /* Calculate real checksum for the last edid extension block data */ > if (last_block < num_blocks) > connector->real_edid_checksum = > - edid_block_compute_checksum(edid + last_block * EDID_LENGTH); > + edid_block_compute_checksum(edid + last_block); > > if (connector->bad_edid_counter++ && !drm_debug_enabled(DRM_UT_KMS)) > return; > > drm_dbg_kms(connector->dev, "%s: EDID is invalid:\n", connector->name); > - for (i = 0; i < num_blocks; i++) { > - u8 *block = edid + i * EDID_LENGTH; > - > - edid_block_dump(KERN_DEBUG, block, i); > - } > + for (i = 0; i < num_blocks; i++) > + edid_block_dump(KERN_DEBUG, edid + i, i); nit: I'm not a big fan of pointer arithmetic in general. IMO it makes it a bit too easy to miss the fact that it's not counting bytes but rather potentially something much bigger. So I tend to prefer array notation for such things. But looks like most of these go away at the end anyway with the block_data() stuff. Reviewed-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> > } > > /* Get override or firmware EDID */ > @@ -2139,7 +2136,7 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, > } > > if (invalid_blocks) { > - connector_bad_edid(connector, (u8 *)edid, edid->extensions + 1); > + connector_bad_edid(connector, edid, edid->extensions + 1); > > edid = edid_filter_invalid_blocks(edid, invalid_blocks); > } > -- > 2.30.2 -- Ville Syrjälä Intel