aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
authorBurman Yan <yan_952@hotmail.com>2006-11-15 14:10:29 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2006-11-28 18:47:21 -0500
commit95b93a0cd46682c6d9e8eea803fda510cb6b863a (patch)
tree7e430d3fc04ed20791187d144730dd3052292c67 /drivers/mtd/devices
parent998a43e72d20afa7566dad66fd866fe939a89c09 (diff)
[MTD] replace kmalloc+memset with kzalloc
Signed-off-by: Yan Burman <yan_952@hotmail.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r--drivers/mtd/devices/block2mtd.c3
-rw-r--r--drivers/mtd/devices/ms02-nv.c18
-rw-r--r--drivers/mtd/devices/phram.c4
-rw-r--r--drivers/mtd/devices/slram.c7
4 files changed, 10 insertions, 22 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 401c6a294baa..6d917a4daa9d 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -295,10 +295,9 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
295 if (!devname) 295 if (!devname)
296 return NULL; 296 return NULL;
297 297
298 dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); 298 dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
299 if (!dev) 299 if (!dev)
300 return NULL; 300 return NULL;
301 memset(dev, 0, sizeof(*dev));
302 301
303 /* Get a handle on the device */ 302 /* Get a handle on the device */
304 bdev = open_bdev_excl(devname, O_RDWR, NULL); 303 bdev = open_bdev_excl(devname, O_RDWR, NULL);
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index 08dfb899b272..9cff119a2024 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulong addr)
131 int ret = -ENODEV; 131 int ret = -ENODEV;
132 132
133 /* The module decodes 8MiB of address space. */ 133 /* The module decodes 8MiB of address space. */
134 mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL); 134 mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL);
135 if (!mod_res) 135 if (!mod_res)
136 return -ENOMEM; 136 return -ENOMEM;
137 137
138 memset(mod_res, 0, sizeof(*mod_res));
139 mod_res->name = ms02nv_name; 138 mod_res->name = ms02nv_name;
140 mod_res->start = addr; 139 mod_res->start = addr;
141 mod_res->end = addr + MS02NV_SLOT_SIZE - 1; 140 mod_res->end = addr + MS02NV_SLOT_SIZE - 1;
@@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong addr)
153 } 152 }
154 153
155 ret = -ENOMEM; 154 ret = -ENOMEM;
156 mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 155 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
157 if (!mtd) 156 if (!mtd)
158 goto err_out_mod_res_rel; 157 goto err_out_mod_res_rel;
159 memset(mtd, 0, sizeof(*mtd)); 158 mp = kzalloc(sizeof(*mp), GFP_KERNEL);
160 mp = kmalloc(sizeof(*mp), GFP_KERNEL);
161 if (!mp) 159 if (!mp)
162 goto err_out_mtd; 160 goto err_out_mtd;
163 memset(mp, 0, sizeof(*mp));
164 161
165 mtd->priv = mp; 162 mtd->priv = mp;
166 mp->resource.module = mod_res; 163 mp->resource.module = mod_res;
167 164
168 /* Firmware's diagnostic NVRAM area. */ 165 /* Firmware's diagnostic NVRAM area. */
169 diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL); 166 diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL);
170 if (!diag_res) 167 if (!diag_res)
171 goto err_out_mp; 168 goto err_out_mp;
172 169
173 memset(diag_res, 0, sizeof(*diag_res));
174 diag_res->name = ms02nv_res_diag_ram; 170 diag_res->name = ms02nv_res_diag_ram;
175 diag_res->start = addr; 171 diag_res->start = addr;
176 diag_res->end = addr + MS02NV_RAM - 1; 172 diag_res->end = addr + MS02NV_RAM - 1;
@@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong addr)
180 mp->resource.diag_ram = diag_res; 176 mp->resource.diag_ram = diag_res;
181 177
182 /* User-available general-purpose NVRAM area. */ 178 /* User-available general-purpose NVRAM area. */
183 user_res = kmalloc(sizeof(*user_res), GFP_KERNEL); 179 user_res = kzalloc(sizeof(*user_res), GFP_KERNEL);
184 if (!user_res) 180 if (!user_res)
185 goto err_out_diag_res; 181 goto err_out_diag_res;
186 182
187 memset(user_res, 0, sizeof(*user_res));
188 user_res->name = ms02nv_res_user_ram; 183 user_res->name = ms02nv_res_user_ram;
189 user_res->start = addr + MS02NV_RAM; 184 user_res->start = addr + MS02NV_RAM;
190 user_res->end = addr + size - 1; 185 user_res->end = addr + size - 1;
@@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong addr)
194 mp->resource.user_ram = user_res; 189 mp->resource.user_ram = user_res;
195 190
196 /* Control and status register. */ 191 /* Control and status register. */
197 csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL); 192 csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL);
198 if (!csr_res) 193 if (!csr_res)
199 goto err_out_user_res; 194 goto err_out_user_res;
200 195
201 memset(csr_res, 0, sizeof(*csr_res));
202 csr_res->name = ms02nv_res_csr; 196 csr_res->name = ms02nv_res_csr;
203 csr_res->start = addr + MS02NV_CSR; 197 csr_res->start = addr + MS02NV_CSR;
204 csr_res->end = addr + MS02NV_CSR + 3; 198 csr_res->end = addr + MS02NV_CSR + 3;
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 6c7337f9ebbb..56cc1ca7ffd5 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -126,12 +126,10 @@ static int register_device(char *name, unsigned long start, unsigned long len)
126 struct phram_mtd_list *new; 126 struct phram_mtd_list *new;
127 int ret = -ENOMEM; 127 int ret = -ENOMEM;
128 128
129 new = kmalloc(sizeof(*new), GFP_KERNEL); 129 new = kzalloc(sizeof(*new), GFP_KERNEL);
130 if (!new) 130 if (!new)
131 goto out0; 131 goto out0;
132 132
133 memset(new, 0, sizeof(*new));
134
135 ret = -EIO; 133 ret = -EIO;
136 new->mtd.priv = ioremap(start, len); 134 new->mtd.priv = ioremap(start, len);
137 if (!new->mtd.priv) { 135 if (!new->mtd.priv) {
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 542a0c009006..5f49248a4856 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -168,19 +168,16 @@ static int register_device(char *name, unsigned long start, unsigned long length
168 E("slram: Cannot allocate new MTD device.\n"); 168 E("slram: Cannot allocate new MTD device.\n");
169 return(-ENOMEM); 169 return(-ENOMEM);
170 } 170 }
171 (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); 171 (*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
172 (*curmtd)->next = NULL; 172 (*curmtd)->next = NULL;
173 173
174 if ((*curmtd)->mtdinfo) { 174 if ((*curmtd)->mtdinfo) {
175 memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info));
176 (*curmtd)->mtdinfo->priv = 175 (*curmtd)->mtdinfo->priv =
177 kmalloc(sizeof(slram_priv_t), GFP_KERNEL); 176 kzalloc(sizeof(slram_priv_t), GFP_KERNEL);
178 177
179 if (!(*curmtd)->mtdinfo->priv) { 178 if (!(*curmtd)->mtdinfo->priv) {
180 kfree((*curmtd)->mtdinfo); 179 kfree((*curmtd)->mtdinfo);
181 (*curmtd)->mtdinfo = NULL; 180 (*curmtd)->mtdinfo = NULL;
182 } else {
183 memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t));
184 } 181 }
185 } 182 }
186 183