All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: ye.xingchen@zte.com.cn
Cc: markgross@kernel.org, pobrn@protonmail.com,
	dell.client.kernel@dell.com, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: dell: use sysfs_emit() to instead of scnprintf()
Date: Thu, 8 Dec 2022 17:07:54 +0100	[thread overview]
Message-ID: <034a882b-e6fc-b20a-25fb-8aaa02f1b1bc@redhat.com> (raw)
In-Reply-To: <202212021721543696124@zte.com.cn>

Hi,

On 12/2/22 10:21, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
>  drivers/platform/x86/dell/alienware-wmi.c | 41 +++++++++--------------
>  1 file changed, 16 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index a34e07ef2c79..a9477e5432e4 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -398,10 +398,10 @@ static ssize_t show_control_state(struct device *dev,
>  				  struct device_attribute *attr, char *buf)
>  {
>  	if (lighting_control_state == LEGACY_BOOTING)
> -		return scnprintf(buf, PAGE_SIZE, "[booting] running suspend\n");
> +		return sysfs_emit(buf, "[booting] running suspend\n");
>  	else if (lighting_control_state == LEGACY_SUSPEND)
> -		return scnprintf(buf, PAGE_SIZE, "booting running [suspend]\n");
> -	return scnprintf(buf, PAGE_SIZE, "booting [running] suspend\n");
> +		return sysfs_emit(buf, "booting running [suspend]\n");
> +	return sysfs_emit(buf, "booting [running] suspend\n");
>  }
> 
>  static ssize_t store_control_state(struct device *dev,
> @@ -547,14 +547,12 @@ static ssize_t show_hdmi_cable(struct device *dev,
>  				   (u32 *) &out_data);
>  	if (ACPI_SUCCESS(status)) {
>  		if (out_data == 0)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "[unconnected] connected unknown\n");
> +			return sysfs_emit(buf, "[unconnected] connected unknown\n");
>  		else if (out_data == 1)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "unconnected [connected] unknown\n");
> +			return sysfs_emit(buf, "unconnected [connected] unknown\n");
>  	}
>  	pr_err("alienware-wmi: unknown HDMI cable status: %d\n", status);
> -	return scnprintf(buf, PAGE_SIZE, "unconnected connected [unknown]\n");
> +	return sysfs_emit(buf, "unconnected connected [unknown]\n");
>  }
> 
>  static ssize_t show_hdmi_source(struct device *dev,
> @@ -571,14 +569,12 @@ static ssize_t show_hdmi_source(struct device *dev,
> 
>  	if (ACPI_SUCCESS(status)) {
>  		if (out_data == 1)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "[input] gpu unknown\n");
> +			return sysfs_emit(buf, "[input] gpu unknown\n");
>  		else if (out_data == 2)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "input [gpu] unknown\n");
> +			return sysfs_emit(buf, "input [gpu] unknown\n");
>  	}
>  	pr_err("alienware-wmi: unknown HDMI source status: %u\n", status);
> -	return scnprintf(buf, PAGE_SIZE, "input gpu [unknown]\n");
> +	return sysfs_emit(buf, "input gpu [unknown]\n");
>  }
> 
>  static ssize_t toggle_hdmi_source(struct device *dev,
> @@ -652,14 +648,12 @@ static ssize_t show_amplifier_status(struct device *dev,
>  				   (u32 *) &out_data);
>  	if (ACPI_SUCCESS(status)) {
>  		if (out_data == 0)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "[unconnected] connected unknown\n");
> +			return sysfs_emit(buf, "[unconnected] connected unknown\n");
>  		else if (out_data == 1)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "unconnected [connected] unknown\n");
> +			return sysfs_emit(buf, "unconnected [connected] unknown\n");
>  	}
>  	pr_err("alienware-wmi: unknown amplifier cable status: %d\n", status);
> -	return scnprintf(buf, PAGE_SIZE, "unconnected connected [unknown]\n");
> +	return sysfs_emit(buf, "unconnected connected [unknown]\n");
>  }
> 
>  static DEVICE_ATTR(status, S_IRUGO, show_amplifier_status, NULL);
> @@ -706,17 +700,14 @@ static ssize_t show_deepsleep_status(struct device *dev,
>  					(u32 *) &out_data);
>  	if (ACPI_SUCCESS(status)) {
>  		if (out_data == 0)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "[disabled] s5 s5_s4\n");
> +			return sysfs_emit(buf, "[disabled] s5 s5_s4\n");
>  		else if (out_data == 1)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "disabled [s5] s5_s4\n");
> +			return sysfs_emit(buf, "disabled [s5] s5_s4\n");
>  		else if (out_data == 2)
> -			return scnprintf(buf, PAGE_SIZE,
> -					 "disabled s5 [s5_s4]\n");
> +			return sysfs_emit(buf, "disabled s5 [s5_s4]\n");
>  	}
>  	pr_err("alienware-wmi: unknown deep sleep status: %d\n", status);
> -	return scnprintf(buf, PAGE_SIZE, "disabled s5 s5_s4 [unknown]\n");
> +	return sysfs_emit(buf, "disabled s5 s5_s4 [unknown]\n");
>  }
> 
>  static ssize_t toggle_deepsleep(struct device *dev,


      reply	other threads:[~2022-12-08 16:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  9:21 [PATCH] platform/x86: dell: use sysfs_emit() to instead of scnprintf() ye.xingchen
2022-12-08 16:07 ` Hans de Goede [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=034a882b-e6fc-b20a-25fb-8aaa02f1b1bc@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=dell.client.kernel@dell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=pobrn@protonmail.com \
    --cc=ye.xingchen@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.