From: "Bjørn Mork" <bjorn@mork.no>
To: <Charles.Hyde@dellteam.com>
Cc: <linux-usb@vger.kernel.org>, <Mario.Limonciello@dell.com>,
<oliver@neukum.org>, <nic_swsd@realtek.com>,
<linux-acpi@vger.kernel.org>
Subject: Re: [RFC 3/3] net: cdc_ncm: Add ACPI MAC address pass through functionality
Date: Sun, 25 Aug 2019 17:11:40 +0200 [thread overview]
Message-ID: <87h865xosz.fsf@miraculix.mork.no> (raw)
In-Reply-To: <6db7de30d5584018adf169638e956626@AUSX13MPS303.AMER.DELL.COM> (Charles Hyde's message of "Fri, 23 Aug 2019 22:29:29 +0000")
<Charles.Hyde@dellteam.com> writes:
> +static int cdc_ncm_resume (struct usb_interface *intf)
> +{
> + struct usbnet *dev = usb_get_intfdata(intf);
> + struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
> + int ret;
> +
> + ret = usbnet_resume(intf);
> + if (ret != 0)
> + goto error2;
> +
> + if (ctx->ether_desc) {
> + struct sockaddr sa;
> +
> + if (cdc_ncm_get_ethernet_address(dev, ctx)) {
> + dev_dbg(&intf->dev, "failed to get mac address\n");
> + goto error2;
> + }
> + if (get_acpi_mac_passthru(&intf->dev, &sa) == 0) {
> + if (memcmp(dev->net->dev_addr, sa.sa_data, ETH_ALEN) != 0) {
> + if (cdc_ncm_set_ethernet_address(dev, &sa) == 0) {
> + memcpy(dev->net->dev_addr, sa.sa_data, ETH_ALEN);
> + }
> + }
> + }
> + dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
> + }
> +
> +error2:
> + return ret;
> +}
This is wrong. dev->net->dev_addr will hold the correct address, and it
does not have to match any USB descriptor or ACPI table entry. It's a
user managed address.
You should simply make sure the device is syncronized with the
dev->net->dev_addr field. But you probably want to avoid doing that if
it failed initially. There is no need to issue control requests you
know will fail.
Why the dev_info()? It logs info the user can retrieve with a simple
"ip link" or similar. Seems pretty useless even as a debug statement?
Bjørn
prev parent reply other threads:[~2019-08-25 15:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-23 22:29 [RFC 3/3] net: cdc_ncm: Add ACPI MAC address pass through functionality Charles.Hyde
2019-08-25 15:11 ` Bjørn Mork [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=87h865xosz.fsf@miraculix.mork.no \
--to=bjorn@mork.no \
--cc=Charles.Hyde@dellteam.com \
--cc=Mario.Limonciello@dell.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=oliver@neukum.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;
as well as URLs for NNTP newsgroup(s).