From: Lee Jones <lee@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Pavel Machek" <pavel@kernel.org>,
"Sebastian Reichel" <sre@kernel.org>,
"Ion Agorria" <ion@agorria.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org, linux-leds@vger.kernel.org,
linux-pm@vger.kernel.org
Subject: Re: [PATCH v6 2/7] mfd: Add driver for ASUS Transformer embedded controller
Date: Mon, 18 May 2026 11:13:28 +0100 [thread overview]
Message-ID: <20260518101328.GS305027@google.com> (raw)
In-Reply-To: <CAPVz0n1drWV6zMzOx93gHNaw+Tt0M9oAF2RyKW6tZcC2gF_HAQ@mail.gmail.com>
On Thu, 14 May 2026, Svyatoslav Ryhel wrote:
> чт, 14 трав. 2026 р. о 18:50 Lee Jones <lee@kernel.org> пише:
> >
> > On Thu, 14 May 2026, Svyatoslav Ryhel wrote:
> >
> > > чт, 14 трав. 2026 р. о 13:02 Lee Jones <lee@kernel.org> пише:
> > > >
> > > > On Sat, 02 May 2026, Svyatoslav Ryhel wrote:
> > > >
> > > > > From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > > >
> > > > > Support Nuvoton NPCE795-based ECs as used in Asus Transformer TF201,
> > > > > TF300T, TF300TG, TF300TL and TF700T pad and dock, as well as TF101 dock
> > > > > and TF600T, P1801-T and TF701T pad. This is a glue driver handling
> > > > > detection and common operations for EC's functions.
> > > > >
> > > > > Co-developed-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > > > ---
> > > > > drivers/mfd/Kconfig | 14 +
> > > > > drivers/mfd/Makefile | 1 +
> > > > > drivers/mfd/asus-transformer-ec.c | 762 ++++++++++++++++++++++++
> > > > > include/linux/mfd/asus-transformer-ec.h | 162 +++++
> > > > > 4 files changed, 939 insertions(+)
> > > > > create mode 100644 drivers/mfd/asus-transformer-ec.c
> > > > > create mode 100644 include/linux/mfd/asus-transformer-ec.h
> >
> > [...]
> >
> > > > > + unsigned int num_devices;
> > > > > + bool clr_fmode; /* clear Factory Mode bit in EC control register */
> > > > > +};
> > > > > +
> > > > > +struct asus_ec_data {
> > > > > + struct asusec_info info;
> > > >
> > > > You have 'data' and 'info' which a) using non-forthcoming nomenclature
> > > > and doesn't tell me anything and then you b) put 'info' in the device's
> > > > driver_data attribute which is very confusing. driver_data should be
> > > > for what we call ddata which I assume is expressed as 'data' here.
> > > >
> > >
> > > asusec_info is shared among all child devices and is exposed while
> > > remaining elements of this struct are for internal use only.
> >
> > Our terminology for that is usually ddata, that gets stored in
> > 'struct devices' device_data attribute.
> >
> > > > > + struct mutex ecreq_lock; /* prevent simultaneous access */
> > > > > + struct gpio_desc *ecreq;
> > > >
> > > > If I hadn't seen the declaration, I'd have no idea this was a GPIO
> > > > descriptor. Please improve the nomenclature throughout.
> > > >
> > > > > + struct i2c_client *self;
> > > >
> > > > Again, please use standard naming conventions:
> > > >
> > > > % git grep "struct i2c_client" | grep "\*self" | wc -l
> > > > 0
> > > >
> > > > % git grep "struct i2c_client" | grep "\*client" | wc -l
> > > > 6304
> > > >
> > > > % git grep "struct i2c_client" | grep "\*i2c" | wc -l
> > > > 903
> > > >
> > >
> > > ok, noted.
> > >
> > > > > + const struct asus_ec_chip_data *data;
> > > >
> > > > 'data', 'priv' and 'info' should be improved.
> > > >
> > > > > + char ec_data[DOCKRAM_ENTRY_BUFSIZE];
> > > >
> > > > An array of chars called 'data'. This could be anything.
> > > >
> > >
> > > Do you have a comprehensive list of name conventions you find suitable?
> >
> > Anything descriptive that alludes to the type of data being held there.
> >
> > There are 100's of good examples, but a handful of generic / bad ones.
> >
> > > > > + bool logging_disabled;
> > > >
> > > > This debugging tool is probably never going to be used again.
> > > >
> > > > Keep it local.
> > > >
> > > > > +};
> > > > > +
> > > > > +struct dockram_ec_data {
> > > > > + struct mutex ctl_lock; /* prevent simultaneous access */
> > > > > + char ctl_data[DOCKRAM_ENTRY_BUFSIZE];
> > > > > +};
> > > > > +
> > > > > +#define to_ec_data(ec) \
> > > > > + container_of(ec, struct asus_ec_data, info)
> > > > > +
> > > > > +/**
> > > > > + * asus_dockram_read - Read a register from the DockRAM device.
> > > > > + * @client: Handle to the DockRAM device.
> > > > > + * @reg: Register to read.
> > > > > + * @buf: Byte array into which data will be read; must be large enough to
> > > > > + * hold the data returned by the DockRAM.
> > > > > + *
> > > > > + * This executes the DockRAM read based on the SMBus "block read" protocol
> > > > > + * or its emulation. It extracts DOCKRAM_ENTRY_SIZE bytes from the set
> > > > > + * register address.
> > > > > + *
> > > > > + * Returns a negative errno code else zero on success.
> > > > > + */
> > > > > +int asus_dockram_read(struct i2c_client *client, int reg, char *buf)
> > > > > +{
> > > >
> > > > Have you considered using Regmap for register access instead of
> > > > implementing custom functions? Remaps already deals with caching and
> > > > locking mechanisms that you'd get for free.
> > > >
> > > > This looks like it would be replaced with devm_regmap_init_i2c().
> > > >
> > >
> > > I will consider this, thank you.
> > >
>
> It seems that regmap does not fit for this purpose, but I might switch
> to plain i2c_smbus_read_i2c_block_data
Can you explain why Regmap doesn't work for you?
Regmap is just a wrapper about i2c_smbus_read_i2c_block_data() and friends.
> > > > > + struct device *dev = &client->dev;
> > > > > + int ret;
> > > > > +
> > > > > + memset(buf, 0, DOCKRAM_ENTRY_BUFSIZE);
> > > > > + ret = i2c_smbus_read_i2c_block_data(client, reg,
> > > > > + DOCKRAM_ENTRY_BUFSIZE, buf);
> > > > > + if (ret < 0)
> > > > > + return ret;
> > > > > +
> > > > > + if (buf[0] > DOCKRAM_ENTRY_SIZE) {
> > > > > + dev_err(dev, "bad data len; buffer: %*ph; ret: %d\n",
> > > > > + DOCKRAM_ENTRY_BUFSIZE, buf, ret);
> > > > > + return -EPROTO;
> > > > > + }
> > > > > +
> > > > > + dev_dbg(dev, "got data; buffer: %*ph; ret: %d\n",
> > > > > + DOCKRAM_ENTRY_BUFSIZE, buf, ret);
> > > >
> > > > Please remove all of these debug messages.
> > > >
> > >
> > > Why debug messages cannot be preserved? They are specifically marked as dev_dbg
> >
> > It's a general convention.
> >
> > After initial development, they tend to just litter the code-base.
> >
> > Debug prints can be useful higher up the stack though.
> >
>
> I am fine with removing all debugs and logging but I strongly would
> like to keep EC model and firmware version along with susb and factory
> status. That may be quite useful in identifying EC used and its
> behavior without need in rebuilding the kernel and digging huge piles
> of downstream code in order to find how to dump these values.
Yes, you can keep this sort of thing as INFO.
--
Lee Jones
next prev parent reply other threads:[~2026-05-18 10:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 12:40 [PATCH v6 0/7] mfd: Add support for Asus Transformer embedded controller Svyatoslav Ryhel
2026-05-02 12:40 ` [PATCH v6 1/7] dt-bindings: embedded-controller: document ASUS Transformer EC Svyatoslav Ryhel
2026-05-02 12:40 ` [PATCH v6 2/7] mfd: Add driver for ASUS Transformer embedded controller Svyatoslav Ryhel
2026-05-14 10:02 ` Lee Jones
2026-05-14 10:31 ` Svyatoslav Ryhel
2026-05-14 15:50 ` Lee Jones
2026-05-14 16:06 ` Svyatoslav Ryhel
2026-05-18 10:13 ` Lee Jones [this message]
2026-05-18 10:27 ` Svyatoslav Ryhel
2026-05-14 11:02 ` Svyatoslav Ryhel
2026-05-02 12:40 ` [PATCH v6 3/7] input: serio: Add driver for ASUS Transformer dock keyboard and touchpad Svyatoslav Ryhel
2026-05-02 12:40 ` [PATCH v6 4/7] input: keyboard: Add driver for ASUS Transformer dock multimedia keys Svyatoslav Ryhel
2026-05-02 12:40 ` [PATCH v6 5/7] leds: Add driver for ASUS Transformer LEDs Svyatoslav Ryhel
2026-05-14 10:09 ` Lee Jones
2026-05-02 12:40 ` [PATCH v6 6/7] power: supply: Add driver for ASUS Transformer battery Svyatoslav Ryhel
2026-05-02 12:40 ` [PATCH v6 7/7] power: supply: Add charger driver for Asus Transformers Svyatoslav Ryhel
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=20260518101328.GS305027@google.com \
--to=lee@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=ion@agorria.com \
--cc=krzk+dt@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=pavel@kernel.org \
--cc=robh@kernel.org \
--cc=sre@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