devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Dan Murphy <dmurphy@ti.com>, Sebastian Reichel <sre@kernel.org>,
	devicetree@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/4] mfd: Add driver for Embedded Controller found on Acer Iconia Tab A500
Date: Mon, 16 Nov 2020 02:12:28 +0300	[thread overview]
Message-ID: <3ad644fd-cd03-a1e1-36d9-014304fdfcee@gmail.com> (raw)
In-Reply-To: <20201113093747.GJ2787115@dell>

13.11.2020 12:37, Lee Jones пишет:
...
>> +config MFD_ACER_A500_EC
>> +	tristate "Embedded Controller driver for Acer Iconia Tab A500"
> 
> Drop "driver".  This is meant to be describing the device.
> 
>> +	depends on I2C
> 
> depends on OF ?
...
>> +	depends on ARCH_TEGRA_2x_SOC || COMPILE_TEST
>> +	select MFD_CORE
>> +	select REGMAP
>> +	help

ARCH_TEGRA_2x_SOC selects OF.

For COMPILE_TEST it doesn't matter since OF framework provides stubs for
!OF.

...
>> +static int a500_ec_read(void *context, const void *reg_buf, size_t reg_size,
>> +			void *val_buf, size_t val_sizel)
>> +{
>> +	struct i2c_client *client = context;
>> +	unsigned int reg, retries = 5;
>> +	u16 *ret_val = val_buf;
>> +	s32 ret = 0;
>> +
>> +	if (reg_size != 1 || val_sizel != 2)
> 
> No magic numbers please.
> 
> What does this *mean*?

These are the size of address register and size of a read value, both in
bytes.

>> +		return -EOPNOTSUPP;
> 
> Why EOPNOTSUPP?

Other sizes aren't supported by embedded controller.

Although, perhaps this check isn't really needed at all since the sizes
are already expressed in the a500_ec_regmap_config.

I'll need to take a closer look at why this size-checking was added
because don't quite remember already. If it's not needed, then I'll
remove it in the next revision, otherwise will add a clarifying comment.

>> +	reg = *(u8 *)reg_buf;
>> +
>> +	while (retries-- > 0) {
>> +		ret = i2c_smbus_read_word_data(client, reg);
>> +		if (ret >= 0)
>> +			break;
>> +
>> +		msleep(A500_EC_I2C_ERR_TIMEOUT);
>> +	}
>> +
>> +	if (ret < 0) {
>> +		dev_err(&client->dev, "read 0x%x failed: %d\n", reg, ret);
>> +		return ret;
>> +	}
>> +
>> +	*ret_val = ret;
>> +
>> +	if (reg == REG_CURRENT_NOW)
>> +		fsleep(10000);
> 
> Ooo, new toy!
> 
>> +	return 0;
>> +}
> 
> I'm surprised there isn't a generic function which does this kind of
> read.  Seems like pretty common/boilerplate stuff.

I'm not quite sure that this is a really very common pattern which
deserves a generic helper.

...
>> +static int a500_ec_restart_notify(struct notifier_block *this,
>> +				  unsigned long reboot_mode, void *data)
>> +{
>> +	if (reboot_mode == REBOOT_WARM)
>> +		i2c_smbus_write_word_data(a500_ec_client_pm_off,
>> +					  REG_WARM_REBOOT, 0);
>> +	else
>> +		i2c_smbus_write_word_data(a500_ec_client_pm_off,
>> +					  REG_COLD_REBOOT, 1);
> 
> What's with the magic '0' and '1's at the end?

These are the values which controller's firmware wants to see, otherwise
it will reject command as invalid. I'll add a clarifying comment to the
code.

Thank you for the review. I'll address all the comments in the v7.

  reply	other threads:[~2020-11-15 23:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 20:33 [PATCH v5 0/4] Introduce Embedded Controller driver for Acer A500 Dmitry Osipenko
2020-11-04 20:34 ` [PATCH v5 1/4] dt-bindings: mfd: Add ENE KB930 Embedded Controller binding Dmitry Osipenko
2020-11-06 16:11   ` Rob Herring
2020-11-04 20:34 ` [PATCH v5 2/4] mfd: Add driver for Embedded Controller found on Acer Iconia Tab A500 Dmitry Osipenko
2020-11-13  9:37   ` Lee Jones
2020-11-15 23:12     ` Dmitry Osipenko [this message]
2020-11-16  8:48       ` Lee Jones
2020-11-16  9:53         ` Dmitry Osipenko
2020-11-16 10:29           ` Lee Jones
2020-11-04 20:34 ` [PATCH v5 3/4] power: supply: Add battery gauge driver for " Dmitry Osipenko
2020-11-04 20:34 ` [PATCH v5 4/4] ARM: tegra: acer-a500: Add Embedded Controller Dmitry Osipenko

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=3ad644fd-cd03-a1e1-36d9-014304fdfcee@gmail.com \
    --to=digetx@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmurphy@ti.com \
    --cc=jonathanh@nvidia.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    --cc=thierry.reding@gmail.com \
    /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).