diff mbox series

drm/i915/gt: Use sysfs_emit() and sysfs_emit_at()

Message ID 20230130131358.16800-1-nirmoy.das@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/gt: Use sysfs_emit() and sysfs_emit_at() | expand

Commit Message

Nirmoy Das Jan. 30, 2023, 1:13 p.m. UTC
Use sysfs_emit() and sysfs_emit_at() in show() callback
as recommended by Documentation/filesystems/sysfs.rst

Cc: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
---
 drivers/gpu/drm/i915/gt/sysfs_engines.c | 34 ++++++++++++-------------
 1 file changed, 16 insertions(+), 18 deletions(-)

Comments

Rodrigo Vivi Jan. 30, 2023, 3:42 p.m. UTC | #1
On Mon, Jan 30, 2023 at 02:13:58PM +0100, Nirmoy Das wrote:
> Use sysfs_emit() and sysfs_emit_at() in show() callback
> as recommended by Documentation/filesystems/sysfs.rst
> 
> Cc: Andi Shyti <andi.shyti@linux.intel.com>
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/i915/gt/sysfs_engines.c | 34 ++++++++++++-------------
>  1 file changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> index f2d9858d827c..323cead181b8 100644
> --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
> +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> @@ -24,7 +24,7 @@ static struct intel_engine_cs *kobj_to_engine(struct kobject *kobj)
>  static ssize_t
>  name_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%s\n", kobj_to_engine(kobj)->name);
> +	return sysfs_emit(buf, "%s\n", kobj_to_engine(kobj)->name);
>  }
>  
>  static struct kobj_attribute name_attr =
> @@ -33,7 +33,7 @@ __ATTR(name, 0444, name_show, NULL);
>  static ssize_t
>  class_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
>  }
>  
>  static struct kobj_attribute class_attr =
> @@ -42,7 +42,7 @@ __ATTR(class, 0444, class_show, NULL);
>  static ssize_t
>  inst_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
>  }
>  
>  static struct kobj_attribute inst_attr =
> @@ -51,7 +51,7 @@ __ATTR(instance, 0444, inst_show, NULL);
>  static ssize_t
>  mmio_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
> +	return sysfs_emit(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
>  }
>  
>  static struct kobj_attribute mmio_attr =
> @@ -107,11 +107,9 @@ __caps_show(struct intel_engine_cs *engine,
>  	for_each_set_bit(n, &caps, show_unknown ? BITS_PER_LONG : count) {
>  		if (n >= count || !repr[n]) {
>  			if (GEM_WARN_ON(show_unknown))
> -				len += snprintf(buf + len, PAGE_SIZE - len,
> -						"[%x] ", n);
> +				len += sysfs_emit_at(buf, len, "[%x] ", n);
>  		} else {
> -			len += snprintf(buf + len, PAGE_SIZE - len,
> -					"%s ", repr[n]);
> +			len += sysfs_emit_at(buf, len, "%s ", repr[n]);
>  		}
>  		if (GEM_WARN_ON(len >= PAGE_SIZE))
>  			break;
> @@ -182,7 +180,7 @@ max_spin_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.max_busywait_duration_ns);
> +	return sysfs_emit(buf, "%lu\n", engine->props.max_busywait_duration_ns);
>  }
>  
>  static struct kobj_attribute max_spin_attr =
> @@ -193,7 +191,7 @@ max_spin_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
>  }
>  
>  static struct kobj_attribute max_spin_def =
> @@ -236,7 +234,7 @@ timeslice_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.timeslice_duration_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.timeslice_duration_ms);
>  }
>  
>  static struct kobj_attribute timeslice_duration_attr =
> @@ -247,7 +245,7 @@ timeslice_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
>  }
>  
>  static struct kobj_attribute timeslice_duration_def =
> @@ -287,7 +285,7 @@ stop_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.stop_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.stop_timeout_ms);
>  }
>  
>  static struct kobj_attribute stop_timeout_attr =
> @@ -298,7 +296,7 @@ stop_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.stop_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.stop_timeout_ms);
>  }
>  
>  static struct kobj_attribute stop_timeout_def =
> @@ -343,7 +341,7 @@ preempt_timeout_show(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.preempt_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.preempt_timeout_ms);
>  }
>  
>  static struct kobj_attribute preempt_timeout_attr =
> @@ -355,7 +353,7 @@ preempt_timeout_default(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
>  }
>  
>  static struct kobj_attribute preempt_timeout_def =
> @@ -399,7 +397,7 @@ heartbeat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.heartbeat_interval_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.heartbeat_interval_ms);
>  }
>  
>  static struct kobj_attribute heartbeat_interval_attr =
> @@ -410,7 +408,7 @@ heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
>  }
>  
>  static struct kobj_attribute heartbeat_interval_def =
> -- 
> 2.39.0
>
Andi Shyti Jan. 30, 2023, 8:43 p.m. UTC | #2
Hi Nirmoy,

