<snipped>
> static int cdc_ncm_init(struct usbnet *dev) {
> struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
> u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
> int err;
>
> err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_PARAMETERS,
> USB_TYPE_CLASS | USB_DIR_IN
> |USB_RECIP_INTERFACE,
> 0, iface_no, &ctx->ncm_parm,
> sizeof(ctx->ncm_parm));
> ,,
>
> You'll obviously have to replace USB_CDC_GET_NTB_PARAMETERS with
> USB_CDC_GET_NET_ADDRESS, &ctx->ncm_parm with buf, and
> sizeof(ctx->ncm_parm) with ETH_ALEN.
>
>
> Bjørn
Not everything is obvious to those who do not live and breathe USB. This has
been an experience.
Is this snippet what you have in mind? Will iface_no be correct? If not, then
what do you suggest?
/* Provide method to push MAC address to the USB device's ethernet controller.
* If the device does not support CDC_SET_ADDRESS, there is no harm and we
* proceed as before.
*/
static int cdc_ncm_set_ethernet_address(struct usbnet *dev,
struct sockaddr *addr)
{
int ret;
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
u8 iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
ret = usbnet_write_cmd(dev, USB_CDC_SET_NET_ADDRESS,
USB_DIR_OUT | USB_TYPE_CLASS
| USB_RECIP_INTERFACE, 0, iface_no,
addr->sa_data, ETH_ALEN);
if (ret == ETH_ALEN)
ret = 0; /* success */
else if (ret < 0)
dev_dbg(&dev->udev->dev, "bad MAC address put, %d\n", ret);
return ret;
}