Re: [PATCH] please review mcs7830 (DeLOCK USB etherner) driver

From: David Hollis
Date: Mon Aug 07 2006 - 10:53:35 EST


On Mon, 2006-08-07 at 15:00 +0200, Arnd Bergmann wrote:
> +
> +/* index for PHY registers */
> +enum {
> + PHY_CONTROL_REG_INDEX = 0,
> + PHY_STATUS_REG_INDEX = 1,
> + PHY_IDENTIFICATION1_REG_INDEX = 2,
> + PHY_IDENTIFICATION2_REG_INDEX = 3,
> + PHY_AUTONEGADVT_REG_INDEX = 4,
> + PHY_AUTONEGLINK_REG_INDEX = 5,
> + PHY_AUTONEGEXP_REG_INDEX = 6,

These values are dupes of the MII_xxxx constants from linux/mii.h. It
would be clearer and more consistent to use those instead

> + PHY_MIRROR_REG_INDEX = 16,
> + PHY_INTERRUPTENABLE_REG_INDEX = 17,
> + PHY_INTERRUPTSTATUS_REG_INDEX = 18,
> + PHY_CONFIG_REG_INDEX = 19,
> + PHY_CHIPSTATUS_REG_INDEX = 20,
> +};

These values are device specific so you would want to define them here.
Following the MII_xxxxx naming convention may be helpful.

> +
> +static DEFINE_MUTEX(mcs7830_phy_mutex);
> +

Does this need to be global? Isn't it really just to prevent
simultaneous access to the adapters PHY? What if you have multiple
adapters installed?

> +
> +static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
> +{
> + struct net_device *net = dev->net;
> + int ret;
> +
> + ret = mcs7830_init_dev(dev);
> + if (ret)
> + goto out;
> +
> + net->do_ioctl = mcs7830_ioctl;
> + net->set_multicast_list = mcs7830_set_multicast;
> + mcs7830_set_multicast(net);
> +
> + dev->mii.mdio_read = mcs7830_mdio_read;
> + dev->mii.mdio_write = mcs7830_mdio_write;
> + dev->mii.dev = net;
> + dev->mii.phy_id_mask = 0x3f;
> + dev->mii.reg_num_mask = 0x1f;
> + dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
> +
> + dev->in = usb_rcvbulkpipe(dev->udev, 1);
> + dev->out = usb_sndbulkpipe(dev->udev, 2);

Couldn't you use usbnet_getendpoints() here. It will also pick up the
status pipe.

> +out:
> + return ret;
> +}
> +
> +static int mcs7830_check_connect(struct usbnet *dev)
> +{
> + int ret;
> + ret = mcs7830_mdio_read(dev->net, dev->mii.phy_id, 1);

use MII_BMSR here instead of the magic value '1'.
> + return !ret;
> +}
> +

--
David Hollis <dhollis@xxxxxxxxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part