On Mon, Jan 30, 2023 at 02:13:58PM +0100, Nirmoy Das wrote:
> Use sysfs_emit() and sysfs_emit_at() in show() callback
> as recommended by Documentation/filesystems/sysfs.rst
> 
> Cc: Andi Shyti <andi.shyti@linux.intel.com>
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>

I thought we didn't have anymore of those...

Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>

Thanks,
Andi

> ---
>  drivers/gpu/drm/i915/gt/sysfs_engines.c | 34 ++++++++++++-------------
>  1 file changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> index f2d9858d827c..323cead181b8 100644
> --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
> +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> @@ -24,7 +24,7 @@ static struct intel_engine_cs *kobj_to_engine(struct kobject *kobj)
>  static ssize_t
>  name_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%s\n", kobj_to_engine(kobj)->name);
> +	return sysfs_emit(buf, "%s\n", kobj_to_engine(kobj)->name);
>  }
>  
>  static struct kobj_attribute name_attr =
> @@ -33,7 +33,7 @@ __ATTR(name, 0444, name_show, NULL);
>  static ssize_t
>  class_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
>  }
>  
>  static struct kobj_attribute class_attr =
> @@ -42,7 +42,7 @@ __ATTR(class, 0444, class_show, NULL);
>  static ssize_t
>  inst_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
>  }
>  
>  static struct kobj_attribute inst_attr =
> @@ -51,7 +51,7 @@ __ATTR(instance, 0444, inst_show, NULL);
>  static ssize_t
>  mmio_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
> +	return sysfs_emit(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
>  }
>  
>  static struct kobj_attribute mmio_attr =
> @@ -107,11 +107,9 @@ __caps_show(struct intel_engine_cs *engine,
>  	for_each_set_bit(n, &caps, show_unknown ? BITS_PER_LONG : count) {
>  		if (n >= count || !repr[n]) {
>  			if (GEM_WARN_ON(show_unknown))
> -				len += snprintf(buf + len, PAGE_SIZE - len,
> -						"[%x] ", n);
> +				len += sysfs_emit_at(buf, len, "[%x] ", n);
>  		} else {
> -			len += snprintf(buf + len, PAGE_SIZE - len,
> -					"%s ", repr[n]);
> +			len += sysfs_emit_at(buf, len, "%s ", repr[n]);
>  		}
>  		if (GEM_WARN_ON(len >= PAGE_SIZE))
>  			break;
> @@ -182,7 +180,7 @@ max_spin_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.max_busywait_duration_ns);
> +	return sysfs_emit(buf, "%lu\n", engine->props.max_busywait_duration_ns);
>  }
>  
>  static struct kobj_attribute max_spin_attr =
> @@ -193,7 +191,7 @@ max_spin_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
>  }
>  
>  static struct kobj_attribute max_spin_def =
> @@ -236,7 +234,7 @@ timeslice_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.timeslice_duration_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.timeslice_duration_ms);
>  }
>  
>  static struct kobj_attribute timeslice_duration_attr =
> @@ -247,7 +245,7 @@ timeslice_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
>  }
>  
>  static struct kobj_attribute timeslice_duration_def =
> @@ -287,7 +285,7 @@ stop_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.stop_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.stop_timeout_ms);
>  }
>  
>  static struct kobj_attribute stop_timeout_attr =
> @@ -298,7 +296,7 @@ stop_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.stop_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.stop_timeout_ms);
>  }
>  
>  static struct kobj_attribute stop_timeout_def =
> @@ -343,7 +341,7 @@ preempt_timeout_show(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.preempt_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.preempt_timeout_ms);
>  }
>  
>  static struct kobj_attribute preempt_timeout_attr =
> @@ -355,7 +353,7 @@ preempt_timeout_default(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
>  }
>  
>  static struct kobj_attribute preempt_timeout_def =
> @@ -399,7 +397,7 @@ heartbeat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.heartbeat_interval_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.heartbeat_interval_ms);
>  }
>  
>  static struct kobj_attribute heartbeat_interval_attr =
> @@ -410,7 +408,7 @@ heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
>  }
>  
>  static struct kobj_attribute heartbeat_interval_def =
> -- 
> 2.39.0
Nirmoy Das Jan. 31, 2023, 11:35 a.m. UTC | #3
Rerun passed well https://patchwork.freedesktop.org/series/113490/

