Beispiel #1
0
/*
 * mcs7830_read_phy() - read a PHY register of the network adapter
 * @udev:	network device to read from
 * @index:	index of the PHY register to read from
 * Return: non-negative 16bit register content, negative upon error
 */
static int mcs7830_read_phy(struct usb_device *udev, uint8_t index)
{
	int rc;
	uint16_t val;

	/* issue the PHY read request and wait for its execution */
	rc = mcs7830_phy_emit_wait(udev, PHY_CMD1_READ, index);
	if (rc < 0)
		return rc;

	/* fetch the PHY data which was read */
	rc = mcs7830_read_reg(udev, REG_PHY_DATA, sizeof(val), &val);
	if (rc < 0)
		return rc;
	rc = le16_to_cpu(val);
	debug("%s(%d) => 0x%04X\n", __func__, index, rc);
	return rc;
}
Beispiel #2
0
/*
 * mcs7830_write_phy() - write a PHY register of the network adapter
 * @dev:	network device to write to
 * @index:	index of the PHY register to write to
 * @val:	value to write to the PHY register
 * Return: zero upon success, negative upon error
 */
static int mcs7830_write_phy(struct ueth_data *dev, uint8_t index, uint16_t val)
{
	int rc;

	debug("%s(%s, %d, 0x%04X)\n", __func__, dev->eth_dev.name, index, val);

	/* setup the PHY data which is to get written */
	val = cpu_to_le16(val);
	rc = mcs7830_write_reg(dev, REG_PHY_DATA, sizeof(val), &val);
	if (rc < 0)
		return rc;

	/* issue the PHY write request and wait for its execution */
	rc = mcs7830_phy_emit_wait(dev, PHY_CMD1_WRITE, index);
	if (rc < 0)
		return rc;

	return 0;
}