RE: [RESEND 5/6] drm/edid: add a helper for EDID sysfs property show

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: dri-devel <dri-devel-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of Jani
> Nikula
> Sent: Friday, May 10, 2024 8:38 PM
> To: dri-devel@xxxxxxxxxxxxxxxxxxxxx
> Cc: amd-gfx@xxxxxxxxxxxxxxxxxxxxx; nouveau@xxxxxxxxxxxxxxxxxxxxx; intel-
> gfx@xxxxxxxxxxxxxxxxxxxxx; Nikula, Jani <jani.nikula@xxxxxxxxx>
> Subject: [RESEND 5/6] drm/edid: add a helper for EDID sysfs property show
> 
> Add a helper to get the EDID property for sysfs property show. This hides all
> the edid_blob_ptr usage within drm_edid.c.
> 
> Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>

LGTM,
Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@xxxxxxxxx>



> ---
>  drivers/gpu/drm/drm_crtc_internal.h |  2 ++
>  drivers/gpu/drm/drm_edid.c          | 33 +++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_sysfs.c         | 24 ++-------------------
>  3 files changed, 37 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc_internal.h
> b/drivers/gpu/drm/drm_crtc_internal.h
> index 25aaae937ceb..20e9d7b206a2 100644
> --- a/drivers/gpu/drm/drm_crtc_internal.h
> +++ b/drivers/gpu/drm/drm_crtc_internal.h
> @@ -303,6 +303,8 @@ const u8 *drm_edid_find_extension(const struct
> drm_edid *drm_edid,
>  				  int ext_id, int *ext_index);
>  void drm_edid_cta_sad_get(const struct cea_sad *cta_sad, u8 *sad);  void
> drm_edid_cta_sad_set(struct cea_sad *cta_sad, const u8 *sad);
> +ssize_t drm_edid_connector_property_show(struct drm_connector
> *connector,
> +					 char *buf, loff_t off, size_t count);
> 
>  /* drm_edid_load.c */
>  #ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index
> 4f54c91b31b2..97362dd2330b 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -6969,6 +6969,39 @@ static int
> _drm_edid_connector_property_update(struct drm_connector *connector,
>  	return ret;
>  }
> 
> +/* For sysfs edid show implementation */ ssize_t
> +drm_edid_connector_property_show(struct drm_connector *connector,
> +					 char *buf, loff_t off, size_t count) {
> +	const void *edid;
> +	size_t size;
> +	ssize_t ret = 0;
> +
> +	mutex_lock(&connector->dev->mode_config.mutex);
> +
> +	if (!connector->edid_blob_ptr)
> +		goto unlock;
> +
> +	edid = connector->edid_blob_ptr->data;
> +	size = connector->edid_blob_ptr->length;
> +	if (!edid)
> +		goto unlock;
> +
> +	if (off >= size)
> +		goto unlock;
> +
> +	if (off + count > size)
> +		count = size - off;
> +
> +	memcpy(buf, edid + off, count);
> +
> +	ret = count;
> +unlock:
> +	mutex_unlock(&connector->dev->mode_config.mutex);
> +
> +	return ret;
> +}
> +
>  /**
>   * drm_edid_connector_update - Update connector information from EDID
>   * @connector: Connector
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index bd9b8ab4f82b..fb3bbb6adcd1 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -266,29 +266,9 @@ static ssize_t edid_show(struct file *filp, struct
> kobject *kobj,  {
>  	struct device *connector_dev = kobj_to_dev(kobj);
>  	struct drm_connector *connector =
> to_drm_connector(connector_dev);
> -	unsigned char *edid;
> -	size_t size;
> -	ssize_t ret = 0;
> +	ssize_t ret;
> 
> -	mutex_lock(&connector->dev->mode_config.mutex);
> -	if (!connector->edid_blob_ptr)
> -		goto unlock;
> -
> -	edid = connector->edid_blob_ptr->data;
> -	size = connector->edid_blob_ptr->length;
> -	if (!edid)
> -		goto unlock;
> -
> -	if (off >= size)
> -		goto unlock;
> -
> -	if (off + count > size)
> -		count = size - off;
> -	memcpy(buf, edid + off, count);
> -
> -	ret = count;
> -unlock:
> -	mutex_unlock(&connector->dev->mode_config.mutex);
> +	ret = drm_edid_connector_property_show(connector, buf, off, count);
> 
>  	return ret;
>  }
> --
> 2.39.2





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux