Skip to content

Commit 235b630

Browse files
Sean-StarLabsgregkh
authored andcommitted
drivers/card_reader/rtsx_usb: Restore interrupt based detection
This commit reintroduces interrupt-based card detection previously used in the rts5139 driver. This functionality was removed in commit 00d8521 ("staging: remove rts5139 driver code"). Reintroducing this mechanism fixes presence detection for certain card readers, which with the current driver, will taken approximately 20 seconds to enter S3 as `mmc_rescan` has to be frozen. Fixes: 00d8521 ("staging: remove rts5139 driver code") Cc: [email protected] Cc: Arnd Bergmann <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Sean Rhodes <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ff5e0c8 commit 235b630

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/misc/cardreader/rtsx_usb.c

+15
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ static int rtsx_usb_get_status_with_bulk(struct rtsx_ucr *ucr, u16 *status)
286286
int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
287287
{
288288
int ret;
289+
u8 interrupt_val = 0;
289290
u16 *buf;
290291

291292
if (!status)
@@ -308,6 +309,20 @@ int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
308309
ret = rtsx_usb_get_status_with_bulk(ucr, status);
309310
}
310311

312+
rtsx_usb_read_register(ucr, CARD_INT_PEND, &interrupt_val);
313+
/* Cross check presence with interrupts */
314+
if (*status & XD_CD)
315+
if (!(interrupt_val & XD_INT))
316+
*status &= ~XD_CD;
317+
318+
if (*status & SD_CD)
319+
if (!(interrupt_val & SD_INT))
320+
*status &= ~SD_CD;
321+
322+
if (*status & MS_CD)
323+
if (!(interrupt_val & MS_INT))
324+
*status &= ~MS_CD;
325+
311326
/* usb_control_msg may return positive when success */
312327
if (ret < 0)
313328
return ret;

0 commit comments

Comments
 (0)