Commit 35644b0c authored by Duncan Sands's avatar Duncan Sands Committed by Greg Kroah-Hartman

[PATCH] USBATM: add flags field

Have minidrivers and the core signal special requirements
using a flags field in struct usbatm_data.  For the moment
this is only used to replace the need_heavy_init bind
parameter, but there'll be new flags in later patches.
Signed-off-by: default avatarDuncan Sands <baldrick@free.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 0ec3c7e8
...@@ -666,8 +666,7 @@ static int cxacru_heavy_init(struct usbatm_data *usbatm_instance, ...@@ -666,8 +666,7 @@ static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
} }
static int cxacru_bind(struct usbatm_data *usbatm_instance, static int cxacru_bind(struct usbatm_data *usbatm_instance,
struct usb_interface *intf, const struct usb_device_id *id, struct usb_interface *intf, const struct usb_device_id *id)
int *need_heavy_init)
{ {
struct cxacru_data *instance; struct cxacru_data *instance;
struct usb_device *usb_dev = interface_to_usbdev(intf); struct usb_device *usb_dev = interface_to_usbdev(intf);
...@@ -726,7 +725,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance, ...@@ -726,7 +725,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
usbatm_instance->driver_data = instance; usbatm_instance->driver_data = instance;
*need_heavy_init = cxacru_card_status(instance); usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT);
return 0; return 0;
......
...@@ -681,8 +681,7 @@ static void speedtch_release_interfaces(struct usb_device *usb_dev, int num_inte ...@@ -681,8 +681,7 @@ static void speedtch_release_interfaces(struct usb_device *usb_dev, int num_inte
static int speedtch_bind(struct usbatm_data *usbatm, static int speedtch_bind(struct usbatm_data *usbatm,
struct usb_interface *intf, struct usb_interface *intf,
const struct usb_device_id *id, const struct usb_device_id *id)
int *need_heavy_init)
{ {
struct usb_device *usb_dev = interface_to_usbdev(intf); struct usb_device *usb_dev = interface_to_usbdev(intf);
struct usb_interface *cur_intf; struct usb_interface *cur_intf;
...@@ -754,11 +753,11 @@ static int speedtch_bind(struct usbatm_data *usbatm, ...@@ -754,11 +753,11 @@ static int speedtch_bind(struct usbatm_data *usbatm,
0x12, 0xc0, 0x07, 0x00, 0x12, 0xc0, 0x07, 0x00,
instance->scratch_buffer + OFFSET_7, SIZE_7, 500); instance->scratch_buffer + OFFSET_7, SIZE_7, 500);
*need_heavy_init = (ret != SIZE_7); usbatm->flags = (ret == SIZE_7 ? UDSL_SKIP_HEAVY_INIT : 0);
usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already"); usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, usbatm->flags & UDSL_SKIP_HEAVY_INIT ? "already" : "not");
if (*need_heavy_init) if (!(usbatm->flags & UDSL_SKIP_HEAVY_INIT))
if ((ret = usb_reset_device(usb_dev)) < 0) { if ((ret = usb_reset_device(usb_dev)) < 0) {
usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret); usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
goto fail_free; goto fail_free;
......
...@@ -1617,7 +1617,7 @@ static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf) ...@@ -1617,7 +1617,7 @@ static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
} }
static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
const struct usb_device_id *id, int *heavy) const struct usb_device_id *id)
{ {
struct usb_device *usb = interface_to_usbdev(intf); struct usb_device *usb = interface_to_usbdev(intf);
struct uea_softc *sc; struct uea_softc *sc;
...@@ -1629,7 +1629,7 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, ...@@ -1629,7 +1629,7 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
if (ifnum != UEA_INTR_IFACE_NO) if (ifnum != UEA_INTR_IFACE_NO)
return -ENODEV; return -ENODEV;
*heavy = sync_wait[modem_index]; usbatm_instance->flags = (sync_wait[modem_index] ? 0 : UDSL_SKIP_HEAVY_INIT);
/* interface 1 is for outbound traffic */ /* interface 1 is for outbound traffic */
ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO); ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);
......
...@@ -969,7 +969,6 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, ...@@ -969,7 +969,6 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
char *buf; char *buf;
int error = -ENOMEM; int error = -ENOMEM;
int i, length; int i, length;
int need_heavy;
dev_dbg(dev, "%s: trying driver %s with vendor=%04x, product=%04x, ifnum %2d\n", dev_dbg(dev, "%s: trying driver %s with vendor=%04x, product=%04x, ifnum %2d\n",
__func__, driver->driver_name, __func__, driver->driver_name,
...@@ -1014,8 +1013,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, ...@@ -1014,8 +1013,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
snprintf(buf, length, ")"); snprintf(buf, length, ")");
bind: bind:
need_heavy = 1; if (driver->bind && (error = driver->bind(instance, intf, id)) < 0) {
if (driver->bind && (error = driver->bind(instance, intf, id, &need_heavy)) < 0) {
dev_err(dev, "%s: bind failed: %d!\n", __func__, error); dev_err(dev, "%s: bind failed: %d!\n", __func__, error);
goto fail_free; goto fail_free;
} }
...@@ -1098,7 +1096,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, ...@@ -1098,7 +1096,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id,
__func__, urb->transfer_buffer, urb->transfer_buffer_length, urb); __func__, urb->transfer_buffer, urb->transfer_buffer_length, urb);
} }
if (need_heavy && driver->heavy_init) { if (!(instance->flags & UDSL_SKIP_HEAVY_INIT) && driver->heavy_init) {
error = usbatm_heavy_init(instance); error = usbatm_heavy_init(instance);
} else { } else {
complete(&instance->thread_exited); /* pretend that heavy_init was run */ complete(&instance->thread_exited); /* pretend that heavy_init was run */
......
...@@ -84,6 +84,11 @@ ...@@ -84,6 +84,11 @@
#endif #endif
/* flags, set by mini-driver in bind() */
#define UDSL_SKIP_HEAVY_INIT (1<<0)
/* mini driver */ /* mini driver */
struct usbatm_data; struct usbatm_data;
...@@ -99,12 +104,9 @@ struct usbatm_driver { ...@@ -99,12 +104,9 @@ struct usbatm_driver {
const char *driver_name; const char *driver_name;
/* /* init device ... can sleep, or cause probe() failure */
* init device ... can sleep, or cause probe() failure. Drivers with a heavy_init
* method can avoid having it called by setting need_heavy_init to zero.
*/
int (*bind) (struct usbatm_data *, struct usb_interface *, int (*bind) (struct usbatm_data *, struct usb_interface *,
const struct usb_device_id *id, int *need_heavy_init); const struct usb_device_id *id);
/* additional device initialization that is too slow to be done in probe() */ /* additional device initialization that is too slow to be done in probe() */
int (*heavy_init) (struct usbatm_data *, struct usb_interface *); int (*heavy_init) (struct usbatm_data *, struct usb_interface *);
...@@ -152,6 +154,7 @@ struct usbatm_data { ...@@ -152,6 +154,7 @@ struct usbatm_data {
struct usbatm_driver *driver; struct usbatm_driver *driver;
void *driver_data; void *driver_data;
char driver_name[16]; char driver_name[16];
unsigned int flags; /* set by mini-driver in bind() */
/* USB device */ /* USB device */
struct usb_device *usb_dev; struct usb_device *usb_dev;
......
...@@ -62,8 +62,7 @@ static int usb_intf_has_ep(const struct usb_interface *intf, u8 ep) ...@@ -62,8 +62,7 @@ static int usb_intf_has_ep(const struct usb_interface *intf, u8 ep)
} }
static int xusbatm_bind(struct usbatm_data *usbatm, static int xusbatm_bind(struct usbatm_data *usbatm,
struct usb_interface *intf, const struct usb_device_id *id, struct usb_interface *intf, const struct usb_device_id *id)
int *need_heavy_init)
{ {
struct usb_device *usb_dev = interface_to_usbdev(intf); struct usb_device *usb_dev = interface_to_usbdev(intf);
int drv_ix = id - xusbatm_usb_ids; int drv_ix = id - xusbatm_usb_ids;
......
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