All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Charles Hyde <chip.programmer@gmail.com>
Cc: Oliver Neukum <oliver@neukum.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	Mario Limonciello <mario.limonciello@dell.com>,
	Charles Hyde <charles.hyde@dellteam.com>,
	Realtek linux nic maintainers <nic_swsd@realtek.com>,
	linux-usb@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH v3 3/3] net: cdc_ncm: Add ACPI MAC address pass through functionality
Date: Fri, 6 Sep 2019 11:22:00 +0200	[thread overview]
Message-ID: <20190906092200.GA31500@kroah.com> (raw)
In-Reply-To: <20190906015115.12796-4-chip.programmer@gmail.com>

On Thu, Sep 05, 2019 at 08:51:15PM -0500, Charles Hyde wrote:
> This change adds support to cdc_ncm for ACPI MAC address pass through
> functionality that also exists in the Realtek r8152 driver.  This is in
> support of Dell's Universal Dock D6000, to give it the same feature
> capability as is currently available in Windows and advertized on Dell's
> product web site.
> 
> Today's v3 patch series includes a function named get_ethernet_addr()
> which replaces two instances where the same code snippet was located in
> teh previous patch series.  I also created a post reset function to set
> the MAC address, if there exists an ACPI MAC address pass through (MAPT)
> method.  Oliver Neukum had requested a post reset function for this
> purpose.
> 
> Signed-off-by: Charles Hyde <charles.hyde@dellteam.com>
> Cc: Mario Limonciello <mario.limonciello@dell.com>
> Cc: chip.programmer@gmail.com
> Cc: Oliver Neukum <oliver@neukum.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-usb@vger.kernel.org
> Cc: linux-acpi@vger.kernel.org
> ---
>  drivers/net/usb/cdc_ncm.c | 74 +++++++++++++++++++++++++++++++++------
>  1 file changed, 64 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index 85093579612f..e0152d44f5af 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -52,6 +52,7 @@
>  #include <linux/usb/usbnet.h>
>  #include <linux/usb/cdc.h>
>  #include <linux/usb/cdc_ncm.h>
> +#include <acpi/acpi_mac_passthru.h>
>  
>  #if IS_ENABLED(CONFIG_USB_NET_CDC_MBIM)
>  static bool prefer_mbim = true;
> @@ -833,6 +834,45 @@ static const struct net_device_ops cdc_ncm_netdev_ops = {
>  	.ndo_validate_addr   = eth_validate_addr,
>  };
>  
> +static int get_ethernet_addr(struct usb_interface *intf)
> +{
> +	struct sockaddr sa;
> +	struct usbnet *dev = usb_get_intfdata(intf);
> +	struct cdc_ncm_ctx *ctx;
> +	int ret = 0;
> +
> +	if (!dev)
> +		return 0;
> +
> +	ctx = (struct cdc_ncm_ctx *)dev->data[0];
> +	if (!ctx->ether_desc)
> +		return 0;
> +
> +	ret = cdc_ncm_get_ethernet_address(dev, ctx);
> +	if (ret) {
> +		dev_dbg(&intf->dev, "failed to get mac address\n");
> +		return ret;
> +	}
> +
> +	/* Check for a Dell Universal Dock D6000 before checking if ACPI
> +	 * supports MAC address pass through.
> +	 */
> +	if (strstr(dev->udev->product, "D6000")) {

As other people have pointed out, that's funny.

No, this is explicitly what the USB vendor/product ids are for, don't
try to make up something that will be guaranteed to not work
correctly...

> +		sa.sa_family = dev->net->type;
> +		if (get_acpi_mac_passthru(sa.sa_data)) {
> +			if (!memcmp(dev->net->dev_addr, sa.sa_data,
> +				    ETH_ALEN)) {
> +				if (!cdc_ncm_set_ethernet_address(dev, &sa))
> +					memcpy(dev->net->dev_addr, sa.sa_data,
> +					       ETH_ALEN);
> +			}
> +		}
> +	}
> +	dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);

If a driver is working properly, it should not spit out any kernel log
messages.  Make this dev_dbg() if you need it for your own debugging
logic.

thanks,

greg k-h

  reply	other threads:[~2019-09-06  9:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06  1:51 [PATCH v3 0/3] Add get/set ethernet address functions and ACPI MAC address pass through functionality to cdc_ncm driver Charles Hyde
2019-09-06  1:51 ` [PATCH v3 1/3] net: cdc_ncm: add get/set ethernet address functions Charles Hyde
2019-09-06  1:51 ` [PATCH v3 2/3] ACPI: move ACPI functionality out of r8152 driver Charles Hyde
2019-09-06  1:51 ` [PATCH v3 3/3] net: cdc_ncm: Add ACPI MAC address pass through functionality Charles Hyde
2019-09-06  9:22   ` Greg KH [this message]
     [not found] <20190906014827.12666-1-chip.programmer@gmail.com>
2019-09-06  1:48 ` Charles Hyde

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=20190906092200.GA31500@kroah.com \
    --to=greg@kroah.com \
    --cc=charles.hyde@dellteam.com \
    --cc=chip.programmer@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mario.limonciello@dell.com \
    --cc=nic_swsd@realtek.com \
    --cc=oliver@neukum.org \
    --cc=rjw@rjwysocki.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.