public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/staging/gasket: Use refcount_read()
@ 2018-07-07  6:43 Todd Poynor
  2018-07-07  7:22 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Todd Poynor @ 2018-07-07  6:43 UTC (permalink / raw)
  To: Rob Springer, John Joseph, Ben Chan, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Todd Poynor

From: Todd Poynor <toddpoynor@google.com>

Use the refcount_read accessor function, avoid reaching into refcount
and atomic struct fields.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
 drivers/staging/gasket/gasket_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
index d45098c90b4b..b5cdc180772a 100644
--- a/drivers/staging/gasket/gasket_sysfs.c
+++ b/drivers/staging/gasket/gasket_sysfs.c
@@ -122,7 +122,7 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
 	}
 
 	mutex_lock(&mapping->mutex);
-	if (mapping->refcount.refcount.refs.counter == 0)
+	if (refcount_read(&mapping->refcount.refcount) == 0)
 		gasket_nodev_error("Refcount is already 0!");
 	if (kref_put(&mapping->refcount, release_entry)) {
 		gasket_nodev_info("Removing Gasket sysfs mapping, device %s",
-- 
2.18.0.203.gfac676dfb9-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drivers/staging/gasket: Use refcount_read()
  2018-07-07  6:43 [PATCH] drivers/staging/gasket: Use refcount_read() Todd Poynor
@ 2018-07-07  7:22 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2018-07-07  7:22 UTC (permalink / raw)
  To: Todd Poynor
  Cc: Rob Springer, John Joseph, Ben Chan, devel, Todd Poynor,
	linux-kernel

On Fri, Jul 06, 2018 at 11:43:10PM -0700, Todd Poynor wrote:
> From: Todd Poynor <toddpoynor@google.com>
> 
> Use the refcount_read accessor function, avoid reaching into refcount
> and atomic struct fields.
> 
> Signed-off-by: Todd Poynor <toddpoynor@google.com>
> ---
>  drivers/staging/gasket/gasket_sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/gasket/gasket_sysfs.c b/drivers/staging/gasket/gasket_sysfs.c
> index d45098c90b4b..b5cdc180772a 100644
> --- a/drivers/staging/gasket/gasket_sysfs.c
> +++ b/drivers/staging/gasket/gasket_sysfs.c
> @@ -122,7 +122,7 @@ static void put_mapping(struct gasket_sysfs_mapping *mapping)
>  	}
>  
>  	mutex_lock(&mapping->mutex);
> -	if (mapping->refcount.refcount.refs.counter == 0)
> +	if (refcount_read(&mapping->refcount.refcount) == 0)
>  		gasket_nodev_error("Refcount is already 0!");
>  	if (kref_put(&mapping->refcount, release_entry)) {
>  		gasket_nodev_info("Removing Gasket sysfs mapping, device %s",

Thanks for the patch, but ugh, why in the world is this driver even
doing this type of thing?  Odds are all of these reference counting
checks can be removed, something else to add to the "todo" file...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-07  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-07  6:43 [PATCH] drivers/staging/gasket: Use refcount_read() Todd Poynor
2018-07-07  7:22 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox