Linux SOC development
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy@kernel.org>
To: "Marek Behún" <kabel@kernel.org>
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>,
	Arnd Bergmann <arnd@arndb.de>,
	soc@kernel.org, arm@kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH v3 4/7] platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup
Date: Mon, 23 Oct 2023 22:40:45 +0300	[thread overview]
Message-ID: <ZTbMPcP7HmBvY4YP@smile.fi.intel.com> (raw)
In-Reply-To: <20231023143130.11602-5-kabel@kernel.org>

On Mon, Oct 23, 2023 at 04:31:27PM +0200, Marek Behún wrote:
> Add support for true board poweroff (MCU can disable all unnecessary
> voltage regulators) and wakeup at a specified time, implemented via a
> RTC driver so that the rtcwake utility can be used to configure it.

...

> +static int omnia_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> +{
> +	struct i2c_client *client = to_i2c_client(dev);
> +	struct omnia_mcu *mcu = i2c_get_clientdata(client);
> +
> +	mcu->rtc_alarm = rtc_tm_to_time64(&alrm->time);
> +
> +	if (alrm->enabled)
> +		return omnia_cmd_write_u32(client, CMD_SET_WAKEUP,
> +					   mcu->rtc_alarm);

> +	else

Redundant 'else'.

> +		return 0;
> +}

...

> +static int omnia_power_off(struct sys_off_data *data)
> +
> +	struct omnia_mcu *mcu = data->cb_data;
> +	__be32 tmp;
> +	u8 cmd[9];
> +	u16 arg;
> +	int err;
> +
> +	if (mcu->front_button_poweron)
> +		arg = CMD_POWER_OFF_POWERON_BUTTON;
> +	else
> +		arg = 0;
> +
> +	cmd[0] = CMD_POWER_OFF;
> +	put_unaligned_le16(CMD_POWER_OFF_MAGIC, &cmd[1]);
> +	put_unaligned_le16(arg, &cmd[3]);

> +	tmp = cpu_to_be32(get_unaligned_le32(&cmd[1]));
> +	put_unaligned_le32(crc32_be(0xffffffff, (void *)&tmp, sizeof(tmp)),
> +			   &cmd[5]);

Hmm... Why crc32_le*() can't be used?

> +	err = omnia_cmd_write(mcu->client, cmd, sizeof(cmd));
> +	if (err)
> +		dev_err(&mcu->client->dev,
> +			"Unable to send the poweroff command: %d\n", err);
> +
> +	return NOTIFY_DONE;
> +}

...

> +	if (kstrtobool(buf, &val) < 0)
> +		return -EINVAL;

Why is the error code shadowed?

...

> +	struct device *dev = container_of(kobj, typeof(*dev), kobj);

kobj_to_dev()?

...

> +	/*
> +	 * poweroff and wakeup are available only if POWEROFF_WAKEUP feature is
> +	 * present

Missing period at the end.

> +	 */

...

> +	err = devm_rtc_register_device(mcu->rtcdev);
> +	if (err)
> +		return dev_err_probe(dev, err, "Cannot register RTC device\n");
> +
> +	mcu->front_button_poweron = true;

> +	return err;

Can it be anything than 0?

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-10-23 19:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 14:31 [PATCH v3 0/7] Turris Omnia MCU driver Marek Behún
2023-10-23 14:31 ` [PATCH v3 1/7] dt-bindings: arm: add cznic,turris-omnia-mcu binding Marek Behún
2023-10-23 14:31 ` [PATCH v3 2/7] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2023-10-23 14:31 ` [PATCH v3 3/7] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2023-10-23 20:04   ` Andy Shevchenko
2023-10-26 16:14     ` Marek Behún
2023-10-23 14:31 ` [PATCH v3 4/7] platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup Marek Behún
2023-10-23 19:40   ` Andy Shevchenko [this message]
2023-10-26 16:16     ` Marek Behún
2023-10-23 14:31 ` [PATCH v3 5/7] platform: cznic: turris-omnia-mcu: Add support for MCU watchdog Marek Behún
2023-10-23 14:47   ` Guenter Roeck
2023-10-23 14:59     ` Marek Behún
2023-10-23 15:03       ` Mark Brown
2023-10-23 15:09         ` Marek Behún
2023-10-23 14:31 ` [PATCH v3 6/7] ARM: dts: turris-omnia: Add MCU system-controller node Marek Behún
2023-10-23 14:31 ` [PATCH v3 7/7] ARM: dts: turris-omnia: Add GPIO key node for front button Marek Behún

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=ZTbMPcP7HmBvY4YP@smile.fi.intel.com \
    --to=andy@kernel.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=arm@kernel.org \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=gregory.clement@bootlin.com \
    --cc=kabel@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=soc@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