3 INT
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter
,
11 if (psIntfAdapter
== NULL
) {
12 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_PRINTK
, 0, 0, "Interface Adapter is NULL");
16 if (psIntfAdapter
->psAdapter
->device_removed
== TRUE
) {
17 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_PRINTK
, 0, 0, "Device got removed");
21 if ((psIntfAdapter
->psAdapter
->StopAllXaction
== TRUE
) && (psIntfAdapter
->psAdapter
->chip_id
>= T3LPB
)) {
22 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
, "Currently Xaction is not allowed on the bus");
26 if (psIntfAdapter
->bSuspended
== TRUE
|| psIntfAdapter
->bPreparingForBusSuspend
== TRUE
) {
27 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
, "Bus is in suspended states hence RDM not allowed..");
30 psIntfAdapter
->psAdapter
->DeviceAccess
= TRUE
;
33 retval
= usb_control_msg(psIntfAdapter
->udev
,
34 usb_rcvctrlpipe(psIntfAdapter
->udev
, 0),
38 ((addr
>> 16) & 0xFFFF),
44 if (-ENODEV
== retval
) {
45 psIntfAdapter
->psAdapter
->device_removed
= TRUE
;
49 } while ((retval
< 0) && (usRetries
< MAX_RDM_WRM_RETIRES
));
52 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
, "RDM failed status :%d, retires :%d", retval
, usRetries
);
53 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
56 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
, "RDM sent %d", retval
);
57 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
58 return STATUS_SUCCESS
;
62 INT
InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter
,
70 if (psIntfAdapter
== NULL
) {
71 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_PRINTK
, 0, 0, "Interface Adapter is NULL");
75 if (psIntfAdapter
->psAdapter
->device_removed
== TRUE
) {
76 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_PRINTK
, 0, 0, "Device got removed");
80 if ((psIntfAdapter
->psAdapter
->StopAllXaction
== TRUE
) && (psIntfAdapter
->psAdapter
->chip_id
>= T3LPB
)) {
81 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
, "Currently Xaction is not allowed on the bus...");
85 if (psIntfAdapter
->bSuspended
== TRUE
|| psIntfAdapter
->bPreparingForBusSuspend
== TRUE
) {
86 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
, "Bus is in suspended states hence RDM not allowed..");
90 psIntfAdapter
->psAdapter
->DeviceAccess
= TRUE
;
93 retval
= usb_control_msg(psIntfAdapter
->udev
,
94 usb_sndctrlpipe(psIntfAdapter
->udev
, 0),
98 ((addr
>> 16) & 0xFFFF),
104 if (-ENODEV
== retval
) {
105 psIntfAdapter
->psAdapter
->device_removed
= TRUE
;
109 } while ((retval
< 0) && (usRetries
< MAX_RDM_WRM_RETIRES
));
112 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
, "WRM failed status :%d, retires :%d", retval
, usRetries
);
113 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
116 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
117 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
, DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
, "WRM sent %d", retval
);
118 return STATUS_SUCCESS
;
122 INT
BcmRDM(PVOID arg
,
127 return InterfaceRDM((PS_INTERFACE_ADAPTER
)arg
, addr
, buff
, len
);
130 INT
BcmWRM(PVOID arg
,
135 return InterfaceWRM((PS_INTERFACE_ADAPTER
)arg
, addr
, buff
, len
);
138 INT
Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter
)
140 PS_INTERFACE_ADAPTER psIntfAdapter
= (PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
);
141 INT status
= STATUS_SUCCESS
;
144 * usb_clear_halt - tells device to clear endpoint halt/stall condition
145 * @dev: device whose endpoint is halted
146 * @pipe: endpoint "pipe" being cleared
147 * @ Context: !in_interrupt ()
149 * usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code.
150 * This is used to clear halt conditions for bulk and interrupt endpoints only.
151 * Control and isochronous endpoints never halts.
153 * Any URBs queued for such an endpoint should normally be unlinked by the driver
154 * before clearing the halt condition.
158 /* Killing all the submitted urbs to different end points. */
159 Bcm_kill_all_URBs(psIntfAdapter
);
161 /* clear the halted/stalled state for every end point */
162 status
= usb_clear_halt(psIntfAdapter
->udev
, psIntfAdapter
->sIntrIn
.int_in_pipe
);
163 if (status
!= STATUS_SUCCESS
)
164 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, INTF_INIT
, DBG_LVL_ALL
, "Unable to Clear Halt of Interrupt IN end point. :%d ", status
);
166 status
= usb_clear_halt(psIntfAdapter
->udev
, psIntfAdapter
->sBulkIn
.bulk_in_pipe
);
167 if (status
!= STATUS_SUCCESS
)
168 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, INTF_INIT
, DBG_LVL_ALL
, "Unable to Clear Halt of Bulk IN end point. :%d ", status
);
170 status
= usb_clear_halt(psIntfAdapter
->udev
, psIntfAdapter
->sBulkOut
.bulk_out_pipe
);
171 if (status
!= STATUS_SUCCESS
)
172 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, INTF_INIT
, DBG_LVL_ALL
, "Unable to Clear Halt of Bulk OUT end point. :%d ", status
);
177 VOID
Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter
)
179 struct urb
*tempUrb
= NULL
;
183 * usb_kill_urb - cancel a transfer request and wait for it to finish
184 * @urb: pointer to URB describing a previously submitted request,
185 * returns nothing as it is void returned API.
187 * This routine cancels an in-progress request. It is guaranteed that
188 * upon return all completion handlers will have finished and the URB
189 * will be totally idle and available for reuse
191 * This routine may not be used in an interrupt context (such as a bottom
192 * half or a completion handler), or when holding a spinlock, or in other
193 * situations where the caller can't schedule().
197 /* Cancel submitted Interrupt-URB's */
198 if (psIntfAdapter
->psInterruptUrb
!= NULL
) {
199 if (psIntfAdapter
->psInterruptUrb
->status
== -EINPROGRESS
)
200 usb_kill_urb(psIntfAdapter
->psInterruptUrb
);
203 /* Cancel All submitted TX URB's */
204 for (i
= 0; i
< MAXIMUM_USB_TCB
; i
++) {
205 tempUrb
= psIntfAdapter
->asUsbTcb
[i
].urb
;
207 if (tempUrb
->status
== -EINPROGRESS
)
208 usb_kill_urb(tempUrb
);
212 for (i
= 0; i
< MAXIMUM_USB_RCB
; i
++) {
213 tempUrb
= psIntfAdapter
->asUsbRcb
[i
].urb
;
215 if (tempUrb
->status
== -EINPROGRESS
)
216 usb_kill_urb(tempUrb
);
220 atomic_set(&psIntfAdapter
->uNumTcbUsed
, 0);
221 atomic_set(&psIntfAdapter
->uCurrTcb
, 0);
223 atomic_set(&psIntfAdapter
->uNumRcbUsed
, 0);
224 atomic_set(&psIntfAdapter
->uCurrRcb
, 0);
227 VOID
putUsbSuspend(struct work_struct
*work
)
229 PS_INTERFACE_ADAPTER psIntfAdapter
= NULL
;
230 struct usb_interface
*intf
= NULL
;
231 psIntfAdapter
= container_of(work
, S_INTERFACE_ADAPTER
, usbSuspendWork
);
232 intf
= psIntfAdapter
->interface
;
234 if (psIntfAdapter
->bSuspended
== FALSE
)
235 usb_autopm_put_interface(intf
);