forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/mmc/host/vub300.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Remote VUB300 SDIO/SDmem Host Controller Driver
34 *
....@@ -6,10 +7,6 @@
67 * based on USB Skeleton driver - 2.2
78 *
89 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License as
12
- * published by the Free Software Foundation, version 2
1310 *
1411 * VUB300: is a USB 2.0 client device with a single SDIO/SDmem/MMC slot
1512 * Any SDIO/SDmem/MMC device plugged into the VUB300 will appear,
....@@ -98,7 +95,7 @@
9895 u8 port_number;
9996 u8 command_type;
10097 u8 command_index;
101
- u8 command_response[0];
98
+ u8 command_response[];
10299 } __packed;
103100
104101 struct sd_status_header {
....@@ -1366,7 +1363,7 @@
13661363 int retval;
13671364 for (n = 0; n < sdio_funcs; n++) {
13681365 struct sdio_func *sf = card->sdio_func[n];
1369
- l += snprintf(vub300->vub_name + l,
1366
+ l += scnprintf(vub300->vub_name + l,
13701367 sizeof(vub300->vub_name) - l, "_%04X%04X",
13711368 sf->vendor, sf->device);
13721369 }
....@@ -1718,6 +1715,9 @@
17181715 int bytes = 3 & less_cmd;
17191716 int words = less_cmd >> 2;
17201717 u8 *r = vub300->resp.response.command_response;
1718
+
1719
+ if (!resp_len)
1720
+ return;
17211721 if (bytes == 3) {
17221722 cmd->resp[words] = (r[1 + (words << 2)] << 24)
17231723 | (r[2 + (words << 2)] << 16)
....@@ -2052,6 +2052,7 @@
20522052 return;
20532053 kref_get(&vub300->kref);
20542054 if (enable) {
2055
+ set_current_state(TASK_RUNNING);
20552056 mutex_lock(&vub300->irq_mutex);
20562057 if (vub300->irqs_queued) {
20572058 vub300->irqs_queued -= 1;
....@@ -2067,16 +2068,11 @@
20672068 vub300_queue_poll_work(vub300, 0);
20682069 }
20692070 mutex_unlock(&vub300->irq_mutex);
2071
+ set_current_state(TASK_INTERRUPTIBLE);
20702072 } else {
20712073 vub300->irq_enabled = 0;
20722074 }
20732075 kref_put(&vub300->kref, vub300_delete);
2074
-}
2075
-
2076
-static void vub300_init_card(struct mmc_host *mmc, struct mmc_card *card)
2077
-{ /* NOT irq */
2078
- struct vub300_mmc_host *vub300 = mmc_priv(mmc);
2079
- dev_info(&vub300->udev->dev, "NO host QUIRKS for this card\n");
20802076 }
20812077
20822078 static const struct mmc_host_ops vub300_mmc_ops = {
....@@ -2084,7 +2080,6 @@
20842080 .set_ios = vub300_mmc_set_ios,
20852081 .get_ro = vub300_mmc_get_ro,
20862082 .enable_sdio_irq = vub300_enable_sdio_irq,
2087
- .init_card = vub300_init_card,
20882083 };
20892084
20902085 static int vub300_probe(struct usb_interface *interface,
....@@ -2309,14 +2304,14 @@
23092304 0x0000, 0x0000, &vub300->system_port_status,
23102305 sizeof(vub300->system_port_status), 1000);
23112306 if (retval < 0) {
2312
- goto error4;
2307
+ goto error5;
23132308 } else if (sizeof(vub300->system_port_status) == retval) {
23142309 vub300->card_present =
23152310 (0x0001 & vub300->system_port_status.port_flags) ? 1 : 0;
23162311 vub300->read_only =
23172312 (0x0010 & vub300->system_port_status.port_flags) ? 1 : 0;
23182313 } else {
2319
- goto error4;
2314
+ goto error5;
23202315 }
23212316 usb_set_intfdata(interface, vub300);
23222317 INIT_DELAYED_WORK(&vub300->pollwork, vub300_pollwork_thread);
....@@ -2339,8 +2334,13 @@
23392334 "USB vub300 remote SDIO host controller[%d]"
23402335 "connected with no SD/SDIO card inserted\n",
23412336 interface_to_InterfaceNumber(interface));
2342
- mmc_add_host(mmc);
2337
+ retval = mmc_add_host(mmc);
2338
+ if (retval)
2339
+ goto error6;
2340
+
23432341 return 0;
2342
+error6:
2343
+ del_timer_sync(&vub300->inactivity_timer);
23442344 error5:
23452345 mmc_free_host(mmc);
23462346 /*