linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers: tee: improve sysfs interface by using sysfs_emit()
@ 2025-07-18 15:30 Akhilesh Patil
  2025-07-21 10:56 ` Sumit Garg
  0 siblings, 1 reply; 3+ messages in thread
From: Akhilesh Patil @ 2025-07-18 15:30 UTC (permalink / raw)
  To: jens.wiklander, sumit.garg; +Cc: op-tee, linux-kernel, akhileshpatilvnit, skhan

Replace scnprintf() with sysfs_emit() while formatting buffer that is
passed to userspace as per the recommendation in
Documentation/filesystems/sysfs.rst. sysfs _show() callbacks should use
sysfs_emit() or sysfs_emit_at() while returning values to the userspace.
This change does not impact functionality, but aligns with sysfs
interface usage guidelines for the tee driver.

Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
---
 drivers/tee/optee/core.c | 2 +-
 drivers/tee/tee_core.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index c75fddc83576..ce44e3498d37 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -72,7 +72,7 @@ static ssize_t rpmb_routing_model_show(struct device *dev,
 	else
 		s = "user";
 
-	return scnprintf(buf, PAGE_SIZE, "%s\n", s);
+	return sysfs_emit(buf, "%s\n", s);
 }
 static DEVICE_ATTR_RO(rpmb_routing_model);
 
diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index acc7998758ad..944f913f8592 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -977,7 +977,7 @@ static ssize_t implementation_id_show(struct device *dev,
 	struct tee_ioctl_version_data vers;
 
 	teedev->desc->ops->get_version(teedev, &vers);
-	return scnprintf(buf, PAGE_SIZE, "%d\n", vers.impl_id);
+	return sysfs_emit(buf, "%d\n", vers.impl_id);
 }
 static DEVICE_ATTR_RO(implementation_id);
 
-- 
2.34.1


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

* Re: [PATCH] drivers: tee: improve sysfs interface by using sysfs_emit()
  2025-07-18 15:30 [PATCH] drivers: tee: improve sysfs interface by using sysfs_emit() Akhilesh Patil
@ 2025-07-21 10:56 ` Sumit Garg
  2025-08-04 11:20   ` Jens Wiklander
  0 siblings, 1 reply; 3+ messages in thread
From: Sumit Garg @ 2025-07-21 10:56 UTC (permalink / raw)
  To: Akhilesh Patil
  Cc: jens.wiklander, op-tee, linux-kernel, akhileshpatilvnit, skhan

On Fri, Jul 18, 2025 at 09:00:13PM +0530, Akhilesh Patil wrote:
> Replace scnprintf() with sysfs_emit() while formatting buffer that is
> passed to userspace as per the recommendation in
> Documentation/filesystems/sysfs.rst. sysfs _show() callbacks should use
> sysfs_emit() or sysfs_emit_at() while returning values to the userspace.
> This change does not impact functionality, but aligns with sysfs
> interface usage guidelines for the tee driver.
> 
> Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
> ---
>  drivers/tee/optee/core.c | 2 +-
>  drivers/tee/tee_core.c   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Nice catch.

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

-Sumit

> 
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index c75fddc83576..ce44e3498d37 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -72,7 +72,7 @@ static ssize_t rpmb_routing_model_show(struct device *dev,
>  	else
>  		s = "user";
>  
> -	return scnprintf(buf, PAGE_SIZE, "%s\n", s);
> +	return sysfs_emit(buf, "%s\n", s);
>  }
>  static DEVICE_ATTR_RO(rpmb_routing_model);
>  
> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> index acc7998758ad..944f913f8592 100644
> --- a/drivers/tee/tee_core.c
> +++ b/drivers/tee/tee_core.c
> @@ -977,7 +977,7 @@ static ssize_t implementation_id_show(struct device *dev,
>  	struct tee_ioctl_version_data vers;
>  
>  	teedev->desc->ops->get_version(teedev, &vers);
> -	return scnprintf(buf, PAGE_SIZE, "%d\n", vers.impl_id);
> +	return sysfs_emit(buf, "%d\n", vers.impl_id);
>  }
>  static DEVICE_ATTR_RO(implementation_id);
>  
> -- 
> 2.34.1
> 

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

* Re: [PATCH] drivers: tee: improve sysfs interface by using sysfs_emit()
  2025-07-21 10:56 ` Sumit Garg
@ 2025-08-04 11:20   ` Jens Wiklander
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Wiklander @ 2025-08-04 11:20 UTC (permalink / raw)
  To: Sumit Garg; +Cc: Akhilesh Patil, op-tee, linux-kernel, akhileshpatilvnit, skhan

On Mon, Jul 21, 2025 at 12:57 PM Sumit Garg <sumit.garg@kernel.org> wrote:
>
> On Fri, Jul 18, 2025 at 09:00:13PM +0530, Akhilesh Patil wrote:
> > Replace scnprintf() with sysfs_emit() while formatting buffer that is
> > passed to userspace as per the recommendation in
> > Documentation/filesystems/sysfs.rst. sysfs _show() callbacks should use
> > sysfs_emit() or sysfs_emit_at() while returning values to the userspace.
> > This change does not impact functionality, but aligns with sysfs
> > interface usage guidelines for the tee driver.
> >
> > Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
> > ---
> >  drivers/tee/optee/core.c | 2 +-
> >  drivers/tee/tee_core.c   | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
>
> Nice catch.
>
> Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

Looks good. I'm picking up this for v6.17.

Cheers,
Jens

>
> -Sumit
>
> >
> > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> > index c75fddc83576..ce44e3498d37 100644
> > --- a/drivers/tee/optee/core.c
> > +++ b/drivers/tee/optee/core.c
> > @@ -72,7 +72,7 @@ static ssize_t rpmb_routing_model_show(struct device *dev,
> >       else
> >               s = "user";
> >
> > -     return scnprintf(buf, PAGE_SIZE, "%s\n", s);
> > +     return sysfs_emit(buf, "%s\n", s);
> >  }
> >  static DEVICE_ATTR_RO(rpmb_routing_model);
> >
> > diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> > index acc7998758ad..944f913f8592 100644
> > --- a/drivers/tee/tee_core.c
> > +++ b/drivers/tee/tee_core.c
> > @@ -977,7 +977,7 @@ static ssize_t implementation_id_show(struct device *dev,
> >       struct tee_ioctl_version_data vers;
> >
> >       teedev->desc->ops->get_version(teedev, &vers);
> > -     return scnprintf(buf, PAGE_SIZE, "%d\n", vers.impl_id);
> > +     return sysfs_emit(buf, "%d\n", vers.impl_id);
> >  }
> >  static DEVICE_ATTR_RO(implementation_id);
> >
> > --
> > 2.34.1
> >

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

end of thread, other threads:[~2025-08-04 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18 15:30 [PATCH] drivers: tee: improve sysfs interface by using sysfs_emit() Akhilesh Patil
2025-07-21 10:56 ` Sumit Garg
2025-08-04 11:20   ` Jens Wiklander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).