From fea52b8910f6f5438790dbd2de45003ce08d01a5 Mon Sep 17 00:00:00 2001 From: Roger Tseng Date: Fri, 11 Apr 2014 14:53:20 +0800 Subject: mfd: rtsx_usb: Fix possible race condition Fix two possible race condition generated by misuse of del_timer in rtsx_usb_bulk_transfer_sglist() and uninitialized timers before mfd_add_devices in rtsx_usb_probe(). Signed-off-by: Roger Tseng Signed-off-by: Lee Jones --- drivers/mfd/rtsx_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/mfd/rtsx_usb.c') diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c index b53b9d46cc4..0ca79736afe 100644 --- a/drivers/mfd/rtsx_usb.c +++ b/drivers/mfd/rtsx_usb.c @@ -67,7 +67,7 @@ static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout); add_timer(&ucr->sg_timer); usb_sg_wait(&ucr->current_sg); - del_timer(&ucr->sg_timer); + del_timer_sync(&ucr->sg_timer); if (act_len) *act_len = ucr->current_sg.bytes; @@ -644,14 +644,14 @@ static int rtsx_usb_probe(struct usb_interface *intf, if (ret) goto out_init_fail; + /* initialize USB SG transfer timer */ + setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr); + ret = mfd_add_devices(&intf->dev, usb_dev->devnum, rtsx_usb_cells, ARRAY_SIZE(rtsx_usb_cells), NULL, 0, NULL); if (ret) goto out_init_fail; - /* initialize USB SG transfer timer */ - init_timer(&ucr->sg_timer); - setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr); #ifdef CONFIG_PM intf->needs_remote_wakeup = 1; usb_enable_autosuspend(usb_dev); -- cgit v1.2.3-70-g09d2 From 5f0334205239bb5ae22ca89ad2af378062836498 Mon Sep 17 00:00:00 2001 From: Roger Tseng Date: Fri, 11 Apr 2014 14:53:21 +0800 Subject: mfd: rtsx_usb: Add comment in rtsx_usb_suspend Explain why there is no need to have a symmetric LED turn-on in resume handler while calling rtsx_usb_turn_off_led() in suspend handler. Signed-off-by: Roger Tseng Signed-off-by: Lee Jones --- drivers/mfd/rtsx_usb.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/mfd/rtsx_usb.c') diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c index 0ca79736afe..141ea52c46e 100644 --- a/drivers/mfd/rtsx_usb.c +++ b/drivers/mfd/rtsx_usb.c @@ -687,9 +687,15 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message) dev_dbg(&intf->dev, "%s called with pm message 0x%04u\n", __func__, message.event); + /* + * Call to make sure LED is off during suspend to save more power. + * It is NOT a permanent state and could be turned on anytime later. + * Thus no need to call turn_on when resunming. + */ mutex_lock(&ucr->dev_mutex); rtsx_usb_turn_off_led(ucr); mutex_unlock(&ucr->dev_mutex); + return 0; } -- cgit v1.2.3-70-g09d2 From 9031a939185b65f1d8eda2c8f7cd30472496dc9a Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 13 May 2014 12:58:44 +0200 Subject: mfd: rtsx_usb: Make mfd_cell array const mfd_add_devices() expects array of struct mfd_cell to be const. Signed-off-by: Krzysztof Kozlowski Acked-by: Roger Tseng Signed-off-by: Lee Jones --- drivers/mfd/rtsx_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mfd/rtsx_usb.c') diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c index 141ea52c46e..6352bec8419 100644 --- a/drivers/mfd/rtsx_usb.c +++ b/drivers/mfd/rtsx_usb.c @@ -29,7 +29,7 @@ static int polling_pipe = 1; module_param(polling_pipe, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(polling_pipe, "polling pipe (0: ctl, 1: bulk)"); -static struct mfd_cell rtsx_usb_cells[] = { +static const struct mfd_cell rtsx_usb_cells[] = { [RTSX_USB_SD_CARD] = { .name = "rtsx_usb_sdmmc", .pdata_size = 0, -- cgit v1.2.3-70-g09d2