On 1/30/2023 6:49 PM, Patchwork wrote:
> Project List - Patchwork *Patch Details*
> *Series:* 	drm/i915/gt: Use sysfs_emit() and sysfs_emit_at()
> *URL:* 	https://patchwork.freedesktop.org/series/113490/
> *State:* 	failure
> *Details:* 
> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/index.html
>
>
>   CI Bug Log - changes from CI_DRM_12666 -> Patchwork_113490v1
>
>
>     Summary
>
> *FAILURE*
>
> Serious unknown changes coming with Patchwork_113490v1 absolutely need 
> to be
> verified manually.
>
> If you think the reported changes have nothing to do with the changes
> introduced in Patchwork_113490v1, please notify your bug team to allow 
> them
> to document this new failure mode, which will reduce false positives 
> in CI.
>
> External URL: 
> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/index.html
>
>
>     Participating hosts (25 -> 25)
>
> Additional (1): fi-kbl-soraka
> Missing (1): fi-snb-2520m
>
>
>     Possible new issues
>
> Here are the unknown changes that may have been introduced in 
> Patchwork_113490v1:
>
>
>       IGT changes
>
>
>         Possible regressions
>
>   * igt@i915_selftest@live@execlists:
>       o fi-kbl-soraka: NOTRUN -> INCOMPLETE
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/fi-kbl-soraka/igt@i915_selftest@live@execlists.html>
>
>
>     Known issues
>
> Here are the changes found in Patchwork_113490v1 that come from known 
> issues:
>
>
>       IGT changes
>
>
>         Issues hit
>
>  *
>
>     igt@gem_huc_copy@huc-copy:
>
>       o fi-kbl-soraka: NOTRUN -> SKIP
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/fi-kbl-soraka/igt@gem_huc_copy@huc-copy.html>
>         (fdo#109271
>         <https://bugs.freedesktop.org/show_bug.cgi?id=109271> /
>         i915#2190 <https://gitlab.freedesktop.org/drm/intel/issues/2190>)
>  *
>
>     igt@gem_lmem_swapping@basic:
>
>       o fi-kbl-soraka: NOTRUN -> SKIP
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/fi-kbl-soraka/igt@gem_lmem_swapping@basic.html>
>         (fdo#109271
>         <https://bugs.freedesktop.org/show_bug.cgi?id=109271> /
>         i915#4613
>         <https://gitlab.freedesktop.org/drm/intel/issues/4613>) +3
>         similar issues
>  *
>
>     igt@i915_selftest@live@gt_pm:
>
>       o fi-kbl-soraka: NOTRUN -> DMESG-FAIL
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html>
>         (i915#1886 <https://gitlab.freedesktop.org/drm/intel/issues/1886>)
>  *
>
>     igt@kms_chamelium_frames@hdmi-crc-fast:
>
>       o fi-kbl-soraka: NOTRUN -> SKIP
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/fi-kbl-soraka/igt@kms_chamelium_frames@hdmi-crc-fast.html>
>         (fdo#109271
>         <https://bugs.freedesktop.org/show_bug.cgi?id=109271>) +15
>         similar issues
>
>
>         Possible fixes
>
>  *
>
>     igt@i915_selftest@live@gt_heartbeat:
>
>       o fi-apl-guc: DMESG-FAIL
>         <https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12666/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html>
>         (i915#5334
>         <https://gitlab.freedesktop.org/drm/intel/issues/5334>) ->
>         PASS
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html>
>  *
>
>     igt@i915_selftest@live@reset:
>
>       o {bat-rpls-1}: ABORT
>         <https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12666/bat-rpls-1/igt@i915_selftest@live@reset.html>
>         (i915#4983
>         <https://gitlab.freedesktop.org/drm/intel/issues/4983> /
>         i915#7981
>         <https://gitlab.freedesktop.org/drm/intel/issues/7981>) ->
>         PASS
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/bat-rpls-1/igt@i915_selftest@live@reset.html>
>  *
>
>     igt@i915_selftest@live@slpc:
>
>       o {bat-adlp-6}: DMESG-FAIL
>         <https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12666/bat-adlp-6/igt@i915_selftest@live@slpc.html>
>         (i915#6367
>         <https://gitlab.freedesktop.org/drm/intel/issues/6367> /
>         i915#7913
>         <https://gitlab.freedesktop.org/drm/intel/issues/7913>) ->
>         PASS
>         <https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113490v1/bat-adlp-6/igt@i915_selftest@live@slpc.html>
>
> {name}: This element is suppressed. This means it is ignored when 
> computing
> the status of the difference (SUCCESS, WARNING, or FAILURE).
>
>
>     Build changes
>
>   * Linux: CI_DRM_12666 -> Patchwork_113490v1
>
> CI-20190529: 20190529
> CI_DRM_12666: 908c84b836ee39b5565561a0b352c2dc18378215 @ 
> git://anongit.freedesktop.org/gfx-ci/linux
> IGT_7142: adeeb8527422eeee155ff4039aed34a922da4a7d @ 
> https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
> Patchwork_113490v1: 908c84b836ee39b5565561a0b352c2dc18378215 @ 
> git://anongit.freedesktop.org/gfx-ci/linux
>
>
>       Linux commits
>
> 093d7c03c708 drm/i915/gt: Use sysfs_emit() and sysfs_emit_at()
>
Nirmoy Das Jan. 31, 2023, 11:36 a.m. UTC | #4
On 1/30/2023 9:43 PM, Andi Shyti wrote:
> Hi Nirmoy,
>
> On Mon, Jan 30, 2023 at 02:13:58PM +0100, Nirmoy Das wrote:
>> Use sysfs_emit() and sysfs_emit_at() in show() callback
>> as recommended by Documentation/filesystems/sysfs.rst
>>
>> Cc: Andi Shyti <andi.shyti@linux.intel.com>
>> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
> I thought we didn't have anymore of those...


Yes,  I was surprise to see just only this file. Rest are okay.


>
> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>


Thanks,

Nirmoy

>
> Thanks,
> Andi
>
>> ---
>>   drivers/gpu/drm/i915/gt/sysfs_engines.c | 34 ++++++++++++-------------
>>   1 file changed, 16 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
>> index f2d9858d827c..323cead181b8 100644
>> --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
>> +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
>> @@ -24,7 +24,7 @@ static struct intel_engine_cs *kobj_to_engine(struct kobject *kobj)
>>   static ssize_t
>>   name_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>> -	return sprintf(buf, "%s\n", kobj_to_engine(kobj)->name);
>> +	return sysfs_emit(buf, "%s\n", kobj_to_engine(kobj)->name);
>>   }
>>   
>>   static struct kobj_attribute name_attr =
>> @@ -33,7 +33,7 @@ __ATTR(name, 0444, name_show, NULL);
>>   static ssize_t
>>   class_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
>> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
>>   }
>>   
>>   static struct kobj_attribute class_attr =
>> @@ -42,7 +42,7 @@ __ATTR(class, 0444, class_show, NULL);
>>   static ssize_t
>>   inst_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
>> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
>>   }
>>   
>>   static struct kobj_attribute inst_attr =
>> @@ -51,7 +51,7 @@ __ATTR(instance, 0444, inst_show, NULL);
>>   static ssize_t
>>   mmio_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>> -	return sprintf(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
>> +	return sysfs_emit(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
>>   }
>>   
>>   static struct kobj_attribute mmio_attr =
>> @@ -107,11 +107,9 @@ __caps_show(struct intel_engine_cs *engine,
>>   	for_each_set_bit(n, &caps, show_unknown ? BITS_PER_LONG : count) {
>>   		if (n >= count || !repr[n]) {
>>   			if (GEM_WARN_ON(show_unknown))
>> -				len += snprintf(buf + len, PAGE_SIZE - len,
>> -						"[%x] ", n);
>> +				len += sysfs_emit_at(buf, len, "[%x] ", n);
>>   		} else {
>> -			len += snprintf(buf + len, PAGE_SIZE - len,
>> -					"%s ", repr[n]);
>> +			len += sysfs_emit_at(buf, len, "%s ", repr[n]);
>>   		}
>>   		if (GEM_WARN_ON(len >= PAGE_SIZE))
>>   			break;
>> @@ -182,7 +180,7 @@ max_spin_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->props.max_busywait_duration_ns);
>> +	return sysfs_emit(buf, "%lu\n", engine->props.max_busywait_duration_ns);
>>   }
>>   
>>   static struct kobj_attribute max_spin_attr =
>> @@ -193,7 +191,7 @@ max_spin_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
>> +	return sysfs_emit(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
>>   }
>>   
>>   static struct kobj_attribute max_spin_def =
>> @@ -236,7 +234,7 @@ timeslice_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->props.timeslice_duration_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->props.timeslice_duration_ms);
>>   }
>>   
>>   static struct kobj_attribute timeslice_duration_attr =
>> @@ -247,7 +245,7 @@ timeslice_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
>>   }
>>   
>>   static struct kobj_attribute timeslice_duration_def =
>> @@ -287,7 +285,7 @@ stop_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->props.stop_timeout_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->props.stop_timeout_ms);
>>   }
>>   
>>   static struct kobj_attribute stop_timeout_attr =
>> @@ -298,7 +296,7 @@ stop_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->defaults.stop_timeout_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->defaults.stop_timeout_ms);
>>   }
>>   
>>   static struct kobj_attribute stop_timeout_def =
>> @@ -343,7 +341,7 @@ preempt_timeout_show(struct kobject *kobj, struct kobj_attribute *attr,
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->props.preempt_timeout_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->props.preempt_timeout_ms);
>>   }
>>   
>>   static struct kobj_attribute preempt_timeout_attr =
>> @@ -355,7 +353,7 @@ preempt_timeout_default(struct kobject *kobj, struct kobj_attribute *attr,
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
>>   }
>>   
>>   static struct kobj_attribute preempt_timeout_def =
>> @@ -399,7 +397,7 @@ heartbeat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->props.heartbeat_interval_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->props.heartbeat_interval_ms);
>>   }
>>   
>>   static struct kobj_attribute heartbeat_interval_attr =
>> @@ -410,7 +408,7 @@ heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>>   {
>>   	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>>   
>> -	return sprintf(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
>> +	return sysfs_emit(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
>>   }
>>   
>>   static struct kobj_attribute heartbeat_interval_def =
>> -- 
>> 2.39.0
Andi Shyti Feb. 2, 2023, 2:59 p.m. UTC | #5
Hi Nirmoy,

On Mon, Jan 30, 2023 at 02:13:58PM +0100, Nirmoy Das wrote:
> Use sysfs_emit() and sysfs_emit_at() in show() callback
> as recommended by Documentation/filesystems/sysfs.rst
> 
> Cc: Andi Shyti <andi.shyti@linux.intel.com>
> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>

Pushed in drm-intel-gt-next.

Thank you,
Andi

> ---
>  drivers/gpu/drm/i915/gt/sysfs_engines.c | 34 ++++++++++++-------------
>  1 file changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> index f2d9858d827c..323cead181b8 100644
> --- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
> +++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
> @@ -24,7 +24,7 @@ static struct intel_engine_cs *kobj_to_engine(struct kobject *kobj)
>  static ssize_t
>  name_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%s\n", kobj_to_engine(kobj)->name);
> +	return sysfs_emit(buf, "%s\n", kobj_to_engine(kobj)->name);
>  }
>  
>  static struct kobj_attribute name_attr =
> @@ -33,7 +33,7 @@ __ATTR(name, 0444, name_show, NULL);
>  static ssize_t
>  class_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
>  }
>  
>  static struct kobj_attribute class_attr =
> @@ -42,7 +42,7 @@ __ATTR(class, 0444, class_show, NULL);
>  static ssize_t
>  inst_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
> +	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
>  }
>  
>  static struct kobj_attribute inst_attr =
> @@ -51,7 +51,7 @@ __ATTR(instance, 0444, inst_show, NULL);
>  static ssize_t
>  mmio_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
> -	return sprintf(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
> +	return sysfs_emit(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
>  }
>  
>  static struct kobj_attribute mmio_attr =
> @@ -107,11 +107,9 @@ __caps_show(struct intel_engine_cs *engine,
>  	for_each_set_bit(n, &caps, show_unknown ? BITS_PER_LONG : count) {
>  		if (n >= count || !repr[n]) {
>  			if (GEM_WARN_ON(show_unknown))
> -				len += snprintf(buf + len, PAGE_SIZE - len,
> -						"[%x] ", n);
> +				len += sysfs_emit_at(buf, len, "[%x] ", n);
>  		} else {
> -			len += snprintf(buf + len, PAGE_SIZE - len,
> -					"%s ", repr[n]);
> +			len += sysfs_emit_at(buf, len, "%s ", repr[n]);
>  		}
>  		if (GEM_WARN_ON(len >= PAGE_SIZE))
>  			break;
> @@ -182,7 +180,7 @@ max_spin_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.max_busywait_duration_ns);
> +	return sysfs_emit(buf, "%lu\n", engine->props.max_busywait_duration_ns);
>  }
>  
>  static struct kobj_attribute max_spin_attr =
> @@ -193,7 +191,7 @@ max_spin_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
>  }
>  
>  static struct kobj_attribute max_spin_def =
> @@ -236,7 +234,7 @@ timeslice_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.timeslice_duration_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.timeslice_duration_ms);
>  }
>  
>  static struct kobj_attribute timeslice_duration_attr =
> @@ -247,7 +245,7 @@ timeslice_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
>  }
>  
>  static struct kobj_attribute timeslice_duration_def =
> @@ -287,7 +285,7 @@ stop_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.stop_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.stop_timeout_ms);
>  }
>  
>  static struct kobj_attribute stop_timeout_attr =
> @@ -298,7 +296,7 @@ stop_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.stop_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.stop_timeout_ms);
>  }
>  
>  static struct kobj_attribute stop_timeout_def =
> @@ -343,7 +341,7 @@ preempt_timeout_show(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.preempt_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.preempt_timeout_ms);
>  }
>  
>  static struct kobj_attribute preempt_timeout_attr =
> @@ -355,7 +353,7 @@ preempt_timeout_default(struct kobject *kobj, struct kobj_attribute *attr,
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
>  }
>  
>  static struct kobj_attribute preempt_timeout_def =
> @@ -399,7 +397,7 @@ heartbeat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->props.heartbeat_interval_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->props.heartbeat_interval_ms);
>  }
>  
>  static struct kobj_attribute heartbeat_interval_attr =
> @@ -410,7 +408,7 @@ heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct intel_engine_cs *engine = kobj_to_engine(kobj);
>  
> -	return sprintf(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
> +	return sysfs_emit(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
>  }
>  
>  static struct kobj_attribute heartbeat_interval_def =
> -- 
> 2.39.0
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
index f2d9858d827c..323cead181b8 100644
--- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
+++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
@@ -24,7 +24,7 @@  static struct intel_engine_cs *kobj_to_engine(struct kobject *kobj)
 static ssize_t
 name_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
-	return sprintf(buf, "%s\n", kobj_to_engine(kobj)->name);
+	return sysfs_emit(buf, "%s\n", kobj_to_engine(kobj)->name);
 }
 
 static struct kobj_attribute name_attr =
