[PATCH 03/10] drm/sysfs: Annote lockless show functions with READ_ONCE

Daniel Vetter daniel at ffwll.ch
Tue Apr 26 11:24:15 UTC 2016


On Wed, Mar 30, 2016 at 11:45:13AM +0200, Daniel Vetter wrote:
> For documentation and paranoia.
> 
> Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>

Merged to drm-misc with Chris' irc ack - we just discussed the opposite
WRITE_ONCE in some other patches.
-Daniel

> ---
>  drivers/gpu/drm/drm_sysfs.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
> index d503f8e8c2d1..43875cb35691 100644
> --- a/drivers/gpu/drm/drm_sysfs.c
> +++ b/drivers/gpu/drm/drm_sysfs.c
> @@ -208,9 +208,12 @@ static ssize_t status_show(struct device *device,
>  			   char *buf)
>  {
>  	struct drm_connector *connector = to_drm_connector(device);
> +	enum drm_connector_status status;
> +
> +	status = READ_ONCE(connector->status);
>  
>  	return snprintf(buf, PAGE_SIZE, "%s\n",
> -			drm_get_connector_status_name(connector->status));
> +			drm_get_connector_status_name(status));
>  }
>  
>  static ssize_t dpms_show(struct device *device,
> @@ -231,9 +234,11 @@ static ssize_t enabled_show(struct device *device,
>  			   char *buf)
>  {
>  	struct drm_connector *connector = to_drm_connector(device);
> +	bool enabled;
> +
> +	enabled = READ_ONCE(connector->encoder);
>  
> -	return snprintf(buf, PAGE_SIZE, "%s\n", connector->encoder ? "enabled" :
> -			"disabled");
> +	return snprintf(buf, PAGE_SIZE, enabled ? "enabled\n" : "disabled\n");
>  }
>  
>  static ssize_t edid_show(struct file *filp, struct kobject *kobj,
> -- 
> 2.8.0.rc3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list