diff options
author | Brian Cavagnolo <brian@cozybit.com> | 2008-07-21 14:03:16 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-08-22 16:29:49 -0400 |
commit | 1ff41eb0d9a937957d481d4f058a91230851ae17 (patch) | |
tree | 0e2fc14f0e61e009cdf787beb1dda8ef0a18bbda /drivers/net/wireless/libertas/if_usb.c | |
parent | 1556c0f22df77800d2e99342ce354a4ce94c5a0f (diff) |
libertas: add sysfs hooks to update boot2 and persistent firmware
To use these features, copy the boot2 and firmware images to /lib/firmware and:
echo <boot2_image_name> > /sys/class/net/ethX/lbs_flash_boot2
echo <firmware_image_name> > /sys/class/net/ethX/lbs_flash_fw
Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/if_usb.c')
-rw-r--r-- | drivers/net/wireless/libertas/if_usb.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index b5013ce31b9a..7b02d612b076 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -51,6 +51,62 @@ static void if_usb_free(struct if_usb_card *cardp); | |||
51 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp); | 51 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp); |
52 | static int if_usb_reset_device(struct if_usb_card *cardp); | 52 | static int if_usb_reset_device(struct if_usb_card *cardp); |
53 | 53 | ||
54 | /* sysfs hooks */ | ||
55 | |||
56 | /** | ||
57 | * Set function to write firmware to device's persistent memory | ||
58 | */ | ||
59 | static ssize_t if_usb_firmware_set(struct device *dev, | ||
60 | struct device_attribute *attr, const char *buf, size_t count) | ||
61 | { | ||
62 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
63 | struct if_usb_card *cardp = priv->card; | ||
64 | char fwname[FIRMWARE_NAME_MAX]; | ||
65 | int ret; | ||
66 | |||
67 | sscanf(buf, "%29s", fwname); /* FIRMWARE_NAME_MAX - 1 = 29 */ | ||
68 | ret = if_usb_prog_firmware(cardp, fwname, BOOT_CMD_UPDATE_FW); | ||
69 | if (ret == 0) | ||
70 | return count; | ||
71 | |||
72 | return ret; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * lbs_flash_fw attribute to be exported per ethX interface through sysfs | ||
77 | * (/sys/class/net/ethX/lbs_flash_fw). Use this like so to write firmware to | ||
78 | * the device's persistent memory: | ||
79 | * echo usb8388-5.126.0.p5.bin > /sys/class/net/ethX/lbs_flash_fw | ||
80 | */ | ||
81 | static DEVICE_ATTR(lbs_flash_fw, 0200, NULL, if_usb_firmware_set); | ||
82 | |||
83 | /** | ||
84 | * Set function to write firmware to device's persistent memory | ||
85 | */ | ||
86 | static ssize_t if_usb_boot2_set(struct device *dev, | ||
87 | struct device_attribute *attr, const char *buf, size_t count) | ||
88 | { | ||
89 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
90 | struct if_usb_card *cardp = priv->card; | ||
91 | char fwname[FIRMWARE_NAME_MAX]; | ||
92 | int ret; | ||
93 | |||
94 | sscanf(buf, "%29s", fwname); /* FIRMWARE_NAME_MAX - 1 = 29 */ | ||
95 | ret = if_usb_prog_firmware(cardp, fwname, BOOT_CMD_UPDATE_BOOT2); | ||
96 | if (ret == 0) | ||
97 | return count; | ||
98 | |||
99 | return ret; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * lbs_flash_boot2 attribute to be exported per ethX interface through sysfs | ||
104 | * (/sys/class/net/ethX/lbs_flash_boot2). Use this like so to write firmware | ||
105 | * to the device's persistent memory: | ||
106 | * echo usb8388-5.126.0.p5.bin > /sys/class/net/ethX/lbs_flash_boot2 | ||
107 | */ | ||
108 | static DEVICE_ATTR(lbs_flash_boot2, 0200, NULL, if_usb_boot2_set); | ||
109 | |||
54 | /** | 110 | /** |
55 | * @brief call back function to handle the status of the URB | 111 | * @brief call back function to handle the status of the URB |
56 | * @param urb pointer to urb structure | 112 | * @param urb pointer to urb structure |
@@ -263,6 +319,12 @@ static int if_usb_probe(struct usb_interface *intf, | |||
263 | usb_get_dev(udev); | 319 | usb_get_dev(udev); |
264 | usb_set_intfdata(intf, cardp); | 320 | usb_set_intfdata(intf, cardp); |
265 | 321 | ||
322 | if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_fw)) | ||
323 | lbs_pr_err("cannot register lbs_flash_fw attribute\n"); | ||
324 | |||
325 | if (device_create_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2)) | ||
326 | lbs_pr_err("cannot register lbs_flash_boot2 attribute\n"); | ||
327 | |||
266 | return 0; | 328 | return 0; |
267 | 329 | ||
268 | err_start_card: | 330 | err_start_card: |
@@ -288,6 +350,9 @@ static void if_usb_disconnect(struct usb_interface *intf) | |||
288 | 350 | ||
289 | lbs_deb_enter(LBS_DEB_MAIN); | 351 | lbs_deb_enter(LBS_DEB_MAIN); |
290 | 352 | ||
353 | device_remove_file(&priv->dev->dev, &dev_attr_lbs_flash_boot2); | ||
354 | device_remove_file(&priv->dev->dev, &dev_attr_lbs_flash_fw); | ||
355 | |||
291 | cardp->surprise_removed = 1; | 356 | cardp->surprise_removed = 1; |
292 | 357 | ||
293 | if (priv) { | 358 | if (priv) { |