aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-24 00:36:13 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-08-24 00:36:13 -0400
commit1ff6f3dbfb366b464869d3558406e498cb3e1159 (patch)
tree3265b96ac28c297adc6f24b1fb22454aa9b7b1ac
parent2b56fec64faae9fc5c3e61bbfb851b7985292cd5 (diff)
parentb67ac3f339c76dfea3cc75fc0285b6d13edc35fa (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: tell which spurious interrupt we got sdhci: handle data interrupts during command mmc: ignore bad max block size in sdhci sdhci: be more cautious about block count register drivers/mmc/core/host.c: kmalloc + memset conversion to kzalloc drivers/mmc/core/bus.c: kmalloc + memset conversion to kzalloc
-rw-r--r--drivers/mmc/core/bus.c4
-rw-r--r--drivers/mmc/core/host.c4
-rw-r--r--drivers/mmc/host/sdhci.c53
-rw-r--r--drivers/mmc/host/sdhci.h1
4 files changed, 36 insertions, 26 deletions
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index fe0e785ed7d2..817a79462b3d 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -186,12 +186,10 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host)
186{ 186{
187 struct mmc_card *card; 187 struct mmc_card *card;
188 188
189 card = kmalloc(sizeof(struct mmc_card), GFP_KERNEL); 189 card = kzalloc(sizeof(struct mmc_card), GFP_KERNEL);
190 if (!card) 190 if (!card)
191 return ERR_PTR(-ENOMEM); 191 return ERR_PTR(-ENOMEM);
192 192
193 memset(card, 0, sizeof(struct mmc_card));
194
195 card->host = host; 193 card->host = host;
196 194
197 device_initialize(&card->dev); 195 device_initialize(&card->dev);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6a7e29849603..2c7ce8f43a9a 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -58,12 +58,10 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
58{ 58{
59 struct mmc_host *host; 59 struct mmc_host *host;
60 60
61 host = kmalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); 61 host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
62 if (!host) 62 if (!host)
63 return NULL; 63 return NULL;
64 64
65 memset(host, 0, sizeof(struct mmc_host) + extra);
66
67 host->parent = dev; 65 host->parent = dev;
68 host->class_dev.parent = dev; 66 host->class_dev.parent = dev;
69 host->class_dev.class = &mmc_host_class; 67 host->class_dev.class = &mmc_host_class;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f2bc87ac24f7..20a7d89e01ba 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -385,6 +385,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
385 BUG_ON(data->blksz > host->mmc->max_blk_size); 385 BUG_ON(data->blksz > host->mmc->max_blk_size);
386 BUG_ON(data->blocks > 65535); 386 BUG_ON(data->blocks > 65535);
387 387
388 host->data = data;
389 host->data_early = 0;
390
388 /* timeout in us */ 391 /* timeout in us */
389 target_timeout = data->timeout_ns / 1000 + 392 target_timeout = data->timeout_ns / 1000 +
390 data->timeout_clks / host->clock; 393 data->timeout_clks / host->clock;
@@ -443,11 +446,11 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
443{ 446{
444 u16 mode; 447 u16 mode;
445 448
446 WARN_ON(host->data);
447
448 if (data == NULL) 449 if (data == NULL)
449 return; 450 return;
450 451
452 WARN_ON(!host->data);
453
451 mode = SDHCI_TRNS_BLK_CNT_EN; 454 mode = SDHCI_TRNS_BLK_CNT_EN;
452 if (data->blocks > 1) 455 if (data->blocks > 1)
453 mode |= SDHCI_TRNS_MULTI; 456 mode |= SDHCI_TRNS_MULTI;
@@ -477,8 +480,8 @@ static void sdhci_finish_data(struct sdhci_host *host)
477 /* 480 /*
478 * Controller doesn't count down when in single block mode. 481 * Controller doesn't count down when in single block mode.
479 */ 482 */
480 if ((data->blocks == 1) && (data->error == MMC_ERR_NONE)) 483 if (data->blocks == 1)
481 blocks = 0; 484 blocks = (data->error == MMC_ERR_NONE) ? 0 : 1;
482 else 485 else
483 blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT); 486 blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT);
484 data->bytes_xfered = data->blksz * (data->blocks - blocks); 487 data->bytes_xfered = data->blksz * (data->blocks - blocks);
@@ -600,9 +603,10 @@ static void sdhci_finish_command(struct sdhci_host *host)
600 603
601 host->cmd->error = MMC_ERR_NONE; 604 host->cmd->error = MMC_ERR_NONE;
602 605
603 if (host->cmd->data) 606 if (host->data && host->data_early)
604 host->data = host->cmd->data; 607 sdhci_finish_data(host);
605 else 608
609 if (!host->cmd->data)
606 tasklet_schedule(&host->finish_tasklet); 610 tasklet_schedule(&host->finish_tasklet);
607 611
608 host->cmd = NULL; 612 host->cmd = NULL;
@@ -929,9 +933,9 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
929 BUG_ON(intmask == 0); 933 BUG_ON(intmask == 0);
930 934
931 if (!host->cmd) { 935 if (!host->cmd) {
932 printk(KERN_ERR "%s: Got command interrupt even though no " 936 printk(KERN_ERR "%s: Got command interrupt 0x%08x even "
933 "command operation was in progress.\n", 937 "though no command operation was in progress.\n",
934 mmc_hostname(host->mmc)); 938 mmc_hostname(host->mmc), (unsigned)intmask);
935 sdhci_dumpregs(host); 939 sdhci_dumpregs(host);
936 return; 940 return;
937 } 941 }
@@ -961,9 +965,9 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
961 if (intmask & SDHCI_INT_DATA_END) 965 if (intmask & SDHCI_INT_DATA_END)
962 return; 966 return;
963 967
964 printk(KERN_ERR "%s: Got data interrupt even though no " 968 printk(KERN_ERR "%s: Got data interrupt 0x%08x even "
965 "data operation was in progress.\n", 969 "though no data operation was in progress.\n",
966 mmc_hostname(host->mmc)); 970 mmc_hostname(host->mmc), (unsigned)intmask);
967 sdhci_dumpregs(host); 971 sdhci_dumpregs(host);
968 972
969 return; 973 return;
@@ -991,8 +995,18 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
991 writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS), 995 writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS),
992 host->ioaddr + SDHCI_DMA_ADDRESS); 996 host->ioaddr + SDHCI_DMA_ADDRESS);
993 997
994 if (intmask & SDHCI_INT_DATA_END) 998 if (intmask & SDHCI_INT_DATA_END) {
995 sdhci_finish_data(host); 999 if (host->cmd) {
1000 /*
1001 * Data managed to finish before the
1002 * command completed. Make sure we do
1003 * things in the proper order.
1004 */
1005 host->data_early = 1;
1006 } else {
1007 sdhci_finish_data(host);
1008 }
1009 }
996 } 1010 }
997} 1011}
998 1012
@@ -1347,12 +1361,11 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1347 */ 1361 */
1348 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT; 1362 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
1349 if (mmc->max_blk_size >= 3) { 1363 if (mmc->max_blk_size >= 3) {
1350 printk(KERN_ERR "%s: Invalid maximum block size.\n", 1364 printk(KERN_WARNING "%s: Invalid maximum block size, assuming 512\n",
1351 host->slot_descr); 1365 host->slot_descr);
1352 ret = -ENODEV; 1366 mmc->max_blk_size = 512;
1353 goto unmap; 1367 } else
1354 } 1368 mmc->max_blk_size = 512 << mmc->max_blk_size;
1355 mmc->max_blk_size = 512 << mmc->max_blk_size;
1356 1369
1357 /* 1370 /*
1358 * Maximum block count. 1371 * Maximum block count.
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index d157776c1149..e28987d6d2eb 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -182,6 +182,7 @@ struct sdhci_host {
182 struct mmc_request *mrq; /* Current request */ 182 struct mmc_request *mrq; /* Current request */
183 struct mmc_command *cmd; /* Current command */ 183 struct mmc_command *cmd; /* Current command */
184 struct mmc_data *data; /* Current data request */ 184 struct mmc_data *data; /* Current data request */
185 int data_early:1; /* Data finished before cmd */
185 186
186 struct scatterlist *cur_sg; /* We're working on this */ 187 struct scatterlist *cur_sg; /* We're working on this */
187 int num_sg; /* Entries left */ 188 int num_sg; /* Entries left */