Updated upstream Git repositories
[opendreambox.git] / meta-dreambox / recipes-kernel / linux / linux-dreambox-3.4 / 0001-block2mtd-add-possibility-to-change-the-writesize.patch
1 From 3aa82ce9ebc1b2d7f8c70a27def787512b6b64f1 Mon Sep 17 00:00:00 2001
2 From: Andreas Monzner <andreas.monzner@dream-property.net>
3 Date: Mon, 11 Mar 2013 16:22:55 +0100
4 Subject: [PATCH 1/4] block2mtd: add possibility to change the writesize
5
6 (cherry picked from commit 88e224371bba45629f03c031faef664a7ff42100)
7 ---
8  drivers/mtd/devices/block2mtd.c | 28 ++++++++++++++++++----------
9  1 file changed, 18 insertions(+), 10 deletions(-)
10
11 diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
12 index 7d7000d..56e559b 100644
13 --- a/drivers/mtd/devices/block2mtd.c
14 +++ b/drivers/mtd/devices/block2mtd.c
15 @@ -214,7 +214,7 @@ static void block2mtd_free_device(struct block2mtd_dev *dev)
16  
17  
18  /* FIXME: ensure that mtd->size % erase_size == 0 */
19 -static struct block2mtd_dev *add_device(char *devname, int erase_size)
20 +static struct block2mtd_dev *add_device(char *devname, int erase_size, int write_size)
21  {
22         const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
23         struct block_device *bdev;
24 @@ -265,7 +265,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
25  
26         dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
27         dev->mtd.erasesize = erase_size;
28 -       dev->mtd.writesize = 1;
29 +       dev->mtd.writesize = write_size;
30         dev->mtd.writebufsize = PAGE_SIZE;
31         dev->mtd.type = MTD_RAM;
32         dev->mtd.flags = MTD_CAP_RAM;
33 @@ -281,9 +281,10 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
34                 goto devinit_err;
35         }
36         list_add(&dev->list, &blkmtd_device_list);
37 -       INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index,
38 +       INFO("mtd%d: [%s] erase_size = %dKiB [%d] write_size = %dKiB [%d]", dev->mtd.index,
39                         dev->mtd.name + strlen("block2mtd: "),
40 -                       dev->mtd.erasesize >> 10, dev->mtd.erasesize);
41 +                       dev->mtd.erasesize >> 10, dev->mtd.erasesize,
42 +                       dev->mtd.writesize >> 10, dev->mtd.writesize);
43         return dev;
44  
45  devinit_err:
46 @@ -350,17 +351,18 @@ static inline void kill_final_newline(char *str)
47  
48  #ifndef MODULE
49  static int block2mtd_init_called = 0;
50 -static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */
51 +static char block2mtd_paramline[80 + 12 + 12]; /* 80 for device, 12 for erase size, 12 for writesize */
52  #endif
53  
54  
55  static int block2mtd_setup2(const char *val)
56  {
57 -       char buf[80 + 12]; /* 80 for device, 12 for erase size */
58 +       char buf[80 + 12 + 12]; /* 80 for device, 12 for erase size, 12 for writesize */
59         char *str = buf;
60 -       char *token[2];
61 +       char *token[3];
62         char *name;
63         size_t erase_size = PAGE_SIZE;
64 +       size_t write_size = 1;
65         int i, ret;
66  
67         if (strnlen(val, sizeof(buf)) >= sizeof(buf))
68 @@ -369,7 +371,7 @@ static int block2mtd_setup2(const char *val)
69         strcpy(str, val);
70         kill_final_newline(str);
71  
72 -       for (i = 0; i < 2; i++)
73 +       for (i = 0; i < 3; i++)
74                 token[i] = strsep(&str, ",");
75  
76         if (str)
77 @@ -388,8 +390,14 @@ static int block2mtd_setup2(const char *val)
78                         parse_err("illegal erase size");
79                 }
80         }
81 +       if (token[2]) {
82 +               ret = parse_num(&write_size, token[2]);
83 +               if (ret) {
84 +                       parse_err("illegal write size");
85 +               }
86 +       }
87  
88 -       add_device(name, erase_size);
89 +       add_device(name, erase_size, write_size);
90  
91         return 0;
92  }
93 @@ -423,7 +431,7 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)
94  
95  
96  module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
97 -MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
98 +MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>,<writesize>]\"");
99  
100  static int __init block2mtd_init(void)
101  {
102 -- 
103 2.1.4
104