Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111163
b: refs/heads/master
c: 1ff41eb
h: refs/heads/master
i:
  111161: b72be2d
  111159: 1115932
v: v3
  • Loading branch information
Brian Cavagnolo authored and John W. Linville committed Aug 22, 2008
1 parent 4ebf3f9 commit 3fdd2cb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1556c0f22df77800d2e99342ce354a4ce94c5a0f
refs/heads/master: 1ff41eb0d9a937957d481d4f058a91230851ae17
65 changes: 65 additions & 0 deletions trunk/drivers/net/wireless/libertas/if_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,62 @@ static void if_usb_free(struct if_usb_card *cardp);
static int if_usb_submit_rx_urb(struct if_usb_card *cardp);
static int if_usb_reset_device(struct if_usb_card *cardp);

/* sysfs hooks */

/**
* Set function to write firmware to device's persistent memory
*/
static ssize_t if_usb_firmware_set(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct lbs_private *priv = to_net_dev(dev)->priv;
struct if_usb_card *cardp = priv->card;
char fwname[FIRMWARE_NAME_MAX];
int ret;

sscanf(buf, "%29s", fwname); /* FIRMWARE_NAME_MAX - 1 = 29 */
ret = if_usb_prog_firmware(cardp, fwname, BOOT_CMD_UPDATE_FW);
if (ret == 0)
return count;

return ret;
}

/**
* lbs_flash_fw attribute to be exported per ethX interface through sysfs
* (/sys/class/net/ethX/lbs_flash_fw). Use this like so to write firmware to
* the device's persistent memory:
* echo usb8388-5.126.0.p5.bin > /sys/class/net/ethX/lbs_flash_fw
*/
static DEVICE_ATTR(lbs_flash_fw, 0200, NULL, if_usb_firmware_set);

/**
* Set function to write firmware to device's persistent memory
*/
static ssize_t if_usb_boot2_set(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct lbs_private *priv = to_net_dev(dev)->priv;
struct if_usb_card *cardp = priv->card;
char fwname[FIRMWARE_NAME_MAX];
int ret;

sscanf(buf, "%29s", fwname); /* FIRMWARE_NAME_MAX - 1 = 29 */
ret = if_usb_prog_firmware(cardp, fwname, BOOT_CMD_UPDATE_BOOT2);
if (ret == 0)
return count;

return ret;
}

/**
* lbs_flash_boot2 attribute to be exported per ethX interface through sysfs
* (/sys/class/net/ethX/lbs_flash_boot2). Use this like so to write firmware
* to the device's persistent memory:
* echo usb8388-5.126.0.p5.bin > /sys/class/net/ethX/lbs_flash_boot2
*/
static DEVICE_ATTR(lbs_flash_boot2, 0200, NULL, if_usb_boot2_set);

/**
* @brief call back function to handle the status of the URB
* @param urb pointer to urb structure
Expand Down Expand Up @@ -263,6 +319,12 @@ static int if_usb_probe(struct usb_interface *intf,
usb_get_dev(udev);
usb_set_intfdata(intf, cardp);

if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_fw))
lbs_pr_err("cannot register lbs_flash_fw attribute\n");

if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2))
lbs_pr_err("cannot register lbs_flash_boot2 attribute\n");

return 0;

err_start_card:
Expand All @@ -288,6 +350,9 @@ static void if_usb_disconnect(struct usb_interface *intf)

lbs_deb_enter(LBS_DEB_MAIN);

device_remove_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2);
device_remove_file(&priv->dev->dev, &dev_attr_lbs_flash_fw);

cardp->surprise_removed = 1;

if (priv) {
Expand Down

0 comments on commit 3fdd2cb

Please sign in to comment.