All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] habanalabs: use correct variable to show fd open counter
@ 2019-07-08 10:43 Oded Gabbay
  2019-07-08 11:08 ` Tomer Tayar
  2019-07-08 11:21 ` Greg KH
  0 siblings, 2 replies; 10+ messages in thread
From: Oded Gabbay @ 2019-07-08 10:43 UTC (permalink / raw)
  To: linux-kernel, oshpigelman, ttayar; +Cc: gregkh

The current code checks if the user context pointer is NULL or not to
display the number of open file descriptors of a device. However, that
variable (user_ctx) will eventually go away as the driver will support
multiple processes. Instead, the driver can use the atomic counter of
the open file descriptors which the driver already maintains.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
---
 drivers/misc/habanalabs/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/habanalabs/sysfs.c b/drivers/misc/habanalabs/sysfs.c
index 25eb46d29d88..881be19b5fad 100644
--- a/drivers/misc/habanalabs/sysfs.c
+++ b/drivers/misc/habanalabs/sysfs.c
@@ -356,7 +356,7 @@ static ssize_t write_open_cnt_show(struct device *dev,
 {
 	struct hl_device *hdev = dev_get_drvdata(dev);
 
-	return sprintf(buf, "%d\n", hdev->user_ctx ? 1 : 0);
+	return sprintf(buf, "%d\n", atomic_read(&hdev->fd_open_cnt));
 }
 
 static ssize_t soft_reset_cnt_show(struct device *dev,
-- 
2.17.1


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

end of thread, other threads:[~2019-07-08 14:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-08 10:43 [PATCH] habanalabs: use correct variable to show fd open counter Oded Gabbay
2019-07-08 11:08 ` Tomer Tayar
2019-07-08 11:21 ` Greg KH
2019-07-08 11:30   ` Oded Gabbay
2019-07-08 11:37     ` Oded Gabbay
2019-07-08 12:21       ` Greg KH
2019-07-08 11:42     ` Greg KH
2019-07-08 11:51       ` Oded Gabbay
2019-07-08 12:20         ` Greg KH
2019-07-08 14:28           ` Oded Gabbay

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.