Example #1
0
/**
 * hdm_update_netinfo - retrieve latest networking information
 * @mdev: device interface
 *
 * This triggers the USB vendor requests to read the hardware address and
 * the current link status of the attached device.
 */
static int hdm_update_netinfo(struct most_dev *mdev)
{
	struct usb_device *usb_device = mdev->usb_device;
	struct device *dev = &usb_device->dev;
	u16 hi, mi, lo, link;

	if (!is_valid_ether_addr(mdev->hw_addr)) {
		if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) {
			dev_err(dev, "Vendor request \"hw_addr_hi\" failed\n");
			return -EFAULT;
		}

		if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) {
			dev_err(dev, "Vendor request \"hw_addr_mid\" failed\n");
			return -EFAULT;
		}

		if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) {
			dev_err(dev, "Vendor request \"hw_addr_low\" failed\n");
			return -EFAULT;
		}

		mutex_lock(&mdev->io_mutex);
		mdev->hw_addr[0] = hi >> 8;
		mdev->hw_addr[1] = hi;
		mdev->hw_addr[2] = mi >> 8;
		mdev->hw_addr[3] = mi;
		mdev->hw_addr[4] = lo >> 8;
		mdev->hw_addr[5] = lo;
		mutex_unlock(&mdev->io_mutex);
	}

	if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) {
		dev_err(dev, "Vendor request \"link status\" failed\n");
		return -EFAULT;
	}

	mutex_lock(&mdev->io_mutex);
	mdev->link_stat = link;
	mutex_unlock(&mdev->io_mutex);
	return 0;
}
Example #2
0
File: usb.c Project: avagin/linux
/**
 * wq_netinfo - work queue function to deliver latest networking information
 * @wq_obj: object that holds data for our deferred work to do
 *
 * This retrieves the network interface status of the USB INIC
 */
static void wq_netinfo(struct work_struct *wq_obj)
{
	struct most_dev *mdev = to_mdev_from_work(wq_obj);
	struct usb_device *usb_device = mdev->usb_device;
	struct device *dev = &usb_device->dev;
	u16 hi, mi, lo, link;
	u8 hw_addr[6];

	if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi) < 0) {
		dev_err(dev, "Vendor request 'hw_addr_hi' failed\n");
		return;
	}

	if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi) < 0) {
		dev_err(dev, "Vendor request 'hw_addr_mid' failed\n");
		return;
	}

	if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo) < 0) {
		dev_err(dev, "Vendor request 'hw_addr_low' failed\n");
		return;
	}

	if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link) < 0) {
		dev_err(dev, "Vendor request 'link status' failed\n");
		return;
	}

	hw_addr[0] = hi >> 8;
	hw_addr[1] = hi;
	hw_addr[2] = mi >> 8;
	hw_addr[3] = mi;
	hw_addr[4] = lo >> 8;
	hw_addr[5] = lo;

	if (mdev->on_netinfo)
		mdev->on_netinfo(&mdev->iface, link, hw_addr);
}
Example #3
0
static ssize_t show_value(struct most_dci_obj *dci_obj,
			  struct most_dci_attribute *attr, char *buf)
{
	const char *name = attr->attr.name;
	u16 val;
	u16 reg_addr;
	int err;

	if (!strcmp(name, "arb_address"))
		return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr);

	if (!strcmp(name, "arb_value"))
		reg_addr = dci_obj->reg_addr;
	else if (get_static_reg_addr(ro_regs, name, &reg_addr) &&
		 get_static_reg_addr(rw_regs, name, &reg_addr))
		return -EFAULT;

	err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val);
	if (err < 0)
		return err;

	return snprintf(buf, PAGE_SIZE, "%04x\n", val);
}