@@ -33,7 +33,7 @@  __ATTR(name, 0444, name_show, NULL);
 static ssize_t
 class_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
-	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
+	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_class);
 }
 
 static struct kobj_attribute class_attr =
@@ -42,7 +42,7 @@  __ATTR(class, 0444, class_show, NULL);
 static ssize_t
 inst_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
-	return sprintf(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
+	return sysfs_emit(buf, "%d\n", kobj_to_engine(kobj)->uabi_instance);
 }
 
 static struct kobj_attribute inst_attr =
@@ -51,7 +51,7 @@  __ATTR(instance, 0444, inst_show, NULL);
 static ssize_t
 mmio_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
-	return sprintf(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
+	return sysfs_emit(buf, "0x%x\n", kobj_to_engine(kobj)->mmio_base);
 }
 
 static struct kobj_attribute mmio_attr =
@@ -107,11 +107,9 @@  __caps_show(struct intel_engine_cs *engine,
 	for_each_set_bit(n, &caps, show_unknown ? BITS_PER_LONG : count) {
 		if (n >= count || !repr[n]) {
 			if (GEM_WARN_ON(show_unknown))
-				len += snprintf(buf + len, PAGE_SIZE - len,
-						"[%x] ", n);
+				len += sysfs_emit_at(buf, len, "[%x] ", n);
 		} else {
-			len += snprintf(buf + len, PAGE_SIZE - len,
-					"%s ", repr[n]);
+			len += sysfs_emit_at(buf, len, "%s ", repr[n]);
 		}
 		if (GEM_WARN_ON(len >= PAGE_SIZE))
 			break;
@@ -182,7 +180,7 @@  max_spin_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->props.max_busywait_duration_ns);
+	return sysfs_emit(buf, "%lu\n", engine->props.max_busywait_duration_ns);
 }
 
 static struct kobj_attribute max_spin_attr =
