Skip to content

Commit

Permalink
Merge git://git.infradead.org/users/dwmw2/mtd-2.6.38
Browse files Browse the repository at this point in the history
* git://git.infradead.org/users/dwmw2/mtd-2.6.38:
  mtd: add "platform:" prefix for platform modalias
  mtd: mtd_blkdevs: fix double free on error path
  mtd: amd76xrom: fix oops at boot when resources are not available
  mtd: fix race in cfi_cmdset_0001 driver
  mtd: jedec_probe: initialise make sector erase command variable
  mtd: jedec_probe: Change variable name from cfi_p to cfi
  • Loading branch information
torvalds committed Mar 13, 2011
2 parents 95a17a2 + c804c73 commit e8444a3
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 42 deletions.
43 changes: 22 additions & 21 deletions drivers/mtd/chips/cfi_cmdset_0001.c
Expand Up @@ -1230,10 +1230,32 @@ static int inval_cache_and_wait_for_operation(
sleep_time = chip_op_time / 2;

for (;;) {
if (chip->state != chip_state) {
/* Someone's suspended the operation: sleep */
DECLARE_WAITQUEUE(wait, current);
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
mutex_unlock(&chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
mutex_lock(&chip->mutex);
continue;
}

status = map_read(map, cmd_adr);
if (map_word_andequal(map, status, status_OK, status_OK))
break;

if (chip->erase_suspended && chip_state == FL_ERASING) {
/* Erase suspend occured while sleep: reset timeout */
timeo = reset_timeo;
chip->erase_suspended = 0;
}
if (chip->write_suspended && chip_state == FL_WRITING) {
/* Write suspend occured while sleep: reset timeout */
timeo = reset_timeo;
chip->write_suspended = 0;
}
if (!timeo) {
map_write(map, CMD(0x70), cmd_adr);
chip->state = FL_STATUS;
Expand All @@ -1257,27 +1279,6 @@ static int inval_cache_and_wait_for_operation(
timeo--;
}
mutex_lock(&chip->mutex);

while (chip->state != chip_state) {
/* Someone's suspended the operation: sleep */
DECLARE_WAITQUEUE(wait, current);
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&chip->wq, &wait);
mutex_unlock(&chip->mutex);
schedule();
remove_wait_queue(&chip->wq, &wait);
mutex_lock(&chip->mutex);
}
if (chip->erase_suspended && chip_state == FL_ERASING) {
/* Erase suspend occured while sleep: reset timeout */
timeo = reset_timeo;
chip->erase_suspended = 0;
}
if (chip->write_suspended && chip_state == FL_WRITING) {
/* Write suspend occured while sleep: reset timeout */
timeo = reset_timeo;
chip->write_suspended = 0;
}
}

/* Done and happy. */
Expand Down
35 changes: 18 additions & 17 deletions drivers/mtd/chips/jedec_probe.c
Expand Up @@ -1935,51 +1935,52 @@ static void jedec_reset(u32 base, struct map_info *map, struct cfi_private *cfi)
}


static int cfi_jedec_setup(struct cfi_private *p_cfi, int index)
static int cfi_jedec_setup(struct map_info *map, struct cfi_private *cfi, int index)
{
int i,num_erase_regions;
uint8_t uaddr;

if (! (jedec_table[index].devtypes & p_cfi->device_type)) {
if (!(jedec_table[index].devtypes & cfi->device_type)) {
DEBUG(MTD_DEBUG_LEVEL1, "Rejecting potential %s with incompatible %d-bit device type\n",
jedec_table[index].name, 4 * (1<<p_cfi->device_type));
jedec_table[index].name, 4 * (1<<cfi->device_type));
return 0;
}

printk(KERN_INFO "Found: %s\n",jedec_table[index].name);

num_erase_regions = jedec_table[index].nr_regions;

p_cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL);
if (!p_cfi->cfiq) {
cfi->cfiq = kmalloc(sizeof(struct cfi_ident) + num_erase_regions * 4, GFP_KERNEL);
if (!cfi->cfiq) {
//xx printk(KERN_WARNING "%s: kmalloc failed for CFI ident structure\n", map->name);
return 0;
}

memset(p_cfi->cfiq,0,sizeof(struct cfi_ident));
memset(cfi->cfiq, 0, sizeof(struct cfi_ident));

p_cfi->cfiq->P_ID = jedec_table[index].cmd_set;
p_cfi->cfiq->NumEraseRegions = jedec_table[index].nr_regions;
p_cfi->cfiq->DevSize = jedec_table[index].dev_size;
p_cfi->cfi_mode = CFI_MODE_JEDEC;
cfi->cfiq->P_ID = jedec_table[index].cmd_set;
cfi->cfiq->NumEraseRegions = jedec_table[index].nr_regions;
cfi->cfiq->DevSize = jedec_table[index].dev_size;
cfi->cfi_mode = CFI_MODE_JEDEC;
cfi->sector_erase_cmd = CMD(0x30);

for (i=0; i<num_erase_regions; i++){
p_cfi->cfiq->EraseRegionInfo[i] = jedec_table[index].regions[i];
cfi->cfiq->EraseRegionInfo[i] = jedec_table[index].regions[i];
}
p_cfi->cmdset_priv = NULL;
cfi->cmdset_priv = NULL;

/* This may be redundant for some cases, but it doesn't hurt */
p_cfi->mfr = jedec_table[index].mfr_id;
p_cfi->id = jedec_table[index].dev_id;
cfi->mfr = jedec_table[index].mfr_id;
cfi->id = jedec_table[index].dev_id;

uaddr = jedec_table[index].uaddr;

/* The table has unlock addresses in _bytes_, and we try not to let
our brains explode when we see the datasheets talking about address
lines numbered from A-1 to A18. The CFI table has unlock addresses
in device-words according to the mode the device is connected in */
p_cfi->addr_unlock1 = unlock_addrs[uaddr].addr1 / p_cfi->device_type;
p_cfi->addr_unlock2 = unlock_addrs[uaddr].addr2 / p_cfi->device_type;
cfi->addr_unlock1 = unlock_addrs[uaddr].addr1 / cfi->device_type;
cfi->addr_unlock2 = unlock_addrs[uaddr].addr2 / cfi->device_type;

return 1; /* ok */
}
Expand Down Expand Up @@ -2175,7 +2176,7 @@ static int jedec_probe_chip(struct map_info *map, __u32 base,
"MTD %s(): matched device 0x%x,0x%x unlock_addrs: 0x%.4x 0x%.4x\n",
__func__, cfi->mfr, cfi->id,
cfi->addr_unlock1, cfi->addr_unlock2 );
if (!cfi_jedec_setup(cfi, i))
if (!cfi_jedec_setup(map, cfi, i))
return 0;
goto ok_out;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/mtd/maps/amd76xrom.c
Expand Up @@ -151,6 +151,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
printk(KERN_ERR MOD_NAME
" %s(): Unable to register resource %pR - kernel bug?\n",
__func__, &window->rsrc);
return -EBUSY;
}


