linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] libertas: add sysfs hooks to update boot2 and persistent firmware
@ 2008-07-16 17:28 Brian Cavagnolo
  2008-07-17 17:54 ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Cavagnolo @ 2008-07-16 17:28 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, libertas-dev

To use these features, copy the boot2 and firmware images to /lib/firmware and:

echo <boot2_image_name> > /sys/class/net/ethX/lbs_boot2
echo <firmware_image_name> > /sys/class/net/ethX/lbs_fw

Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
---
 drivers/net/wireless/libertas/if_usb.c |   71 ++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index e83a4c2..c89785c 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -51,6 +51,68 @@ 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;
+
+	if (!(priv->fwcapinfo & FW_CAPINFO_FIRMWARE_UPGRADE))
+		return -EOPNOTSUPP;
+
+	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;
+
+	if (!(priv->fwcapinfo & FW_CAPINFO_BOOT2_UPGRADE))
+		return -EOPNOTSUPP;
+
+	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
@@ -263,6 +325,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:
@@ -288,6 +356,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) {
-- 
1.5.5.3




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] libertas: add sysfs hooks to update boot2 and persistent firmware
  2008-07-16 17:28 [PATCH 2/3] libertas: add sysfs hooks to update boot2 and persistent firmware Brian Cavagnolo
@ 2008-07-17 17:54 ` Dan Williams
  2008-07-17 18:39   ` Brian Cavagnolo
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Williams @ 2008-07-17 17:54 UTC (permalink / raw)
  To: Brian Cavagnolo; +Cc: linville, linux-wireless, libertas-dev

On Wed, 2008-07-16 at 10:28 -0700, Brian Cavagnolo wrote:
> To use these features, copy the boot2 and firmware images to /lib/firmware and:
> 
> echo <boot2_image_name> > /sys/class/net/ethX/lbs_boot2
> echo <firmware_image_name> > /sys/class/net/ethX/lbs_fw

Perhaps "lbs_flash_boot2" and "lbs_flash_fw" would be better names here?
Otherwise it looks like one of the drivers that you can choose alternate
firmware for (atmel.c for example) and doesn't give any indication that
it'll permanently change what's on the dongle.

Dan

> Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
> ---
>  drivers/net/wireless/libertas/if_usb.c |   71 ++++++++++++++++++++++++++++++++
>  1 files changed, 71 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
> index e83a4c2..c89785c 100644
> --- a/drivers/net/wireless/libertas/if_usb.c
> +++ b/drivers/net/wireless/libertas/if_usb.c
> @@ -51,6 +51,68 @@ 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;
> +
> +	if (!(priv->fwcapinfo & FW_CAPINFO_FIRMWARE_UPGRADE))
> +		return -EOPNOTSUPP;
> +
> +	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;
> +
> +	if (!(priv->fwcapinfo & FW_CAPINFO_BOOT2_UPGRADE))
> +		return -EOPNOTSUPP;
> +
> +	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
> @@ -263,6 +325,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:
> @@ -288,6 +356,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) {


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] libertas: add sysfs hooks to update boot2 and persistent firmware
  2008-07-17 17:54 ` Dan Williams
@ 2008-07-17 18:39   ` Brian Cavagnolo
  2008-07-17 18:52     ` Dan Williams
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Cavagnolo @ 2008-07-17 18:39 UTC (permalink / raw)
  To: Dan Williams; +Cc: linville, linux-wireless, libertas-dev

On Thu, Jul 17, 2008 at 10:54 AM, Dan Williams <dcbw@redhat.com> wrote:
> On Wed, 2008-07-16 at 10:28 -0700, Brian Cavagnolo wrote:
>> To use these features, copy the boot2 and firmware images to /lib/firmware and:
>>
>> echo <boot2_image_name> > /sys/class/net/ethX/lbs_boot2
>> echo <firmware_image_name> > /sys/class/net/ethX/lbs_fw
>
> Perhaps "lbs_flash_boot2" and "lbs_flash_fw" would be better names here?
> Otherwise it looks like one of the drivers that you can choose alternate
> firmware for (atmel.c for example) and doesn't give any indication that
> it'll permanently change what's on the dongle.

Sounds good.  I'll fix that and resubmit.

Ciao,
Brian

>> Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
>> ---
>>  drivers/net/wireless/libertas/if_usb.c |   71 ++++++++++++++++++++++++++++++++
>>  1 files changed, 71 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
>> index e83a4c2..c89785c 100644
>> --- a/drivers/net/wireless/libertas/if_usb.c
>> +++ b/drivers/net/wireless/libertas/if_usb.c
>> @@ -51,6 +51,68 @@ 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;
>> +
>> +     if (!(priv->fwcapinfo & FW_CAPINFO_FIRMWARE_UPGRADE))
>> +             return -EOPNOTSUPP;
>> +
>> +     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;
>> +
>> +     if (!(priv->fwcapinfo & FW_CAPINFO_BOOT2_UPGRADE))
>> +             return -EOPNOTSUPP;
>> +
>> +     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
>> @@ -263,6 +325,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:
>> @@ -288,6 +356,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) {
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/3] libertas: add sysfs hooks to update boot2 and persistent firmware
  2008-07-17 18:39   ` Brian Cavagnolo