@@ -193,7 +191,7 @@  max_spin_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
+	return sysfs_emit(buf, "%lu\n", engine->defaults.max_busywait_duration_ns);
 }
 
 static struct kobj_attribute max_spin_def =
@@ -236,7 +234,7 @@  timeslice_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->props.timeslice_duration_ms);
+	return sysfs_emit(buf, "%lu\n", engine->props.timeslice_duration_ms);
 }
 
 static struct kobj_attribute timeslice_duration_attr =
@@ -247,7 +245,7 @@  timeslice_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
+	return sysfs_emit(buf, "%lu\n", engine->defaults.timeslice_duration_ms);
 }
 
 static struct kobj_attribute timeslice_duration_def =
@@ -287,7 +285,7 @@  stop_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->props.stop_timeout_ms);
+	return sysfs_emit(buf, "%lu\n", engine->props.stop_timeout_ms);
 }
 
 static struct kobj_attribute stop_timeout_attr =
@@ -298,7 +296,7 @@  stop_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->defaults.stop_timeout_ms);
+	return sysfs_emit(buf, "%lu\n", engine->defaults.stop_timeout_ms);
 }
 
 static struct kobj_attribute stop_timeout_def =
@@ -343,7 +341,7 @@  preempt_timeout_show(struct kobject *kobj, struct kobj_attribute *attr,
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->props.preempt_timeout_ms);
+	return sysfs_emit(buf, "%lu\n", engine->props.preempt_timeout_ms);
 }
 
 static struct kobj_attribute preempt_timeout_attr =
@@ -355,7 +353,7 @@  preempt_timeout_default(struct kobject *kobj, struct kobj_attribute *attr,
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
+	return sysfs_emit(buf, "%lu\n", engine->defaults.preempt_timeout_ms);
 }
 
 static struct kobj_attribute preempt_timeout_def =
@@ -399,7 +397,7 @@  heartbeat_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->props.heartbeat_interval_ms);
+	return sysfs_emit(buf, "%lu\n", engine->props.heartbeat_interval_ms);
 }
 
 static struct kobj_attribute heartbeat_interval_attr =
@@ -410,7 +408,7 @@  heartbeat_default(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
 {
 	struct intel_engine_cs *engine = kobj_to_engine(kobj);
 
-	return sprintf(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
+	return sysfs_emit(buf, "%lu\n", engine->defaults.heartbeat_interval_ms);
 }
 
 static struct kobj_attribute heartbeat_interval_def =