From: "Rafał Miłecki" <zajec5@gmail.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>
Cc: "Tom Rini" <trini@konsulko.com>,
linux-arm-kernel@lists.infradead.org, u-boot@lists.denx.de,
devicetree@vger.kernel.org, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org, "Rafał Miłecki" <rafal@milecki.pl>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>
Subject: Re: [PATCH V3 2/2] nvmem: add driver handling U-Boot environment variables
Date: Wed, 15 Jun 2022 20:30:12 +0200 [thread overview]
Message-ID: <c67b209c-4237-4c9f-3150-23a3ef99bc34@gmail.com> (raw)
In-Reply-To: <1ecbb1af-53d6-1ac1-fd9f-b780a7c50fd9@pengutronix.de>
On 14.06.2022 08:45, Ahmad Fatoum wrote:
>> + if (err && !mtd_is_bitflip(err)) {
>> + dev_err(dev, "Failed to read from mtd: %d\n", err);
>
> Nitpick: %pe
My "err" variable in int, not a pointer (I don't use PTR_ERR()).
>> +static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf,
>> + size_t data_offset, size_t data_len)
>> +{
>> + struct device *dev = priv->dev;
>> + char *data = buf + data_offset;
>> + char *var, *value, *eq;
>> + int idx;
>> +
>> + priv->ncells = 0;
>> + for (var = data; var < data + data_len && *var; var += strlen(var) + 1)
>> + priv->ncells++;
>> +
>> + priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL);
>> + if (!priv->cells)
>> + return -ENOMEM;
>> +
>> + for (var = data, idx = 0;
>> + var < data + data_len && *var;
>> + var = value + strlen(value) + 1, idx++) {
>> + eq = strchr(var, '=');
>> + if (!eq)
>> + break;
>> + *eq = '\0';
>> + value = eq + 1;
>> +
>> + priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL);
>> + if (!priv->cells[idx].name)
>> + return -ENOMEM;
>> + priv->cells[idx].offset = data_offset + value - data;
>> + priv->cells[idx].bytes = strlen(value);
>
> U-Boot environment can't hold binary values?
I believe it can't. In any case \0 is a always a separator.
>> + }
>> +
>> + if (WARN_ON(idx != priv->ncells))
>> + priv->ncells = idx;
>> +
>> + return 0;
>> +}
next prev parent reply other threads:[~2022-06-15 18:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-11 20:46 [PATCH V3 1/2] mtd: allow getting MTD device associated with a specific DT node Rafał Miłecki
2022-06-11 20:46 ` [PATCH V3 2/2] nvmem: add driver handling U-Boot environment variables Rafał Miłecki
2022-06-14 6:45 ` Ahmad Fatoum
2022-06-15 18:30 ` Rafał Miłecki [this message]
2022-06-14 7:46 ` Sascha Hauer
2022-06-14 9:02 ` Miquel Raynal
2022-06-13 14:04 ` [PATCH V3 1/2] mtd: allow getting MTD device associated with a specific DT node Miquel Raynal
2022-06-13 14:15 ` Rafał Miłecki
2022-06-13 14:33 ` Miquel Raynal
2022-06-14 6:49 ` Ahmad Fatoum
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=c67b209c-4237-4c9f-3150-23a3ef99bc34@gmail.com \
--to=zajec5@gmail.com \
--cc=a.fatoum@pengutronix.de \
--cc=devicetree@vger.kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=rafal@milecki.pl \
--cc=richard@nod.at \
--cc=srinivas.kandagatla@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.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).