hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/misc/cardreader/rtsx_usb.c
....@@ -1,18 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* Driver for Realtek USB card reader
23 *
34 * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2
7
- * as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but
10
- * WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- * General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along
15
- * with this program; if not, see <http://www.gnu.org/licenses/>.
165 *
176 * Author:
187 * Roger Tseng <rogerable@realtek.com>
....@@ -642,16 +631,20 @@
642631
643632 ucr->pusb_dev = usb_dev;
644633
645
- ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE,
646
- GFP_KERNEL, &ucr->iobuf_dma);
647
- if (!ucr->iobuf)
634
+ ucr->cmd_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL);
635
+ if (!ucr->cmd_buf)
648636 return -ENOMEM;
637
+
638
+ ucr->rsp_buf = kmalloc(IOBUF_SIZE, GFP_KERNEL);
639
+ if (!ucr->rsp_buf) {
640
+ ret = -ENOMEM;
641
+ goto out_free_cmd_buf;
642
+ }
649643
650644 usb_set_intfdata(intf, ucr);
651645
652646 ucr->vendor_id = id->idVendor;
653647 ucr->product_id = id->idProduct;
654
- ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf;
655648
656649 mutex_init(&ucr->dev_mutex);
657650
....@@ -678,8 +671,12 @@
678671 return 0;
679672
680673 out_init_fail:
681
- usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
682
- ucr->iobuf_dma);
674
+ usb_set_intfdata(ucr->pusb_intf, NULL);
675
+ kfree(ucr->rsp_buf);
676
+ ucr->rsp_buf = NULL;
677
+out_free_cmd_buf:
678
+ kfree(ucr->cmd_buf);
679
+ ucr->cmd_buf = NULL;
683680 return ret;
684681 }
685682
....@@ -692,8 +689,12 @@
692689 mfd_remove_devices(&intf->dev);
693690
694691 usb_set_intfdata(ucr->pusb_intf, NULL);
695
- usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
696
- ucr->iobuf_dma);
692
+
693
+ kfree(ucr->cmd_buf);
694
+ ucr->cmd_buf = NULL;
695
+
696
+ kfree(ucr->rsp_buf);
697
+ ucr->rsp_buf = NULL;
697698 }
698699
699700 #ifdef CONFIG_PM
....@@ -723,8 +724,15 @@
723724 return 0;
724725 }
725726
727
+static int rtsx_usb_resume_child(struct device *dev, void *data)
728
+{
729
+ pm_request_resume(dev);
730
+ return 0;
731
+}
732
+
726733 static int rtsx_usb_resume(struct usb_interface *intf)
727734 {
735
+ device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
728736 return 0;
729737 }
730738
....@@ -734,6 +742,7 @@
734742 (struct rtsx_ucr *)usb_get_intfdata(intf);
735743
736744 rtsx_usb_reset_chip(ucr);
745
+ device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
737746 return 0;
738747 }
739748
....@@ -762,7 +771,7 @@
762771 return 0;
763772 }
764773
765
-static struct usb_device_id rtsx_usb_usb_ids[] = {
774
+static const struct usb_device_id rtsx_usb_usb_ids[] = {
766775 { USB_DEVICE(0x0BDA, 0x0129) },
767776 { USB_DEVICE(0x0BDA, 0x0139) },
768777 { USB_DEVICE(0x0BDA, 0x0140) },