aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-06 20:31:29 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-06 20:31:29 -0500
commit8328258e745b80290534c9ab5bede6cd8340ea75 (patch)
treeb1904eb2841f9805e1bf6d524963ad6d9ec583e1
parent205c911da322908abe127b96d2ef2a4a2aa5109a (diff)
parenta715dfc7b9ef15ed5b398b185bd84cc015ff37f6 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc: sdhci: release irq during suspend sdhci: make isr tolerant of read errors mmc: require explicit support for high-speed ncpfs: make sure server connection survives a kill
-rw-r--r--drivers/mmc/mmc.c83
-rw-r--r--drivers/mmc/sdhci.c39
-rw-r--r--fs/ncpfs/inode.c16
-rw-r--r--fs/ncpfs/sock.c151
-rw-r--r--include/linux/mmc/host.h8
-rw-r--r--include/linux/ncp_fs_sb.h2
6 files changed, 184 insertions, 115 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 5046a1661342..4a73e8b2428d 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -376,10 +376,11 @@ static inline void mmc_set_ios(struct mmc_host *host)
376{ 376{
377 struct mmc_ios *ios = &host->ios; 377 struct mmc_ios *ios = &host->ios;
378 378
379 pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", 379 pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u "
380 "width %u timing %u\n",
380 mmc_hostname(host), ios->clock, ios->bus_mode, 381 mmc_hostname(host), ios->clock, ios->bus_mode,
381 ios->power_mode, ios->chip_select, ios->vdd, 382 ios->power_mode, ios->chip_select, ios->vdd,
382 ios->bus_width); 383 ios->bus_width, ios->timing);
383 384
384 host->ops->set_ios(host, ios); 385 host->ops->set_ios(host, ios);
385} 386}
@@ -809,6 +810,7 @@ static void mmc_power_up(struct mmc_host *host)
809 host->ios.chip_select = MMC_CS_DONTCARE; 810 host->ios.chip_select = MMC_CS_DONTCARE;
810 host->ios.power_mode = MMC_POWER_UP; 811 host->ios.power_mode = MMC_POWER_UP;
811 host->ios.bus_width = MMC_BUS_WIDTH_1; 812 host->ios.bus_width = MMC_BUS_WIDTH_1;
813 host->ios.timing = MMC_TIMING_LEGACY;
812 mmc_set_ios(host); 814 mmc_set_ios(host);
813 815
814 mmc_delay(1); 816 mmc_delay(1);
@@ -828,6 +830,7 @@ static void mmc_power_off(struct mmc_host *host)
828 host->ios.chip_select = MMC_CS_DONTCARE; 830 host->ios.chip_select = MMC_CS_DONTCARE;
829 host->ios.power_mode = MMC_POWER_OFF; 831 host->ios.power_mode = MMC_POWER_OFF;
830 host->ios.bus_width = MMC_BUS_WIDTH_1; 832 host->ios.bus_width = MMC_BUS_WIDTH_1;
833 host->ios.timing = MMC_TIMING_LEGACY;
831 mmc_set_ios(host); 834 mmc_set_ios(host);
832} 835}
833 836
@@ -1112,46 +1115,50 @@ static void mmc_process_ext_csds(struct mmc_host *host)
1112 continue; 1115 continue;
1113 } 1116 }
1114 1117
1115 /* Activate highspeed support. */ 1118 if (host->caps & MMC_CAP_MMC_HIGHSPEED) {
1116 cmd.opcode = MMC_SWITCH; 1119 /* Activate highspeed support. */
1117 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | 1120 cmd.opcode = MMC_SWITCH;
1118 (EXT_CSD_HS_TIMING << 16) | 1121 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1119 (1 << 8) | 1122 (EXT_CSD_HS_TIMING << 16) |
1120 EXT_CSD_CMD_SET_NORMAL; 1123 (1 << 8) |
1121 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; 1124 EXT_CSD_CMD_SET_NORMAL;
1125 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1122 1126
1123 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 1127 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1124 if (err != MMC_ERR_NONE) { 1128 if (err != MMC_ERR_NONE) {
1125 printk("%s: failed to switch card to mmc v4 " 1129 printk("%s: failed to switch card to mmc v4 "
1126 "high-speed mode.\n", 1130 "high-speed mode.\n",
1127 mmc_hostname(card->host)); 1131 mmc_hostname(card->host));
1128 continue; 1132 continue;
1129 } 1133 }
1130 1134
1131 mmc_card_set_highspeed(card); 1135 mmc_card_set_highspeed(card);
1132 1136
1133 /* Check for host support for wide-bus modes. */ 1137 host->ios.timing = MMC_TIMING_SD_HS;
1134 if (!(host->caps & MMC_CAP_4_BIT_DATA)) { 1138 mmc_set_ios(host);
1135 continue;
1136 } 1139 }
1137 1140
1138 /* Activate 4-bit support. */ 1141 /* Check for host support for wide-bus modes. */
1139 cmd.opcode = MMC_SWITCH; 1142 if (host->caps & MMC_CAP_4_BIT_DATA) {
1140 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | 1143 /* Activate 4-bit support. */
1141 (EXT_CSD_BUS_WIDTH << 16) | 1144 cmd.opcode = MMC_SWITCH;
1142 (EXT_CSD_BUS_WIDTH_4 << 8) | 1145 cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) |
1143 EXT_CSD_CMD_SET_NORMAL; 1146 (EXT_CSD_BUS_WIDTH << 16) |
1144 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; 1147 (EXT_CSD_BUS_WIDTH_4 << 8) |
1148 EXT_CSD_CMD_SET_NORMAL;
1149 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
1145 1150
1146 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 1151 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
1147 if (err != MMC_ERR_NONE) { 1152 if (err != MMC_ERR_NONE) {
1148 printk("%s: failed to switch card to " 1153 printk("%s: failed to switch card to "
1149 "mmc v4 4-bit bus mode.\n", 1154 "mmc v4 4-bit bus mode.\n",
1150 mmc_hostname(card->host)); 1155 mmc_hostname(card->host));
1151 continue; 1156 continue;
1152 } 1157 }
1153 1158
1154 host->ios.bus_width = MMC_BUS_WIDTH_4; 1159 host->ios.bus_width = MMC_BUS_WIDTH_4;
1160 mmc_set_ios(host);
1161 }
1155 } 1162 }
1156 1163
1157 kfree(ext_csd); 1164 kfree(ext_csd);
@@ -1241,6 +1248,9 @@ static void mmc_read_switch_caps(struct mmc_host *host)
1241 unsigned char *status; 1248 unsigned char *status;
1242 struct scatterlist sg; 1249 struct scatterlist sg;
1243 1250
1251 if (!(host->caps & MMC_CAP_SD_HIGHSPEED))
1252 return;
1253
1244 status = kmalloc(64, GFP_KERNEL); 1254 status = kmalloc(64, GFP_KERNEL);
1245 if (!status) { 1255 if (!status) {
1246 printk(KERN_WARNING "%s: Unable to allocate buffer for " 1256 printk(KERN_WARNING "%s: Unable to allocate buffer for "
@@ -1332,6 +1342,9 @@ static void mmc_read_switch_caps(struct mmc_host *host)
1332 } 1342 }
1333 1343
1334 mmc_card_set_highspeed(card); 1344 mmc_card_set_highspeed(card);
1345
1346 host->ios.timing = MMC_TIMING_SD_HS;
1347 mmc_set_ios(host);
1335 } 1348 }
1336 1349
1337 kfree(status); 1350 kfree(status);
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 7522f76b15ec..d749f08601b8 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -606,7 +606,6 @@ static void sdhci_finish_command(struct sdhci_host *host)
606static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 606static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
607{ 607{
608 int div; 608 int div;
609 u8 ctrl;
610 u16 clk; 609 u16 clk;
611 unsigned long timeout; 610 unsigned long timeout;
612 611
@@ -615,13 +614,6 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
615 614
616 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); 615 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
617 616
618 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
619 if (clock > 25000000)
620 ctrl |= SDHCI_CTRL_HISPD;
621 else
622 ctrl &= ~SDHCI_CTRL_HISPD;
623 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
624
625 if (clock == 0) 617 if (clock == 0)
626 goto out; 618 goto out;
627 619
@@ -761,10 +753,17 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
761 sdhci_set_power(host, ios->vdd); 753 sdhci_set_power(host, ios->vdd);
762 754
763 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL); 755 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
756
764 if (ios->bus_width == MMC_BUS_WIDTH_4) 757 if (ios->bus_width == MMC_BUS_WIDTH_4)
765 ctrl |= SDHCI_CTRL_4BITBUS; 758 ctrl |= SDHCI_CTRL_4BITBUS;
766 else 759 else
767 ctrl &= ~SDHCI_CTRL_4BITBUS; 760 ctrl &= ~SDHCI_CTRL_4BITBUS;
761
762 if (ios->timing == MMC_TIMING_SD_HS)
763 ctrl |= SDHCI_CTRL_HISPD;
764 else
765 ctrl &= ~SDHCI_CTRL_HISPD;
766
768 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); 767 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
769 768
770 mmiowb(); 769 mmiowb();
@@ -994,7 +993,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
994 993
995 intmask = readl(host->ioaddr + SDHCI_INT_STATUS); 994 intmask = readl(host->ioaddr + SDHCI_INT_STATUS);
996 995
997 if (!intmask) { 996 if (!intmask || intmask == 0xffffffff) {
998 result = IRQ_NONE; 997 result = IRQ_NONE;
999 goto out; 998 goto out;
1000 } 999 }
@@ -1080,6 +1079,13 @@ static int sdhci_suspend (struct pci_dev *pdev, pm_message_t state)
1080 1079
1081 pci_save_state(pdev); 1080 pci_save_state(pdev);
1082 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); 1081 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
1082
1083 for (i = 0;i < chip->num_slots;i++) {
1084 if (!chip->hosts[i])
1085 continue;
1086 free_irq(chip->hosts[i]->irq, chip->hosts[i]);
1087 }
1088
1083 pci_disable_device(pdev); 1089 pci_disable_device(pdev);
1084 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 1090 pci_set_power_state(pdev, pci_choose_state(pdev, state));
1085 1091
@@ -1108,6 +1114,11 @@ static int sdhci_resume (struct pci_dev *pdev)
1108 continue; 1114 continue;
1109 if (chip->hosts[i]->flags & SDHCI_USE_DMA) 1115 if (chip->hosts[i]->flags & SDHCI_USE_DMA)
1110 pci_set_master(pdev); 1116 pci_set_master(pdev);
1117 ret = request_irq(chip->hosts[i]->irq, sdhci_irq,
1118 IRQF_SHARED, chip->hosts[i]->slot_descr,
1119 chip->hosts[i]);
1120 if (ret)
1121 return ret;
1111 sdhci_init(chip->hosts[i]); 1122 sdhci_init(chip->hosts[i]);
1112 mmiowb(); 1123 mmiowb();
1113 ret = mmc_resume_host(chip->hosts[i]->mmc); 1124 ret = mmc_resume_host(chip->hosts[i]->mmc);
@@ -1274,6 +1285,9 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1274 mmc->f_max = host->max_clk; 1285 mmc->f_max = host->max_clk;
1275 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE | MMC_CAP_BYTEBLOCK; 1286 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE | MMC_CAP_BYTEBLOCK;
1276 1287
1288 if (caps & SDHCI_CAN_DO_HISPD)
1289 mmc->caps |= MMC_CAP_SD_HIGHSPEED;
1290
1277 mmc->ocr_avail = 0; 1291 mmc->ocr_avail = 0;
1278 if (caps & SDHCI_CAN_VDD_330) 1292 if (caps & SDHCI_CAN_VDD_330)
1279 mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34; 1293 mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34;
@@ -1282,13 +1296,6 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1282 if (caps & SDHCI_CAN_VDD_180) 1296 if (caps & SDHCI_CAN_VDD_180)
1283 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19; 1297 mmc->ocr_avail |= MMC_VDD_17_18|MMC_VDD_18_19;
1284 1298
1285 if ((host->max_clk > 25000000) && !(caps & SDHCI_CAN_DO_HISPD)) {
1286 printk(KERN_ERR "%s: Controller reports > 25 MHz base clock,"
1287 " but no high speed support.\n",
1288 host->slot_descr);
1289 mmc->f_max = 25000000;
1290 }
1291
1292 if (mmc->ocr_avail == 0) { 1299 if (mmc->ocr_avail == 0) {
1293 printk(KERN_ERR "%s: Hardware doesn't report any " 1300 printk(KERN_ERR "%s: Hardware doesn't report any "
1294 "support voltages.\n", host->slot_descr); 1301 "support voltages.\n", host->slot_descr);
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 14939ddf74f1..7285c94956c4 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -576,6 +576,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
576 server->packet = vmalloc(NCP_PACKET_SIZE); 576 server->packet = vmalloc(NCP_PACKET_SIZE);
577 if (server->packet == NULL) 577 if (server->packet == NULL)
578 goto out_nls; 578 goto out_nls;
579 server->txbuf = vmalloc(NCP_PACKET_SIZE);
580 if (server->txbuf == NULL)
581 goto out_packet;
582 server->rxbuf = vmalloc(NCP_PACKET_SIZE);
583 if (server->rxbuf == NULL)
584 goto out_txbuf;
579 585
580 sock->sk->sk_data_ready = ncp_tcp_data_ready; 586 sock->sk->sk_data_ready = ncp_tcp_data_ready;
581 sock->sk->sk_error_report = ncp_tcp_error_report; 587 sock->sk->sk_error_report = ncp_tcp_error_report;
@@ -597,7 +603,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
597 error = ncp_connect(server); 603 error = ncp_connect(server);
598 ncp_unlock_server(server); 604 ncp_unlock_server(server);
599 if (error < 0) 605 if (error < 0)
600 goto out_packet; 606 goto out_rxbuf;
601 DPRINTK("ncp_fill_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb)); 607 DPRINTK("ncp_fill_super: NCP_SBP(sb) = %x\n", (int) NCP_SBP(sb));
602 608
603 error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */ 609 error = -EMSGSIZE; /* -EREMOTESIDEINCOMPATIBLE */
@@ -666,8 +672,12 @@ out_disconnect:
666 ncp_lock_server(server); 672 ncp_lock_server(server);
667 ncp_disconnect(server); 673 ncp_disconnect(server);
668 ncp_unlock_server(server); 674 ncp_unlock_server(server);
669out_packet: 675out_rxbuf:
670 ncp_stop_tasks(server); 676 ncp_stop_tasks(server);
677 vfree(server->rxbuf);
678out_txbuf:
679 vfree(server->txbuf);
680out_packet:
671 vfree(server->packet); 681 vfree(server->packet);
672out_nls: 682out_nls:
673#ifdef CONFIG_NCPFS_NLS 683#ifdef CONFIG_NCPFS_NLS
@@ -723,6 +733,8 @@ static void ncp_put_super(struct super_block *sb)
723 733
724 kfree(server->priv.data); 734 kfree(server->priv.data);
725 kfree(server->auth.object_name); 735 kfree(server->auth.object_name);
736 vfree(server->rxbuf);
737 vfree(server->txbuf);
726 vfree(server->packet); 738 vfree(server->packet);
727 sb->s_fs_info = NULL; 739 sb->s_fs_info = NULL;
728 kfree(server); 740 kfree(server);
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index e496d8b65e92..e37df8d5fe70 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -14,6 +14,7 @@
14#include <linux/socket.h> 14#include <linux/socket.h>
15#include <linux/fcntl.h> 15#include <linux/fcntl.h>
16#include <linux/stat.h> 16#include <linux/stat.h>
17#include <linux/string.h>
17#include <asm/uaccess.h> 18#include <asm/uaccess.h>
18#include <linux/in.h> 19#include <linux/in.h>
19#include <linux/net.h> 20#include <linux/net.h>
@@ -55,10 +56,11 @@ static int _send(struct socket *sock, const void *buff, int len)
55struct ncp_request_reply { 56struct ncp_request_reply {
56 struct list_head req; 57 struct list_head req;
57 wait_queue_head_t wq; 58 wait_queue_head_t wq;
58 struct ncp_reply_header* reply_buf; 59 atomic_t refs;
60 unsigned char* reply_buf;
59 size_t datalen; 61 size_t datalen;
60 int result; 62 int result;
61 enum { RQ_DONE, RQ_INPROGRESS, RQ_QUEUED, RQ_IDLE } status; 63 enum { RQ_DONE, RQ_INPROGRESS, RQ_QUEUED, RQ_IDLE, RQ_ABANDONED } status;
62 struct kvec* tx_ciov; 64 struct kvec* tx_ciov;
63 size_t tx_totallen; 65 size_t tx_totallen;
64 size_t tx_iovlen; 66 size_t tx_iovlen;
@@ -67,6 +69,32 @@ struct ncp_request_reply {
67 u_int32_t sign[6]; 69 u_int32_t sign[6];
68}; 70};
69 71
72static inline struct ncp_request_reply* ncp_alloc_req(void)
73{
74 struct ncp_request_reply *req;
75
76 req = kmalloc(sizeof(struct ncp_request_reply), GFP_KERNEL);
77 if (!req)
78 return NULL;
79
80 init_waitqueue_head(&req->wq);
81 atomic_set(&req->refs, (1));
82 req->status = RQ_IDLE;
83
84 return req;
85}
86
87static void ncp_req_get(struct ncp_request_reply *req)
88{
89 atomic_inc(&req->refs);
90}
91
92static void ncp_req_put(struct ncp_request_reply *req)
93{
94 if (atomic_dec_and_test(&req->refs))
95 kfree(req);
96}
97
70void ncp_tcp_data_ready(struct sock *sk, int len) 98void ncp_tcp_data_ready(struct sock *sk, int len)
71{ 99{
72 struct ncp_server *server = sk->sk_user_data; 100 struct ncp_server *server = sk->sk_user_data;
@@ -101,14 +129,17 @@ void ncpdgram_timeout_call(unsigned long v)
101 schedule_work(&server->timeout_tq); 129 schedule_work(&server->timeout_tq);
102} 130}
103 131
104static inline void ncp_finish_request(struct ncp_request_reply *req, int result) 132static inline void ncp_finish_request(struct ncp_server *server, struct ncp_request_reply *req, int result)
105{ 133{
106 req->result = result; 134 req->result = result;
135 if (req->status != RQ_ABANDONED)
136 memcpy(req->reply_buf, server->rxbuf, req->datalen);
107 req->status = RQ_DONE; 137 req->status = RQ_DONE;
108 wake_up_all(&req->wq); 138 wake_up_all(&req->wq);
139 ncp_req_put(req);
109} 140}
110 141
111static void __abort_ncp_connection(struct ncp_server *server, struct ncp_request_reply *aborted, int err) 142static void __abort_ncp_connection(struct ncp_server *server)
112{ 143{
113 struct ncp_request_reply *req; 144 struct ncp_request_reply *req;
114 145
@@ -118,31 +149,19 @@ static void __abort_ncp_connection(struct ncp_server *server, struct ncp_request
118 req = list_entry(server->tx.requests.next, struct ncp_request_reply, req); 149 req = list_entry(server->tx.requests.next, struct ncp_request_reply, req);
119 150
120 list_del_init(&req->req); 151 list_del_init(&req->req);
121 if (req == aborted) { 152 ncp_finish_request(server, req, -EIO);
122 ncp_finish_request(req, err);
123 } else {
124 ncp_finish_request(req, -EIO);
125 }
126 } 153 }
127 req = server->rcv.creq; 154 req = server->rcv.creq;
128 if (req) { 155 if (req) {
129 server->rcv.creq = NULL; 156 server->rcv.creq = NULL;
130 if (req == aborted) { 157 ncp_finish_request(server, req, -EIO);
131 ncp_finish_request(req, err);
132 } else {
133 ncp_finish_request(req, -EIO);
134 }
135 server->rcv.ptr = NULL; 158 server->rcv.ptr = NULL;
136 server->rcv.state = 0; 159 server->rcv.state = 0;
137 } 160 }
138 req = server->tx.creq; 161 req = server->tx.creq;
139 if (req) { 162 if (req) {
140 server->tx.creq = NULL; 163 server->tx.creq = NULL;
141 if (req == aborted) { 164 ncp_finish_request(server, req, -EIO);
142 ncp_finish_request(req, err);
143 } else {
144 ncp_finish_request(req, -EIO);
145 }
146 } 165 }
147} 166}
148 167
@@ -160,10 +179,12 @@ static inline void __ncp_abort_request(struct ncp_server *server, struct ncp_req
160 break; 179 break;
161 case RQ_QUEUED: 180 case RQ_QUEUED:
162 list_del_init(&req->req); 181 list_del_init(&req->req);
163 ncp_finish_request(req, err); 182 ncp_finish_request(server, req, err);
164 break; 183 break;
165 case RQ_INPROGRESS: 184 case RQ_INPROGRESS:
166 __abort_ncp_connection(server, req, err); 185 req->status = RQ_ABANDONED;
186 break;
187 case RQ_ABANDONED:
167 break; 188 break;
168 } 189 }
169} 190}
@@ -177,7 +198,7 @@ static inline void ncp_abort_request(struct ncp_server *server, struct ncp_reque
177 198
178static inline void __ncptcp_abort(struct ncp_server *server) 199static inline void __ncptcp_abort(struct ncp_server *server)
179{ 200{
180 __abort_ncp_connection(server, NULL, 0); 201 __abort_ncp_connection(server);
181} 202}
182 203
183static int ncpdgram_send(struct socket *sock, struct ncp_request_reply *req) 204static int ncpdgram_send(struct socket *sock, struct ncp_request_reply *req)
@@ -294,6 +315,11 @@ static void ncptcp_start_request(struct ncp_server *server, struct ncp_request_r
294 315
295static inline void __ncp_start_request(struct ncp_server *server, struct ncp_request_reply *req) 316static inline void __ncp_start_request(struct ncp_server *server, struct ncp_request_reply *req)
296{ 317{
318 /* we copy the data so that we do not depend on the caller
319 staying alive */
320 memcpy(server->txbuf, req->tx_iov[1].iov_base, req->tx_iov[1].iov_len);
321 req->tx_iov[1].iov_base = server->txbuf;
322
297 if (server->ncp_sock->type == SOCK_STREAM) 323 if (server->ncp_sock->type == SOCK_STREAM)
298 ncptcp_start_request(server, req); 324 ncptcp_start_request(server, req);
299 else 325 else
@@ -308,6 +334,7 @@ static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *
308 printk(KERN_ERR "ncpfs: tcp: Server died\n"); 334 printk(KERN_ERR "ncpfs: tcp: Server died\n");
309 return -EIO; 335 return -EIO;
310 } 336 }
337 ncp_req_get(req);
311 if (server->tx.creq || server->rcv.creq) { 338 if (server->tx.creq || server->rcv.creq) {
312 req->status = RQ_QUEUED; 339 req->status = RQ_QUEUED;
313 list_add_tail(&req->req, &server->tx.requests); 340 list_add_tail(&req->req, &server->tx.requests);
@@ -409,7 +436,7 @@ void ncpdgram_rcv_proc(struct work_struct *work)
409 server->timeout_last = NCP_MAX_RPC_TIMEOUT; 436 server->timeout_last = NCP_MAX_RPC_TIMEOUT;
410 mod_timer(&server->timeout_tm, jiffies + NCP_MAX_RPC_TIMEOUT); 437 mod_timer(&server->timeout_tm, jiffies + NCP_MAX_RPC_TIMEOUT);
411 } else if (reply.type == NCP_REPLY) { 438 } else if (reply.type == NCP_REPLY) {
412 result = _recv(sock, (void*)req->reply_buf, req->datalen, MSG_DONTWAIT); 439 result = _recv(sock, server->rxbuf, req->datalen, MSG_DONTWAIT);
413#ifdef CONFIG_NCPFS_PACKET_SIGNING 440#ifdef CONFIG_NCPFS_PACKET_SIGNING
414 if (result >= 0 && server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { 441 if (result >= 0 && server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) {
415 if (result < 8 + 8) { 442 if (result < 8 + 8) {
@@ -419,7 +446,7 @@ void ncpdgram_rcv_proc(struct work_struct *work)
419 446
420 result -= 8; 447 result -= 8;
421 hdrl = sock->sk->sk_family == AF_INET ? 8 : 6; 448 hdrl = sock->sk->sk_family == AF_INET ? 8 : 6;
422 if (sign_verify_reply(server, ((char*)req->reply_buf) + hdrl, result - hdrl, cpu_to_le32(result), ((char*)req->reply_buf) + result)) { 449 if (sign_verify_reply(server, server->rxbuf + hdrl, result - hdrl, cpu_to_le32(result), server->rxbuf + result)) {
423 printk(KERN_INFO "ncpfs: Signature violation\n"); 450 printk(KERN_INFO "ncpfs: Signature violation\n");
424 result = -EIO; 451 result = -EIO;
425 } 452 }
@@ -428,7 +455,7 @@ void ncpdgram_rcv_proc(struct work_struct *work)
428#endif 455#endif
429 del_timer(&server->timeout_tm); 456 del_timer(&server->timeout_tm);
430 server->rcv.creq = NULL; 457 server->rcv.creq = NULL;
431 ncp_finish_request(req, result); 458 ncp_finish_request(server, req, result);
432 __ncp_next_request(server); 459 __ncp_next_request(server);
433 mutex_unlock(&server->rcv.creq_mutex); 460 mutex_unlock(&server->rcv.creq_mutex);
434 continue; 461 continue;
@@ -478,12 +505,6 @@ void ncpdgram_timeout_proc(struct work_struct *work)
478 mutex_unlock(&server->rcv.creq_mutex); 505 mutex_unlock(&server->rcv.creq_mutex);
479} 506}
480 507
481static inline void ncp_init_req(struct ncp_request_reply* req)
482{
483 init_waitqueue_head(&req->wq);
484 req->status = RQ_IDLE;
485}
486
487static int do_tcp_rcv(struct ncp_server *server, void *buffer, size_t len) 508static int do_tcp_rcv(struct ncp_server *server, void *buffer, size_t len)
488{ 509{
489 int result; 510 int result;
@@ -601,8 +622,8 @@ skipdata:;
601 goto skipdata; 622 goto skipdata;
602 } 623 }
603 req->datalen = datalen - 8; 624 req->datalen = datalen - 8;
604 req->reply_buf->type = NCP_REPLY; 625 ((struct ncp_reply_header*)server->rxbuf)->type = NCP_REPLY;
605 server->rcv.ptr = (unsigned char*)(req->reply_buf) + 2; 626 server->rcv.ptr = server->rxbuf + 2;
606 server->rcv.len = datalen - 10; 627 server->rcv.len = datalen - 10;
607 server->rcv.state = 1; 628 server->rcv.state = 1;
608 break; 629 break;
@@ -615,12 +636,12 @@ skipdata:;
615 case 1: 636 case 1:
616 req = server->rcv.creq; 637 req = server->rcv.creq;
617 if (req->tx_type != NCP_ALLOC_SLOT_REQUEST) { 638 if (req->tx_type != NCP_ALLOC_SLOT_REQUEST) {
618 if (req->reply_buf->sequence != server->sequence) { 639 if (((struct ncp_reply_header*)server->rxbuf)->sequence != server->sequence) {
619 printk(KERN_ERR "ncpfs: tcp: Bad sequence number\n"); 640 printk(KERN_ERR "ncpfs: tcp: Bad sequence number\n");
620 __ncp_abort_request(server, req, -EIO); 641 __ncp_abort_request(server, req, -EIO);
621 return -EIO; 642 return -EIO;
622 } 643 }
623 if ((req->reply_buf->conn_low | (req->reply_buf->conn_high << 8)) != server->connection) { 644 if ((((struct ncp_reply_header*)server->rxbuf)->conn_low | (((struct ncp_reply_header*)server->rxbuf)->conn_high << 8)) != server->connection) {
624 printk(KERN_ERR "ncpfs: tcp: Connection number mismatch\n"); 645 printk(KERN_ERR "ncpfs: tcp: Connection number mismatch\n");
625 __ncp_abort_request(server, req, -EIO); 646 __ncp_abort_request(server, req, -EIO);
626 return -EIO; 647 return -EIO;
@@ -628,14 +649,14 @@ skipdata:;
628 } 649 }
629#ifdef CONFIG_NCPFS_PACKET_SIGNING 650#ifdef CONFIG_NCPFS_PACKET_SIGNING
630 if (server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) { 651 if (server->sign_active && req->tx_type != NCP_DEALLOC_SLOT_REQUEST) {
631 if (sign_verify_reply(server, (unsigned char*)(req->reply_buf) + 6, req->datalen - 6, cpu_to_be32(req->datalen + 16), &server->rcv.buf.type)) { 652 if (sign_verify_reply(server, server->rxbuf + 6, req->datalen - 6, cpu_to_be32(req->datalen + 16), &server->rcv.buf.type)) {
632 printk(KERN_ERR "ncpfs: tcp: Signature violation\n"); 653 printk(KERN_ERR "ncpfs: tcp: Signature violation\n");
633 __ncp_abort_request(server, req, -EIO); 654 __ncp_abort_request(server, req, -EIO);
634 return -EIO; 655 return -EIO;
635 } 656 }
636 } 657 }
637#endif 658#endif
638 ncp_finish_request(req, req->datalen); 659 ncp_finish_request(server, req, req->datalen);
639 nextreq:; 660 nextreq:;
640 __ncp_next_request(server); 661 __ncp_next_request(server);
641 case 2: 662 case 2:
@@ -645,7 +666,7 @@ skipdata:;
645 server->rcv.state = 0; 666 server->rcv.state = 0;
646 break; 667 break;
647 case 3: 668 case 3:
648 ncp_finish_request(server->rcv.creq, -EIO); 669 ncp_finish_request(server, server->rcv.creq, -EIO);
649 goto nextreq; 670 goto nextreq;
650 case 5: 671 case 5:
651 info_server(server, 0, server->unexpected_packet.data, server->unexpected_packet.len); 672 info_server(server, 0, server->unexpected_packet.data, server->unexpected_packet.len);
@@ -675,28 +696,39 @@ void ncp_tcp_tx_proc(struct work_struct *work)
675} 696}
676 697
677static int do_ncp_rpc_call(struct ncp_server *server, int size, 698static int do_ncp_rpc_call(struct ncp_server *server, int size,
678 struct ncp_reply_header* reply_buf, int max_reply_size) 699 unsigned char* reply_buf, int max_reply_size)
679{ 700{
680 int result; 701 int result;
681 struct ncp_request_reply req; 702 struct ncp_request_reply *req;
682 703
683 ncp_init_req(&req); 704 req = ncp_alloc_req();
684 req.reply_buf = reply_buf; 705 if (!req)
685 req.datalen = max_reply_size; 706 return -ENOMEM;
686 req.tx_iov[1].iov_base = server->packet; 707
687 req.tx_iov[1].iov_len = size; 708 req->reply_buf = reply_buf;
688 req.tx_iovlen = 1; 709 req->datalen = max_reply_size;
689 req.tx_totallen = size; 710 req->tx_iov[1].iov_base = server->packet;
690 req.tx_type = *(u_int16_t*)server->packet; 711 req->tx_iov[1].iov_len = size;
691 712 req->tx_iovlen = 1;
692 result = ncp_add_request(server, &req); 713 req->tx_totallen = size;
693 if (result < 0) { 714 req->tx_type = *(u_int16_t*)server->packet;
694 return result; 715
695 } 716 result = ncp_add_request(server, req);
696 if (wait_event_interruptible(req.wq, req.status == RQ_DONE)) { 717 if (result < 0)
697 ncp_abort_request(server, &req, -EIO); 718 goto out;
719
720 if (wait_event_interruptible(req->wq, req->status == RQ_DONE)) {
721 ncp_abort_request(server, req, -EINTR);
722 result = -EINTR;
723 goto out;
698 } 724 }
699 return req.result; 725
726 result = req->result;
727
728out:
729 ncp_req_put(req);
730
731 return result;
700} 732}
701 733
702/* 734/*
@@ -751,11 +783,6 @@ static int ncp_do_request(struct ncp_server *server, int size,
751 783
752 DDPRINTK("do_ncp_rpc_call returned %d\n", result); 784 DDPRINTK("do_ncp_rpc_call returned %d\n", result);
753 785
754 if (result < 0) {
755 /* There was a problem with I/O, so the connections is
756 * no longer usable. */
757 ncp_invalidate_conn(server);
758 }
759 return result; 786 return result;
760} 787}
761 788
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 913e5752569f..bfcef8a1ad8b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -62,6 +62,12 @@ struct mmc_ios {
62 62
63#define MMC_BUS_WIDTH_1 0 63#define MMC_BUS_WIDTH_1 0
64#define MMC_BUS_WIDTH_4 2 64#define MMC_BUS_WIDTH_4 2
65
66 unsigned char timing; /* timing specification used */
67
68#define MMC_TIMING_LEGACY 0
69#define MMC_TIMING_MMC_HS 1
70#define MMC_TIMING_SD_HS 2
65}; 71};
66 72
67struct mmc_host_ops { 73struct mmc_host_ops {
@@ -87,6 +93,8 @@ struct mmc_host {
87#define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */ 93#define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */
88#define MMC_CAP_MULTIWRITE (1 << 1) /* Can accurately report bytes sent to card on error */ 94#define MMC_CAP_MULTIWRITE (1 << 1) /* Can accurately report bytes sent to card on error */
89#define MMC_CAP_BYTEBLOCK (1 << 2) /* Can do non-log2 block sizes */ 95#define MMC_CAP_BYTEBLOCK (1 << 2) /* Can do non-log2 block sizes */
96#define MMC_CAP_MMC_HIGHSPEED (1 << 3) /* Can do MMC high-speed timing */
97#define MMC_CAP_SD_HIGHSPEED (1 << 4) /* Can do SD high-speed timing */
90 98
91 /* host specific block data */ 99 /* host specific block data */
92 unsigned int max_seg_size; /* see blk_queue_max_segment_size */ 100 unsigned int max_seg_size; /* see blk_queue_max_segment_size */
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
index a503052138bd..6330fc76b00f 100644
--- a/include/linux/ncp_fs_sb.h
+++ b/include/linux/ncp_fs_sb.h
@@ -50,6 +50,8 @@ struct ncp_server {
50 int packet_size; 50 int packet_size;
51 unsigned char *packet; /* Here we prepare requests and 51 unsigned char *packet; /* Here we prepare requests and
52 receive replies */ 52 receive replies */
53 unsigned char *txbuf; /* Storage for current request */
54 unsigned char *rxbuf; /* Storage for reply to current request */
53 55
54 int lock; /* To prevent mismatch in protocols. */ 56 int lock; /* To prevent mismatch in protocols. */
55 struct mutex mutex; 57 struct mutex mutex;