Re: [PATCH v3] Input: goodix-berlin - Add sysfs interface for reading and writing touch IC registers

From: Dmitry Torokhov
Date: Fri Jul 19 2024 - 17:59:18 EST


On Thu, May 30, 2024 at 04:53:11PM -0700, Dmitry Torokhov wrote:
> 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()?

OK, since I have not heard anything I made the changes and applied the
patch.

Thanks.

--
Dmitry