Expand Down
1 change: 0 additions & 1 deletion drivers/mtd/mtd_blkdevs.c
Expand Up @@ -413,7 +413,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
error2:
list_del(&new->list);
error1:
kfree(new);
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nand/omap2.c
Expand Up @@ -968,6 +968,6 @@ static void __exit omap_nand_exit(void)
module_init(omap_nand_init);
module_exit(omap_nand_exit);

MODULE_ALIAS(DRIVER_NAME);
MODULE_ALIAS("platform:" DRIVER_NAME);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Glue layer for NAND flash on TI OMAP boards");
2 changes: 1 addition & 1 deletion drivers/mtd/onenand/generic.c
Expand Up @@ -131,7 +131,7 @@ static struct platform_driver generic_onenand_driver = {
.remove = __devexit_p(generic_onenand_remove),
};

MODULE_ALIAS(DRIVER_NAME);
MODULE_ALIAS("platform:" DRIVER_NAME);

static int __init generic_onenand_init(void)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/onenand/omap2.c
Expand Up @@ -860,7 +860,7 @@ static void __exit omap2_onenand_exit(void)
module_init(omap2_onenand_init);
module_exit(omap2_onenand_exit);

MODULE_ALIAS(DRIVER_NAME);
MODULE_ALIAS("platform:" DRIVER_NAME);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jarkko Lavinen <jarkko.lavinen@nokia.com>");
MODULE_DESCRIPTION("Glue layer for OneNAND flash on OMAP2 / OMAP3");

0 comments on commit e8444a3

Please sign in to comment.