linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Charles Wang <charles.goodix@gmail.com>
Cc: hadess@hadess.net, hdegoede@redhat.com,
	neil.armstrong@linaro.org, hughsient@gmail.com,
	broonie@kernel.org, jeff@labundy.com,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers
Date: Thu, 30 May 2024 16:53:11 -0700	[thread overview]
Message-ID: <ZlkRZ7VKNVZSFi0X@google.com> (raw)
In-Reply-To: <20240514115135.21410-1-charles.goodix@gmail.com>

Hi Charles,

On Tue, May 14, 2024 at 07:44:43PM +0800, Charles Wang wrote:
> +static ssize_t registers_read(struct file *filp, struct kobject *kobj,
> +	struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
> +{
> +	struct regmap *regmap;
> +	int error;
> +
> +	regmap = dev_get_regmap(kobj_to_dev(kobj), NULL);

We already have goodix_berlin_core->regmap, going through drvdata should
be cheaper than scanning devres resources for the regmap data, so I'll
change this.

> +	error = regmap_raw_read(regmap, (unsigned int)off,
> +				buf, count);
> +
> +	return error ? error : count;
> +}
> +
> +static ssize_t registers_write(struct file *filp, struct kobject *kobj,
> +	struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
> +{
> +	struct regmap *regmap;
> +	int error;
> +
> +	regmap = dev_get_regmap(kobj_to_dev(kobj), NULL);
> +	error = regmap_raw_write(regmap, (unsigned int)off,
> +				 buf, count);
> +
> +	return error ? error : count;
> +}
> +
> +BIN_ATTR_RW(registers, 0);

I do not think it is a good idea to allow the world read all registers.
Any objection to make it BIN_ATTR_ADMIN_RW()?

Thanks.

-- 
Dmitry

  reply	other threads:[~2024-05-30 23:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 11:44 [PATCH v3] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers Charles Wang
2024-05-30 23:53 ` Dmitry Torokhov [this message]
2024-07-19 21:59   ` Dmitry Torokhov

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=ZlkRZ7VKNVZSFi0X@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=broonie@kernel.org \
    --cc=charles.goodix@gmail.com \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=hughsient@gmail.com \
    --cc=jeff@labundy.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil.armstrong@linaro.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 NNTP newsgroup(s).