3 static int adapter_err_occurred(const struct bcm_interface_adapter *ad)
5 if (ad->psAdapter->device_removed == TRUE) {
6 BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_PRINTK, 0, 0,
11 if ((ad->psAdapter->StopAllXaction == TRUE) &&
12 (ad->psAdapter->chip_id >= T3LPB)) {
13 BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM,
15 "Currently Xaction is not allowed on the bus");
19 if (ad->bSuspended == TRUE || ad->bPreparingForBusSuspend == TRUE) {
20 BCM_DEBUG_PRINT(ad->psAdapter, DBG_TYPE_OTHERS, RDM,
22 "Bus is in suspended states hence RDM not allowed..");
29 int InterfaceRDM(struct bcm_interface_adapter *psIntfAdapter,
40 err = adapter_err_occurred(psIntfAdapter);
44 psIntfAdapter->psAdapter->DeviceAccess = TRUE;
46 bytes = usb_control_msg(psIntfAdapter->udev,
47 usb_rcvctrlpipe(psIntfAdapter->udev, 0),
51 ((addr >> 16) & 0xFFFF),
57 psIntfAdapter->psAdapter->device_removed = TRUE;
60 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM,
61 DBG_LVL_ALL, "RDM failed status :%d", bytes);
63 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, RDM,
64 DBG_LVL_ALL, "RDM sent %d", bytes);
66 psIntfAdapter->psAdapter->DeviceAccess = false;
70 int InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter,
81 err = adapter_err_occurred(psIntfAdapter);
85 psIntfAdapter->psAdapter->DeviceAccess = TRUE;
87 retval = usb_control_msg(psIntfAdapter->udev,
88 usb_sndctrlpipe(psIntfAdapter->udev, 0),
92 ((addr >> 16) & 0xFFFF),
97 if (-ENODEV == retval)
98 psIntfAdapter->psAdapter->device_removed = TRUE;
101 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM,
102 DBG_LVL_ALL, "WRM failed status :%d", retval);
103 psIntfAdapter->psAdapter->DeviceAccess = false;
106 psIntfAdapter->psAdapter->DeviceAccess = false;
107 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter, DBG_TYPE_OTHERS, WRM,
108 DBG_LVL_ALL, "WRM sent %d", retval);
109 return STATUS_SUCCESS;
113 int BcmRDM(void *arg,
118 return InterfaceRDM((struct bcm_interface_adapter *)arg, addr, buff,
122 int BcmWRM(void *arg,
127 return InterfaceWRM((struct bcm_interface_adapter *)arg, addr, buff,
131 int Bcm_clear_halt_of_endpoints(struct bcm_mini_adapter *Adapter)
133 struct bcm_interface_adapter *psIntfAdapter =
134 (struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter);
135 int status = STATUS_SUCCESS;
138 * usb_clear_halt - tells device to clear endpoint halt/stall condition
139 * @dev: device whose endpoint is halted
140 * @pipe: endpoint "pipe" being cleared
141 * @ Context: !in_interrupt ()
143 * usb_clear_halt is the synchrnous call and returns 0 on success else
144 * returns with error code.
145 * This is used to clear halt conditions for bulk and interrupt
147 * Control and isochronous endpoints never halts.
149 * Any URBs queued for such an endpoint should normally be unlinked by
150 * the driver before clearing the halt condition.
154 /* Killing all the submitted urbs to different end points. */
155 Bcm_kill_all_URBs(psIntfAdapter);
157 /* clear the halted/stalled state for every end point */
158 status = usb_clear_halt(psIntfAdapter->udev,
159 psIntfAdapter->sIntrIn.int_in_pipe);
160 if (status != STATUS_SUCCESS)
161 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
163 "Unable to Clear Halt of Interrupt IN end point. :%d ",
166 status = usb_clear_halt(psIntfAdapter->udev,
167 psIntfAdapter->sBulkIn.bulk_in_pipe);
168 if (status != STATUS_SUCCESS)
169 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
171 "Unable to Clear Halt of Bulk IN end point. :%d ",
174 status = usb_clear_halt(psIntfAdapter->udev,
175 psIntfAdapter->sBulkOut.bulk_out_pipe);
176 if (status != STATUS_SUCCESS)
177 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, INTF_INIT,
179 "Unable to Clear Halt of Bulk OUT end point. :%d ",
185 void Bcm_kill_all_URBs(struct bcm_interface_adapter *psIntfAdapter)
187 struct urb *tempUrb = NULL;
191 * usb_kill_urb - cancel a transfer request and wait for it to finish
192 * @urb: pointer to URB describing a previously submitted request,
193 * returns nothing as it is void returned API.
195 * This routine cancels an in-progress request. It is guaranteed that
196 * upon return all completion handlers will have finished and the URB
197 * will be totally idle and available for reuse
199 * This routine may not be used in an interrupt context (such as a
200 * bottom half or a completion handler), or when holding a spinlock, or
201 * in other situations where the caller can't schedule().
205 /* Cancel submitted Interrupt-URB's */
206 if (psIntfAdapter->psInterruptUrb) {
207 if (psIntfAdapter->psInterruptUrb->status == -EINPROGRESS)
208 usb_kill_urb(psIntfAdapter->psInterruptUrb);
211 /* Cancel All submitted TX URB's */
212 for (i = 0; i < MAXIMUM_USB_TCB; i++) {
213 tempUrb = psIntfAdapter->asUsbTcb[i].urb;
215 if (tempUrb->status == -EINPROGRESS)
216 usb_kill_urb(tempUrb);
220 for (i = 0; i < MAXIMUM_USB_RCB; i++) {
221 tempUrb = psIntfAdapter->asUsbRcb[i].urb;
223 if (tempUrb->status == -EINPROGRESS)
224 usb_kill_urb(tempUrb);
228 atomic_set(&psIntfAdapter->uNumTcbUsed, 0);
229 atomic_set(&psIntfAdapter->uCurrTcb, 0);
231 atomic_set(&psIntfAdapter->uNumRcbUsed, 0);
232 atomic_set(&psIntfAdapter->uCurrRcb, 0);
235 void putUsbSuspend(struct work_struct *work)
237 struct bcm_interface_adapter *psIntfAdapter = NULL;
238 struct usb_interface *intf = NULL;
240 psIntfAdapter = container_of(work, struct bcm_interface_adapter,
242 intf = psIntfAdapter->interface;
244 if (psIntfAdapter->bSuspended == false)
245 usb_autopm_put_interface(intf);