[PATCH] libertas: add sysfs hooks to update boot2 and persistent firmware
Ricardo Carrano
carrano at laptop.org
Tue Jun 3 10:34:26 EDT 2008
On Tue, Jun 3, 2008 at 11:12 AM, Dan Williams <dcbw at redhat.com> wrote:
> On Mon, 2008-06-02 at 17:12 -0700, Brian Cavagnolo wrote:
>> To update boot2, copy the boot2 and firmware images to /lib/firmware and:
>>
>> echo <boot2_image_name> > /sys/class/net/eth2/lbs_boot2
>> echo <firmware_image_name> > /sys/class/net/eth2/lbs_fw
>
> So why are we doing this with the driver, and not the userspace update
> tool? Marvell keeps wanting to do firmware update in the driver, and we
> (David and I at least) keep saying no. If there are issues that prevent
> the userspace firmware update tool from working, then we need to fix
> those issues. Firmware updates from the driver were a disaster the
> first time around, and I don't quite see how that may have changed this
> time?
A necessary rectification:
Firmware updates from the driver are the only method that works
currently. If we want to name one method a "disaster", we would have
to choose the userspace tool, since it will brick many of your active
antennae.
>
> If you really want, the userspace tool can be rewritten in C.
>
> Dan
>
>> Signed-off-by: Brian Cavagnolo <brian at cozybit.com>
>> ---
>> 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 91413a6..6a32f37 100644
>> --- a/drivers/net/wireless/libertas/if_usb.c
>> +++ b/drivers/net/wireless/libertas/if_usb.c
>> @@ -46,6 +46,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_fw attribute to be exported per ethX interface through sysfs
>> + * (/sys/class/net/ethX/lbs_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_fw
>> + */
>> +static DEVICE_ATTR(lbs_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_boot2 attribute to be exported per ethX interface through sysfs
>> + * (/sys/class/net/ethX/lbs_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_boot2
>> + */
>> +static DEVICE_ATTR(lbs_boot2, 0200, NULL, if_usb_boot2_set);
>> +
>> /**
>> * @brief call back function to handle the status of the URB
>> * @param urb pointer to urb structure
>> @@ -246,6 +302,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_fw))
>> + lbs_pr_err("cannot register lbs_fw attribute\n");
>> +
>> + if (device_create_file(&priv->dev->dev, &dev_attr_lbs_boot2))
>> + lbs_pr_err("cannot register lbs_boot2 attribute\n");
>> +
>> return 0;
>>
>> err_start_card:
>> @@ -271,6 +333,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_boot2);
>> + device_remove_file(&priv->dev->dev, &dev_attr_lbs_fw);
>> +
>> cardp->surprise_removed = 1;
>>
>> if (priv) {
>
> _______________________________________________
> Devel mailing list
> Devel at lists.laptop.org
> http://lists.laptop.org/listinfo/devel
>
More information about the Devel
mailing list