packagegroup-opendreambox-essential: move to meta-opendreambox
[opendreambox.git] / meta-bsp / common / recipes / linux / linux-dreambox-3.2 / 0004-block2mtd-add-possibility-to-change-the-writesize.patch
1 From 1053b7a27b144b2ed747c5916794d691e05c4566 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 04/17] block2mtd: add possibility to change the writesize
5
6 ---
7  drivers/mtd/devices/block2mtd.c | 28 ++++++++++++++++++----------
8  1 file changed, 18 insertions(+), 10 deletions(-)
9
10 diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
11 index 8cd983c..a54d052 100644
12 --- a/drivers/mtd/devices/block2mtd.c
13 +++ b/drivers/mtd/devices/block2mtd.c
14 @@ -232,7 +232,7 @@ static void block2mtd_free_device(struct block2mtd_dev *dev)
15  
16  
17  /* FIXME: ensure that mtd->size % erase_size == 0 */
18 -static struct block2mtd_dev *add_device(char *devname, int erase_size)
19 +static struct block2mtd_dev *add_device(char *devname, int erase_size, int write_size)
20  {
21         const fmode_t mode = FMODE_READ | FMODE_WRITE | FMODE_EXCL;
22         struct block_device *bdev;
23 @@ -283,7 +283,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
24  
25         dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
26         dev->mtd.erasesize = erase_size;
27 -       dev->mtd.writesize = 1;
28 +       dev->mtd.writesize = write_size;
29         dev->mtd.writebufsize = PAGE_SIZE;
30         dev->mtd.type = MTD_RAM;
31         dev->mtd.flags = MTD_CAP_RAM;
32 @@ -300,9 +300,10 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
33                 goto devinit_err;
34         }
35         list_add(&dev->list, &blkmtd_device_list);
36 -       INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index,
37 +       INFO("mtd%d: [%s] erase_size = %dKiB [%d] write_size = %dKiB [%d]", dev->mtd.index,
38                         dev->mtd.name + strlen("block2mtd: "),
39 -                       dev->mtd.erasesize >> 10, dev->mtd.erasesize);
40 +                       dev->mtd.erasesize >> 10, dev->mtd.erasesize,
41 +                       dev->mtd.writesize >> 10, dev->mtd.writesize);
42         return dev;
43  
44  devinit_err:
45 @@ -369,17 +370,18 @@ static inline void kill_final_newline(char *str)
46  
47  #ifndef MODULE
48  static int block2mtd_init_called = 0;
49 -static char block2mtd_paramline[80 + 12]; /* 80 for device, 12 for erase size */
50 +static char block2mtd_paramline[80 + 12 + 12]; /* 80 for device, 12 for erase size, 12 for writesize */
51  #endif
52  
53  
54  static int block2mtd_setup2(const char *val)
55  {
56 -       char buf[80 + 12]; /* 80 for device, 12 for erase size */
57 +       char buf[80 + 12 + 12]; /* 80 for device, 12 for erase size, 12 for writesize */
58         char *str = buf;
59 -       char *token[2];
60 +       char *token[3];
61         char *name;
62         size_t erase_size = PAGE_SIZE;
63 +       size_t write_size = 1;
64         int i, ret;
65  
66         if (strnlen(val, sizeof(buf)) >= sizeof(buf))
67 @@ -388,7 +390,7 @@ static int block2mtd_setup2(const char *val)
68         strcpy(str, val);
69         kill_final_newline(str);
70  
71 -       for (i = 0; i < 2; i++)
72 +       for (i = 0; i < 3; i++)
73                 token[i] = strsep(&str, ",");
74  
75         if (str)
76 @@ -407,8 +409,14 @@ static int block2mtd_setup2(const char *val)
77                         parse_err("illegal erase size");
78                 }
79         }
80 +       if (token[2]) {
81 +               ret = parse_num(&write_size, token[2]);
82 +               if (ret) {
83 +                       parse_err("illegal write size");
84 +               }
85 +       }
86  
87 -       add_device(name, erase_size);
88 +       add_device(name, erase_size, write_size);
89  
90         return 0;
91  }
92 @@ -442,7 +450,7 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)
93  
94  
95  module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
96 -MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
97 +MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>,<writesize>]\"");
98  
99  static int __init block2mtd_init(void)
100  {
101 -- 
102 1.8.1.2
103