mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <thomas@t-8ch.de>
To: Armin Wolf <W_Armin@gmx.de>
Cc: hdegoede@redhat.com, markgross@kernel.org,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof()
Date: Sun, 30 Jul 2023 09:10:57 +0200	[thread overview]
Message-ID: <0754301f-d0a2-4ef6-8c4b-972fd4c9a759@t-8ch.de> (raw)
In-Reply-To: <20230730043817.12888-2-W_Armin@gmx.de>

On 2023-07-30 06:38:16+0200, Armin Wolf wrote:
> Replace offset handling code with a single call
> to memory_read_from_buffer() to simplify read_bmof().
> 
> Tested on a ASUS PRIME B650-PLUS.
> 
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>

Reviewed-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Thomas Weißschuh <linux@weissschuh.net>

> ---
>  drivers/platform/x86/wmi-bmof.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/platform/x86/wmi-bmof.c b/drivers/platform/x86/wmi-bmof.c
> index d0516cacfcb5..644d2fd889c0 100644
> --- a/drivers/platform/x86/wmi-bmof.c
> +++ b/drivers/platform/x86/wmi-bmof.c
> @@ -25,25 +25,13 @@ struct bmof_priv {
>  	struct bin_attribute bmof_bin_attr;
>  };
> 
> -static ssize_t
> -read_bmof(struct file *filp, struct kobject *kobj,
> -	 struct bin_attribute *attr,
> -	 char *buf, loff_t off, size_t count)
> +static ssize_t read_bmof(struct file *filp, struct kobject *kobj, struct bin_attribute *attr,
> +			 char *buf, loff_t off, size_t count)
>  {
> -	struct bmof_priv *priv =
> -		container_of(attr, struct bmof_priv, bmof_bin_attr);
> +	struct bmof_priv *priv = container_of(attr, struct bmof_priv, bmof_bin_attr);
> 
> -	if (off < 0)
> -		return -EINVAL;
> -
> -	if (off >= priv->bmofdata->buffer.length)
> -		return 0;
> -
> -	if (count > priv->bmofdata->buffer.length - off)
> -		count = priv->bmofdata->buffer.length - off;
> -
> -	memcpy(buf, priv->bmofdata->buffer.pointer + off, count);
> -	return count;
> +	return memory_read_from_buffer(buf, count, &off, priv->bmofdata->buffer.pointer,
> +				       priv->bmofdata->buffer.length);
>  }
> 
>  static int wmi_bmof_probe(struct wmi_device *wdev, const void *context)
> --
> 2.39.2
> 

  reply	other threads:[~2023-07-30  7:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-30  4:38 [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Armin Wolf
2023-07-30  4:38 ` [PATCH 2/3] platform/x86: wmi-bmof: Simplify read_bmof() Armin Wolf
2023-07-30  7:10   ` Thomas Weißschuh [this message]
2023-07-30  7:35   ` Thomas Weißschuh
2023-07-30  4:38 ` [PATCH 3/3] platform/x86: wmi-bmof: Update MAINTAINERS entry Armin Wolf
2023-07-30  7:11   ` Thomas Weißschuh
2023-07-30 20:30     ` Armin Wolf
2023-07-30  7:10 ` [PATCH 1/3] platform/x86: wmi-bmof: Use device_create_bin_file() Thomas Weißschuh

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=0754301f-d0a2-4ef6-8c4b-972fd4c9a759@t-8ch.de \
    --to=thomas@t-8ch.de \
    --cc=W_Armin@gmx.de \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@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

all inboxes | Powered by JetHome®