Platform-driver-x86 archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: yunshui <jiangyunshui@kylinos.cn>,
	linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org
Cc: Ai Chao <aichao@kylinos.cn>
Subject: Re: [PATCH -v2] platform/x86: msi-laptop: Use sysfs_emit() to replace sprintf()
Date: Mon, 22 Apr 2024 15:41:45 +0200	[thread overview]
Message-ID: <1e4e5799-38b7-42ca-b196-3eac82601ff4@redhat.com> (raw)
In-Reply-To: <20240419063649.2396461-1-jiangyunshui@kylinos.cn>

Hi,

On 4/19/24 8:36 AM, yunshui wrote:
> As Documentation/filesystems/sysfs.rst suggested,
> show() should only use sysfs_emit() or sysfs_emit_at() when formatting
> the value to be returned to user space.
> 
> Signed-off-by: yunshui <jiangyunshui@kylinos.cn>
> Reviewed-by: Ai Chao <aichao@kylinos.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/msi-laptop.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
> index f4c6c36e05a5..e5391a37014d 100644
> --- a/drivers/platform/x86/msi-laptop.c
> +++ b/drivers/platform/x86/msi-laptop.c
> @@ -317,7 +317,7 @@ static ssize_t show_wlan(struct device *dev,
>  	if (ret < 0)
>  		return ret;
>  
> -	return sprintf(buf, "%i\n", enabled);
> +	return sysfs_emit(buf, "%i\n", enabled);
>  }
>  
>  static ssize_t store_wlan(struct device *dev,
> @@ -341,7 +341,7 @@ static ssize_t show_bluetooth(struct device *dev,
>  	if (ret < 0)
>  		return ret;
>  
> -	return sprintf(buf, "%i\n", enabled);
> +	return sysfs_emit(buf, "%i\n", enabled);
>  }
>  
>  static ssize_t store_bluetooth(struct device *dev,
> @@ -364,7 +364,7 @@ static ssize_t show_threeg(struct device *dev,
>  	if (ret < 0)
>  		return ret;
>  
> -	return sprintf(buf, "%i\n", threeg_s);
> +	return sysfs_emit(buf, "%i\n", threeg_s);
>  }
>  
>  static ssize_t store_threeg(struct device *dev,
> @@ -383,7 +383,7 @@ static ssize_t show_lcd_level(struct device *dev,
>  	if (ret < 0)
>  		return ret;
>  
> -	return sprintf(buf, "%i\n", ret);
> +	return sysfs_emit(buf, "%i\n", ret);
>  }
>  
>  static ssize_t store_lcd_level(struct device *dev,
> @@ -413,7 +413,7 @@ static ssize_t show_auto_brightness(struct device *dev,
>  	if (ret < 0)
>  		return ret;
>  
> -	return sprintf(buf, "%i\n", ret);
> +	return sysfs_emit(buf, "%i\n", ret);
>  }
>  
>  static ssize_t store_auto_brightness(struct device *dev,
> @@ -443,7 +443,7 @@ static ssize_t show_touchpad(struct device *dev,
>  	if (result < 0)
>  		return result;
>  
> -	return sprintf(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_TOUCHPAD_MASK));
> +	return sysfs_emit(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_TOUCHPAD_MASK));
>  }
>  
>  static ssize_t show_turbo(struct device *dev,
> @@ -457,7 +457,7 @@ static ssize_t show_turbo(struct device *dev,
>  	if (result < 0)
>  		return result;
>  
> -	return sprintf(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_TURBO_MASK));
> +	return sysfs_emit(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_TURBO_MASK));
>  }
>  
>  static ssize_t show_eco(struct device *dev,
> @@ -471,7 +471,7 @@ static ssize_t show_eco(struct device *dev,
>  	if (result < 0)
>  		return result;
>  
> -	return sprintf(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_ECO_MASK));
> +	return sysfs_emit(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_ECO_MASK));
>  }
>  
>  static ssize_t show_turbo_cooldown(struct device *dev,
> @@ -485,7 +485,7 @@ static ssize_t show_turbo_cooldown(struct device *dev,
>  	if (result < 0)
>  		return result;
>  
> -	return sprintf(buf, "%i\n", (!!(rdata & MSI_STANDARD_EC_TURBO_MASK)) |
> +	return sysfs_emit(buf, "%i\n", (!!(rdata & MSI_STANDARD_EC_TURBO_MASK)) |
>  		(!!(rdata & MSI_STANDARD_EC_TURBO_COOLDOWN_MASK) << 1));
>  }
>  
> @@ -500,7 +500,7 @@ static ssize_t show_auto_fan(struct device *dev,
>  	if (result < 0)
>  		return result;
>  
> -	return sprintf(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_AUTOFAN_MASK));
> +	return sysfs_emit(buf, "%i\n", !!(rdata & MSI_STANDARD_EC_AUTOFAN_MASK));
>  }
>  
>  static ssize_t store_auto_fan(struct device *dev,


      reply	other threads:[~2024-04-22 13:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  6:36 [PATCH -v2] platform/x86: msi-laptop: Use sysfs_emit() to replace sprintf() yunshui
2024-04-22 13:41 ` 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=1e4e5799-38b7-42ca-b196-3eac82601ff4@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=aichao@kylinos.cn \
    --cc=jiangyunshui@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).