Commit b3110cd8 authored by Matthias Beyer's avatar Matthias Beyer Committed by Greg Kroah-Hartman

Staging: bcm: Outsourced selecting of alternate setting

This patch outsources a chunk of code which is for selecting an
alternate setting for highspeed modem into a new function.
Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b4ad0f04
......@@ -374,57 +374,15 @@ static int device_run(struct bcm_interface_adapter *psIntfAdapter)
return 0;
}
static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
static int select_alternate_setting_for_highspeed_modem(
struct bcm_interface_adapter *psIntfAdapter,
struct usb_endpoint_descriptor **endpoint,
const struct usb_host_interface *iface_desc,
int *usedIntOutForBulkTransfer)
{
struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
size_t buffer_size;
unsigned long value;
int retval = 0;
int usedIntOutForBulkTransfer = 0;
bool bBcm16 = false;
UINT uiData = 0;
int bytes;
struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter;
/* Store the usb dev into interface adapter */
psIntfAdapter->udev =
usb_get_dev(interface_to_usbdev(psIntfAdapter->interface));
psIntfAdapter->bHighSpeedDevice =
(psIntfAdapter->udev->speed == USB_SPEED_HIGH);
psAd->interface_rdm = BcmRDM;
psAd->interface_wrm = BcmWRM;
bytes = rdmalt(psAd, CHIP_ID_REG, (u32 *) &(psAd->chip_id),
sizeof(u32));
if (bytes < 0) {
retval = bytes;
BCM_DEBUG_PRINT(psAd, DBG_TYPE_PRINTK, 0, 0,
"CHIP ID Read Failed\n");
return retval;
}
if (0xbece3200 == (psAd->chip_id & ~(0xF0)))
psAd->chip_id &= ~0xF0;
dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n",
psAd->chip_id);
iface_desc = psIntfAdapter->interface->cur_altsetting;
if (psAd->chip_id == T3B) {
/* T3B device will have EEPROM, check if EEPROM is proper and
* BCM16 can be done or not. */
BeceemEEPROMBulkRead(psAd, &uiData, 0x0, 4);
if (uiData == BECM)
bBcm16 = TRUE;
dev_info(&psIntfAdapter->udev->dev,
"number of alternate setting %d\n",
psIntfAdapter->interface->num_altsetting);
if (bBcm16 == TRUE) {
/* selecting alternate setting one as a default setting
* for High Speed modem. */
if (psIntfAdapter->bHighSpeedDevice)
......@@ -435,8 +393,8 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
DBG_LVL_ALL,
"BCM16 is applicable on this dongle\n");
if (retval || !psIntfAdapter->bHighSpeedDevice) {
usedIntOutForBulkTransfer = EP2;
endpoint = &iface_desc->endpoint[EP2].desc;
*usedIntOutForBulkTransfer = EP2;
*endpoint = &iface_desc->endpoint[EP2].desc;
BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
DRV_ENTRY, DBG_LVL_ALL,
"Interface altsetting failed or modem is configured to Full Speed, hence will work on default setting 0\n");
......@@ -448,9 +406,9 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
* point
*/
if ((psIntfAdapter->bHighSpeedDevice &&
!usb_endpoint_is_int_out(endpoint)) ||
!usb_endpoint_is_int_out(*endpoint)) ||
(!psIntfAdapter->bHighSpeedDevice &&
!usb_endpoint_is_bulk_out(endpoint))) {
!usb_endpoint_is_bulk_out(*endpoint))) {
BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
DRV_ENTRY, DBG_LVL_ALL,
"Configuring the EEPROM\n");
......@@ -477,7 +435,7 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
}
if (!psIntfAdapter->bHighSpeedDevice &&
usb_endpoint_is_bulk_out(endpoint)) {
usb_endpoint_is_bulk_out(*endpoint)) {
/* Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail. */
UINT _uiData = ntohl(EP2_CFG_INT);
BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
......@@ -488,12 +446,12 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
0x136, 4, TRUE);
}
} else {
usedIntOutForBulkTransfer = EP4;
endpoint = &iface_desc->endpoint[EP4].desc;
*usedIntOutForBulkTransfer = EP4;
*endpoint = &iface_desc->endpoint[EP4].desc;
BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
DRV_ENTRY, DBG_LVL_ALL,
"Choosing AltSetting as a default setting.\n");
if (!usb_endpoint_is_int_out(endpoint)) {
if (!usb_endpoint_is_int_out(*endpoint)) {
BCM_DEBUG_PRINT(psAd, DBG_TYPE_INITEXIT,
DRV_ENTRY, DBG_LVL_ALL,
"Dongle does not have BCM16 Fix.\n");
......@@ -517,9 +475,68 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
"reset failed. Re-enumerating the device.\n");
return retval;
}
}
}
return 0;
}
static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
{
struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
size_t buffer_size;
unsigned long value;
int retval = 0;
int usedIntOutForBulkTransfer = 0;
bool bBcm16 = false;
UINT uiData = 0;
int bytes;
struct bcm_mini_adapter *psAd = psIntfAdapter->psAdapter;
/* Store the usb dev into interface adapter */
psIntfAdapter->udev =
usb_get_dev(interface_to_usbdev(psIntfAdapter->interface));
psIntfAdapter->bHighSpeedDevice =
(psIntfAdapter->udev->speed == USB_SPEED_HIGH);
psAd->interface_rdm = BcmRDM;
psAd->interface_wrm = BcmWRM;
bytes = rdmalt(psAd, CHIP_ID_REG, (u32 *) &(psAd->chip_id),
sizeof(u32));
if (bytes < 0) {
retval = bytes;
BCM_DEBUG_PRINT(psAd, DBG_TYPE_PRINTK, 0, 0,
"CHIP ID Read Failed\n");
return retval;
}
if (0xbece3200 == (psAd->chip_id & ~(0xF0)))
psAd->chip_id &= ~0xF0;
dev_info(&psIntfAdapter->udev->dev, "RDM Chip ID 0x%lx\n",
psAd->chip_id);
iface_desc = psIntfAdapter->interface->cur_altsetting;
if (psAd->chip_id == T3B) {
/* T3B device will have EEPROM, check if EEPROM is proper and
* BCM16 can be done or not. */
BeceemEEPROMBulkRead(psAd, &uiData, 0x0, 4);
if (uiData == BECM)
bBcm16 = TRUE;
dev_info(&psIntfAdapter->udev->dev,
"number of alternate setting %d\n",
psIntfAdapter->interface->num_altsetting);
if (bBcm16 == TRUE) {
retval = select_alternate_setting_for_highspeed_modem(
psIntfAdapter, &endpoint, iface_desc,
&usedIntOutForBulkTransfer);
if (retval)
return retval;
}
}
......
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