@ 2008-07-17 18:52     ` Dan Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2008-07-17 18:52 UTC (permalink / raw)
  To: Brian Cavagnolo; +Cc: linville, linux-wireless, libertas-dev

On Thu, 2008-07-17 at 11:39 -0700, Brian Cavagnolo wrote:
> On Thu, Jul 17, 2008 at 10:54 AM, Dan Williams <dcbw@redhat.com> wrote:
> > On Wed, 2008-07-16 at 10:28 -0700, Brian Cavagnolo wrote:
> >> To use these features, copy the boot2 and firmware images to /lib/firmware and:
> >>
> >> echo <boot2_image_name> > /sys/class/net/ethX/lbs_boot2
> >> echo <firmware_image_name> > /sys/class/net/ethX/lbs_fw
> >
> > Perhaps "lbs_flash_boot2" and "lbs_flash_fw" would be better names here?
> > Otherwise it looks like one of the drivers that you can choose alternate
> > firmware for (atmel.c for example) and doesn't give any indication that
> > it'll permanently change what's on the dongle.
> 
> Sounds good.  I'll fix that and resubmit.

Just looked again and found the usb8xxx's "lbs_firmware" parameter which
allows you to change the default firmware name on modprobe, which means
it's even more important to change the names of these two new
attributes.  Thanks!

Dan

> Ciao,
> Brian
> 
> >> Signed-off-by: Brian Cavagnolo <brian@cozybit.com>
> >> ---
> >>  drivers/net/wireless/libertas/if_usb.c |   71 ++++++++++++++++++++++++++++++++
> >>  1 files changed, 71 insertions(+), 0 deletions(-)
> >>
> >> diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
> >> index e83a4c2..c89785c 100644
> >> --- a/drivers/net/wireless/libertas/if_usb.c
> >> +++ b/drivers/net/wireless/libertas/if_usb.c
> >> @@ -51,6 +51,68 @@ 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;
> >> +
> >> +     if (!(priv->fwcapinfo & FW_CAPINFO_FIRMWARE_UPGRADE))
> >> +             return -EOPNOTSUPP;
> >> +
> >> +     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;
> >> +
> >> +     if (!(priv->fwcapinfo & FW_CAPINFO_BOOT2_UPGRADE))
> >> +             return -EOPNOTSUPP;
> >> +
> >> +     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
> >> @@ -263,6 +325,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:
> >> @@ -288,6 +356,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) {
> >
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-17 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-16 17:28 [PATCH 2/3] libertas: add sysfs hooks to update boot2 and persistent firmware Brian Cavagnolo
2008-07-17 17:54 ` Dan Williams
2008-07-17 18:39   ` Brian Cavagnolo
2008-07-17 18:52     ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).