source: trunk/target/linux/generic-2.6/patches-2.6.34/060-block2mtd_init.patch @ 20999

Last change on this file since 20999 was 20999, checked in by hauke, 6 years ago

kernel: refresh patches with 2.6.34-rc4

File size: 3.5 KB
  • drivers/mtd/devices/block2mtd.c

    a b  
    1414#include <linux/list.h> 
    1515#include <linux/init.h> 
    1616#include <linux/mtd/mtd.h> 
     17#include <linux/mtd/partitions.h> 
    1718#include <linux/buffer_head.h> 
    1819#include <linux/mutex.h> 
    1920#include <linux/mount.h> 
    static void block2mtd_free_device(struct 
    233234 
    234235 
    235236/* FIXME: ensure that mtd->size % erase_size == 0 */ 
    236 static struct block2mtd_dev *add_device(char *devname, int erase_size) 
     237static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname) 
    237238{ 
    238239        struct block_device *bdev; 
    239240        struct block2mtd_dev *dev; 
     241        struct mtd_partition *part; 
    240242        char *name; 
    241243 
    242244        if (!devname) 
    static struct block2mtd_dev *add_device( 
    274276 
    275277        mutex_init(&dev->write_mutex); 
    276278 
    277         /* Setup the MTD structure */ 
    278         /* make the name contain the block device in */ 
    279         name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1, 
    280                         GFP_KERNEL); 
     279        if (!mtdname) 
     280                mtdname = devname; 
     281 
     282        name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL); 
    281283        if (!name) 
    282284                goto devinit_err; 
    283285 
    284         sprintf(name, "block2mtd: %s", devname); 
     286        strcpy(name, mtdname); 
    285287        dev->mtd.name = name; 
    286288 
    287         dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; 
     289        dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1); 
    288290        dev->mtd.erasesize = erase_size; 
    289291        dev->mtd.writesize = 1; 
    290292        dev->mtd.type = MTD_RAM; 
    static struct block2mtd_dev *add_device( 
    297299        dev->mtd.priv = dev; 
    298300        dev->mtd.owner = THIS_MODULE; 
    299301 
    300         if (add_mtd_device(&dev->mtd)) { 
     302        part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL); 
     303        part->name = dev->mtd.name; 
     304        part->offset = 0; 
     305        part->size = dev->mtd.size; 
     306        if (add_mtd_partitions(&dev->mtd, part, 1)) { 
    301307                /* Device didnt get added, so free the entry */ 
    302308                goto devinit_err; 
    303309        } 
    304310        list_add(&dev->list, &blkmtd_device_list); 
    305311        INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index, 
    306                         dev->mtd.name + strlen("block2mtd: "), 
    307                         dev->mtd.erasesize >> 10, dev->mtd.erasesize); 
     312                        mtdname, dev->mtd.erasesize >> 10, dev->mtd.erasesize); 
    308313        return dev; 
    309314 
    310315devinit_err: 
    static char block2mtd_paramline[80 + 12] 
    377382 
    378383static int block2mtd_setup2(const char *val) 
    379384{ 
    380         char buf[80 + 12]; /* 80 for device, 12 for erase size */ 
     385        char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */ 
    381386        char *str = buf; 
    382         char *token[2]; 
     387        char *token[3]; 
    383388        char *name; 
    384389        size_t erase_size = PAGE_SIZE; 
    385390        int i, ret; 
    static int block2mtd_setup2(const char * 
    390395        strcpy(str, val); 
    391396        kill_final_newline(str); 
    392397 
    393         for (i = 0; i < 2; i++) 
     398        for (i = 0; i < 3; i++) 
    394399                token[i] = strsep(&str, ","); 
    395400 
    396401        if (str) 
    static int block2mtd_setup2(const char * 
    409414                        parse_err("illegal erase size"); 
    410415                } 
    411416        } 
     417        if (token[2] && (strlen(token[2]) + 1 > 80)) 
     418                parse_err("mtd device name too long"); 
    412419 
    413         add_device(name, erase_size); 
     420        add_device(name, erase_size, token[2]); 
    414421 
    415422        return 0; 
    416423} 
    static int block2mtd_setup(const char *v 
    444451 
    445452 
    446453module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200); 
    447 MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\""); 
     454MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\""); 
    448455 
    449456static int __init block2mtd_init(void) 
    450457{ 
  • fs/partitions/check.c

    a b try_scan: 
    639639        kfree(state); 
    640640        return 0; 
    641641} 
     642EXPORT_SYMBOL(rescan_partitions); 
    642643 
    643644unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p) 
    644645{ 
Note: See TracBrowser for help on using the repository browser.