From: Guenter Roeck <linux@roeck-us.net>
To: Enric Balletbo i Serra <enric.balletbo@collabora.com>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Wim Van Sebroeck <wim@iguana.be>,
Martyn Welch <martyn.welch@collabora.com>
Subject: Re: [PATCH v4] watchdog: ziirave_wdt: Add support to upload the firmware.
Date: Sun, 7 Aug 2016 14:37:00 -0700 [thread overview]
Message-ID: <05209a6b-f709-cf79-2e17-c0dea08f99e6@roeck-us.net> (raw)
In-Reply-To: <1470051586-5634-1-git-send-email-enric.balletbo@collabora.com>
On 08/01/2016 04:39 AM, Enric Balletbo i Serra wrote:
> This patch adds and entry to the sysfs to start firmware upload process
> on the specified device with the requested firmware.
>
> The uploading of the firmware needs only to happen once per firmware
> upgrade, as the firmware is stored in persistent storage. If the
> firmware upload or the firmware verification fails then we print and
> error message and exit.
>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> ---
[ ... ]
>
> +static ssize_t ziirave_wdt_sysfs_store_firm(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct i2c_client *client = to_i2c_client(dev->parent);
> + struct ziirave_wdt_data *w_priv = i2c_get_clientdata(client);
> + const struct firmware *fw;
> + int err;
> +
> + err = request_ihex_firmware(&fw, ZIIRAVE_FW_NAME, dev);
> + if (err) {
> + dev_err(&client->dev, "Failed to request ihex firmware\n");
> + return err;
> + }
> +
> + err = mutex_lock_interruptible(&w_priv->sysfs_mutex);
> + if (err)
> + return err;
> +
This doesn't release the firmware.
> + err = ziirave_firm_upload(&w_priv->wdd, fw);
> + if (err) {
> + dev_err(&client->dev, "The firmware update failed: %d\n", err);
> + goto release_firmware;
> + }
> +
> + /* Update firmware version */
> + err = ziirave_wdt_revision(client, &w_priv->firmware_rev,
> + ZIIRAVE_WDT_FIRM_VER_MAJOR);
> + if (err) {
> + dev_err(&client->dev, "Failed to read firmware version: %d\n",
> + err);
> + goto release_firmware;
> + }
> +
> + dev_info(&client->dev, "Firmware updated to version 02.%02u.%02u\n",
> + w_priv->firmware_rev.major, w_priv->firmware_rev.minor);
> +
> + /* Restore the watchdog timeout */
> + err = ziirave_wdt_set_timeout(&w_priv->wdd, w_priv->wdd.timeout);
> + if (err)
> + dev_err(&client->dev, "Failed to set timeout: %d\n", err);
> +
> +release_firmware:
> + release_firmware(fw);
> + mutex_unlock(&w_priv->sysfs_mutex);
Probably best to reverse the order of calls here, and add a second label
to release the firmware without releasing the lock (for use with the above).
Guenter
prev parent reply other threads:[~2016-08-07 21:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-01 11:39 [PATCH v4] watchdog: ziirave_wdt: Add support to upload the firmware Enric Balletbo i Serra
2016-08-07 21:37 ` Guenter Roeck [this message]
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=05209a6b-f709-cf79-2e17-c0dea08f99e6@roeck-us.net \
--to=linux@roeck-us.net \
--cc=enric.balletbo@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=martyn.welch@collabora.com \
--cc=wim@iguana.be \
/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).