From: Sam Ravnborg <sam@ravnborg.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: barebox@lists.infradead.org, Oleksij Rempel <linux@rempel-privat.de>
Subject: Re: [PATCH v1 1/3] MIPS: ath79: provide driver for Atheros ART partition
Date: Tue, 5 Jun 2018 21:03:45 +0200 [thread overview]
Message-ID: <20180605190345.GA32198@ravnborg.org> (raw)
In-Reply-To: <20180605181021.10467-1-o.rempel@pengutronix.de>
Hi Oleksij
Some nitpicks.
On Tue, Jun 05, 2018 at 08:10:19PM +0200, Oleksij Rempel wrote:
> From: Oleksij Rempel <linux@rempel-privat.de>
>
> this partition contains calibration data for WiFi and
> some board specific data, like MAC address.
>
> For now we care only about MAC.
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> +static int art_read_mac(struct device_d *dev, const char *file)
> +{
> + int fd, rbytes;
> + struct ar9300_eeprom eeprom;
> +
> + fd = open_and_lseek(file, O_RDONLY, 0x1000);
> + if (fd < 0) {
> + dev_err(dev, "Failed to open eeprom path %s %d\n",
> + file, -errno);
> + return -errno;
> + }
open_and_lseek says:
otherwise a negative error code is returned
So it is wrong to convert this to a positive errocode
> +
> + rbytes = read_full(fd, &eeprom, sizeof(eeprom));
> + close(fd);
> + if (rbytes <= 0 || rbytes < sizeof(eeprom)) {
> + dev_err(dev, "Failed to read %s\n", file);
> + return -EIO;
> + }
Because here you convert a positive number to a negative number.
> +
> + dev_dbg(dev, "ART version: %x.%x\n",
> + eeprom.eeprom_version, eeprom.template_version);
> + dev_dbg(dev, "mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
> + eeprom.mac_addr[0],
> + eeprom.mac_addr[1],
> + eeprom.mac_addr[2],
> + eeprom.mac_addr[3],
> + eeprom.mac_addr[4],
> + eeprom.mac_addr[5]);
We should add support for %pM...
But this is not done, so the above is fine
> +
> + if (!is_valid_ether_addr(&eeprom.mac_addr[0])) {
> + dev_err(dev, "bad MAC addr\n");
> + return -EILSEQ;
> + }
> +
> + return art_set_mac(dev, &eeprom);
> +}
Sam
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-06-05 19:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 18:10 Oleksij Rempel
2018-06-05 18:10 ` [PATCH v1 2/3] MIPS: dts: tl_wdr4300: add " Oleksij Rempel
2018-06-05 18:10 ` [PATCH v1 3/3] MIPS: dts: dpt-module: " Oleksij Rempel
2018-06-06 7:35 ` Sascha Hauer
2018-06-05 19:03 ` Sam Ravnborg [this message]
2018-06-06 9:14 ` [PATCH v1 1/3] MIPS: ath79: provide driver for " Lucas Stach
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=20180605190345.GA32198@ravnborg.org \
--to=sam@ravnborg.org \
--cc=barebox@lists.infradead.org \
--cc=linux@rempel-privat.de \
--cc=o.rempel@pengutronix.de \
/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