.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* Driver for Realtek USB card reader |
---|
2 | 3 | * |
---|
3 | 4 | * 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/>. |
---|
16 | 5 | * |
---|
17 | 6 | * Author: |
---|
18 | 7 | * Roger Tseng <rogerable@realtek.com> |
---|
.. | .. |
---|
642 | 631 | |
---|
643 | 632 | ucr->pusb_dev = usb_dev; |
---|
644 | 633 | |
---|
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) |
---|
648 | 636 | 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 | + } |
---|
649 | 643 | |
---|
650 | 644 | usb_set_intfdata(intf, ucr); |
---|
651 | 645 | |
---|
652 | 646 | ucr->vendor_id = id->idVendor; |
---|
653 | 647 | ucr->product_id = id->idProduct; |
---|
654 | | - ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf; |
---|
655 | 648 | |
---|
656 | 649 | mutex_init(&ucr->dev_mutex); |
---|
657 | 650 | |
---|
.. | .. |
---|
678 | 671 | return 0; |
---|
679 | 672 | |
---|
680 | 673 | 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; |
---|
683 | 680 | return ret; |
---|
684 | 681 | } |
---|
685 | 682 | |
---|
.. | .. |
---|
692 | 689 | mfd_remove_devices(&intf->dev); |
---|
693 | 690 | |
---|
694 | 691 | 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; |
---|
697 | 698 | } |
---|
698 | 699 | |
---|
699 | 700 | #ifdef CONFIG_PM |
---|
.. | .. |
---|
723 | 724 | return 0; |
---|
724 | 725 | } |
---|
725 | 726 | |
---|
| 727 | +static int rtsx_usb_resume_child(struct device *dev, void *data) |
---|
| 728 | +{ |
---|
| 729 | + pm_request_resume(dev); |
---|
| 730 | + return 0; |
---|
| 731 | +} |
---|
| 732 | + |
---|
726 | 733 | static int rtsx_usb_resume(struct usb_interface *intf) |
---|
727 | 734 | { |
---|
| 735 | + device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child); |
---|
728 | 736 | return 0; |
---|
729 | 737 | } |
---|
730 | 738 | |
---|
.. | .. |
---|
734 | 742 | (struct rtsx_ucr *)usb_get_intfdata(intf); |
---|
735 | 743 | |
---|
736 | 744 | rtsx_usb_reset_chip(ucr); |
---|
| 745 | + device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child); |
---|
737 | 746 | return 0; |
---|
738 | 747 | } |
---|
739 | 748 | |
---|
.. | .. |
---|
762 | 771 | return 0; |
---|
763 | 772 | } |
---|
764 | 773 | |
---|
765 | | -static struct usb_device_id rtsx_usb_usb_ids[] = { |
---|
| 774 | +static const struct usb_device_id rtsx_usb_usb_ids[] = { |
---|
766 | 775 | { USB_DEVICE(0x0BDA, 0x0129) }, |
---|
767 | 776 | { USB_DEVICE(0x0BDA, 0x0139) }, |
---|
768 | 777 | { USB_DEVICE(0x0BDA, 0x0140) }, |
---|