Commit 3bc5c62a authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] USB Gadget: Ethernet/RNDIS gadget, minor updates

Helps battery recharge, and gives this a new version string
since it's changed a lot since St. Patrick's Day.


Just minor updates:

 - use usb_gadget_vbus_draw() when changing configs, so that USB can
   be used to recharge batteries (or whatever); and report power use.
   bMaxPower is now 100 mA except with OTG (where it's 8mA).

 - rename /proc/rndis/000 as /proc/driver/rndis-000, and only have it
   when a new CONFIG variable is set (added by a later patch)

 - minor fixes to make some debug-only rndis messages compile

 - version is now "Equinox 2004".
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 1116edbf
......@@ -84,7 +84,7 @@
*/
#define DRIVER_DESC "Ethernet Gadget"
#define DRIVER_VERSION "St Patrick's Day 2004"
#define DRIVER_VERSION "Equinox 2004"
static const char shortname [] = "ether";
static const char driver_desc [] = DRIVER_DESC;
......@@ -391,7 +391,7 @@ eth_config = {
.bConfigurationValue = DEV_CONFIG_VALUE,
.iConfiguration = STRING_CDC,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
.bMaxPower = 1,
.bMaxPower = 50,
};
#ifdef CONFIG_USB_ETH_RNDIS
......@@ -405,7 +405,7 @@ rndis_config = {
.bConfigurationValue = DEV_RNDIS_CONFIG_VALUE,
.iConfiguration = STRING_RNDIS,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
.bMaxPower = 1,
.bMaxPower = 50,
};
#endif
......@@ -1202,13 +1202,20 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags)
result = -EINVAL;
/* FALL THROUGH */
case 0:
return result;
break;
}
if (result)
eth_reset_config (dev);
else {
if (result) {
if (number)
eth_reset_config (dev);
usb_gadget_vbus_draw(dev->gadget,
dev->gadget->is_otg ? 8 : 100);
} else {
char *speed;
unsigned power;
power = 2 * eth_config.bMaxPower;
usb_gadget_vbus_draw(dev->gadget, power);
switch (gadget->speed) {
case USB_SPEED_FULL: speed = "full"; break;
......@@ -1219,8 +1226,8 @@ eth_set_config (struct eth_dev *dev, unsigned number, int gfp_flags)
}
dev->config = number;
INFO (dev, "%s speed config #%d: %s, using %s\n",
speed, number, driver_desc,
INFO (dev, "%s speed config #%d: %d mA, %s, using %s\n",
speed, number, power, driver_desc,
dev->rndis
? "RNDIS"
: (dev->cdc
......@@ -1379,8 +1386,9 @@ static void eth_setup_complete (struct usb_ep *ep, struct usb_request *req)
static void rndis_response_complete (struct usb_ep *ep, struct usb_request *req)
{
if (req->status || req->actual != req->length)
DEBUG (dev, "rndis response complete --> %d, %d/%d\n",
req->status, req->actual, req->length);
DEBUG ((struct eth_dev *) ep->driver_data,
"rndis response complete --> %d, %d/%d\n",
req->status, req->actual, req->length);
/* done sending after CDC_GET_ENCAPSULATED_RESPONSE */
}
......@@ -2102,11 +2110,13 @@ static void rndis_send_media_state (struct eth_dev *dev, int connect)
}
}
static void rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
static void
rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
{
if (req->status || req->actual != req->length)
DEBUG (dev, "rndis control ack complete --> %d, %d/%d\n",
req->status, req->actual, req->length);
DEBUG ((struct eth_dev *) ep->driver_data,
"rndis control ack complete --> %d, %d/%d\n",
req->status, req->actual, req->length);
usb_ep_free_buffer(ep, req->buf, req->dma, 8);
usb_ep_free_request(ep, req);
......@@ -2472,8 +2482,10 @@ eth_bind (struct usb_gadget *gadget)
if (gadget->is_otg) {
otg_descriptor.bmAttributes |= USB_OTG_HNP,
eth_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
eth_config.bMaxPower = 4;
#ifdef CONFIG_USB_ETH_RNDIS
rndis_config.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
rndis_config.bMaxPower = 4;
#endif
}
......
......@@ -70,8 +70,6 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging");
#define RNDIS_MAX_CONFIGS 1
static struct proc_dir_entry *rndis_connect_dir;
static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS];
......@@ -1275,6 +1273,8 @@ int rndis_rm_hdr (u8 *buf, u32 *length)
return 0;
}
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
int rndis_proc_read (char *page, char **start, off_t off, int count, int *eof,
void *data)
{
......@@ -1365,43 +1365,40 @@ int rndis_proc_write (struct file *file, const char __user *buffer,
return count;
}
#define NAME_TEMPLATE "driver/rndis-%03d"
static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
int __init rndis_init (void)
{
u8 i;
char name [4];
/* FIXME this should probably be /proc/driver/rndis,
* and only if debugging is enabled
*/
if (!(rndis_connect_dir = proc_mkdir ("rndis", NULL))) {
printk (KERN_ERR "%s: couldn't create /proc/rndis entry",
__FUNCTION__);
return -EIO;
}
for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
sprintf (name, "%03d", i);
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
char name [20];
sprintf (name, NAME_TEMPLATE, i);
if (!(rndis_connect_state [i]
= create_proc_entry (name, 0660,
rndis_connect_dir)))
= create_proc_entry (name, 0660, NULL)))
{
DEBUG ("%s :remove entries", __FUNCTION__);
for (i--; i > 0; i--) {
sprintf (name, "%03d", i);
remove_proc_entry (name, rndis_connect_dir);
while (i) {
sprintf (name, NAME_TEMPLATE, --i);
remove_proc_entry (name, NULL);
}
DEBUG ("\n");
remove_proc_entry ("000", rndis_connect_dir);
remove_proc_entry ("rndis", NULL);
return -EIO;
}
rndis_connect_state [i]->nlink = 1;
rndis_connect_state [i]->write_proc = rndis_proc_write;
rndis_connect_state [i]->read_proc = rndis_proc_read;
rndis_connect_state [i]->data = (void *)
(rndis_per_dev_params + i);
#endif
rndis_per_dev_params [i].confignr = i;
rndis_per_dev_params [i].used = 0;
rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED;
......@@ -1415,14 +1412,14 @@ int __init rndis_init (void)
void rndis_exit (void)
{
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
u8 i;
char name [4];
char name [20];
for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
sprintf (name, "%03d", i);
remove_proc_entry (name, rndis_connect_dir);
sprintf (name, NAME_TEMPLATE, i);
remove_proc_entry (name, NULL);
}
remove_proc_entry ("rndis", NULL);
return;
#endif
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment