Skip to content

Commit 35f95d2

Browse files
committed
Merge tag 'for-linus-20121123' of git://git.infradead.org/mtd-2.6
Pull MTD fixes from David Woodhouse: "The most important part of this is that it fixes a regression in Samsung NAND chip detection, introduced by some rework which went into 3.7. The initial fix wasn't quite complete, so it's in two parts. In fact the first part is committed twice (Artem committed his own copy of the same patch) and I've merged Artem's tree into mine which already had that fix. I'd have recommitted that to make it somewhat cleaner, but figured by this point in the release cycle it was better to merge *exactly* the commits which have been in linux-next. If I'd recommitted, I'd also omit the sparse warning fix. But it's there, and it's harmless — just marking one function as 'static' in onenand code. This also includes a couple more fixes for stable: an AB-BA deadlock in JFFS2, and an invalid range check in slram." * tag 'for-linus-20121123' of git://git.infradead.org/mtd-2.6: mtd: nand: fix Samsung SLC detection regression mtd: nand: fix Samsung SLC NAND identification regression jffs2: Fix lock acquisition order bug in jffs2_write_begin mtd: onenand: Make flexonenand_set_boundary static mtd: slram: invalid checking of absolute end address mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions() mtd: nand: fix Samsung SLC NAND identification regression
2 parents 5e351cd + 8514624 commit 35f95d2

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

drivers/mtd/devices/slram.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
240240

241241
if (*(szlength) != '+') {
242242
devlength = simple_strtoul(szlength, &buffer, 0);
243-
devlength = handle_unit(devlength, buffer) - devstart;
243+
devlength = handle_unit(devlength, buffer);
244244
if (devlength < devstart)
245245
goto err_out;
246246

drivers/mtd/nand/nand_base.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,13 +2983,15 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
29832983
/*
29842984
* Field definitions are in the following datasheets:
29852985
* Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32)
2986-
* New style (6 byte ID): Samsung K9GAG08U0F (p.44)
2986+
* New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44)
29872987
* Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22)
29882988
*
2989-
* Check for ID length, cell type, and Hynix/Samsung ID to decide what
2990-
* to do.
2989+
* Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung
2990+
* ID to decide what to do.
29912991
*/
2992-
if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG) {
2992+
if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG &&
2993+
(chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
2994+
id_data[5] != 0x00) {
29932995
/* Calc pagesize */
29942996
mtd->writesize = 2048 << (extid & 0x03);
29952997
extid >>= 2;

drivers/mtd/ofpart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
121121
nr_parts = plen / sizeof(part[0]);
122122

123123
*pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
124-
if (!pparts)
124+
if (!*pparts)
125125
return -ENOMEM;
126126

127127
names = of_get_property(dp, "partition-names", &plen);

drivers/mtd/onenand/onenand_base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3694,7 +3694,7 @@ static int flexonenand_check_blocks_erased(struct mtd_info *mtd, int start, int
36943694
* flexonenand_set_boundary - Writes the SLC boundary
36953695
* @param mtd - mtd info structure
36963696
*/
3697-
int flexonenand_set_boundary(struct mtd_info *mtd, int die,
3697+
static int flexonenand_set_boundary(struct mtd_info *mtd, int die,
36983698
int boundary, int lock)
36993699
{
37003700
struct onenand_chip *this = mtd->priv;

fs/jffs2/file.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,33 +138,39 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
138138
struct page *pg;
139139
struct inode *inode = mapping->host;
140140
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
141+
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
142+
struct jffs2_raw_inode ri;
143+
uint32_t alloc_len = 0;
141144
pgoff_t index = pos >> PAGE_CACHE_SHIFT;
142145
uint32_t pageofs = index << PAGE_CACHE_SHIFT;
143146
int ret = 0;
144147

148+
jffs2_dbg(1, "%s()\n", __func__);
149+
150+
if (pageofs > inode->i_size) {
151+
ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
152+
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
153+
if (ret)
154+
return ret;
155+
}
156+
157+
mutex_lock(&f->sem);
145158
pg = grab_cache_page_write_begin(mapping, index, flags);
146-
if (!pg)
159+
if (!pg) {
160+
if (alloc_len)
161+
jffs2_complete_reservation(c);
162+
mutex_unlock(&f->sem);
147163
return -ENOMEM;
164+
}
148165
*pagep = pg;
149166

150-
jffs2_dbg(1, "%s()\n", __func__);
151-
152-
if (pageofs > inode->i_size) {
167+
if (alloc_len) {
153168
/* Make new hole frag from old EOF to new page */
154-
struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
155-
struct jffs2_raw_inode ri;
156169
struct jffs2_full_dnode *fn;
157-
uint32_t alloc_len;
158170

159171
jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
160172
(unsigned int)inode->i_size, pageofs);
161173

162-
ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
163-
ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
164-
if (ret)
165-
goto out_page;
166-
167-
mutex_lock(&f->sem);
168174
memset(&ri, 0, sizeof(ri));
169175

170176
ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -191,7 +197,6 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
191197
if (IS_ERR(fn)) {
192198
ret = PTR_ERR(fn);
193199
jffs2_complete_reservation(c);
194-
mutex_unlock(&f->sem);
195200
goto out_page;
196201
}
197202
ret = jffs2_add_full_dnode_to_inode(c, f, fn);
@@ -206,12 +211,10 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
206211
jffs2_mark_node_obsolete(c, fn->raw);
207212
jffs2_free_full_dnode(fn);
208213
jffs2_complete_reservation(c);
209-
mutex_unlock(&f->sem);
210214
goto out_page;
211215
}
212216
jffs2_complete_reservation(c);
213217
inode->i_size = pageofs;
214-
mutex_unlock(&f->sem);
215218
}
216219

217220
/*
@@ -220,18 +223,18 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
220223
* case of a short-copy.
221224
*/
222225
if (!PageUptodate(pg)) {
223-
mutex_lock(&f->sem);
224226
ret = jffs2_do_readpage_nolock(inode, pg);
225-
mutex_unlock(&f->sem);
226227
if (ret)
227228
goto out_page;
228229
}
230+
mutex_unlock(&f->sem);
229231
jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
230232
return ret;
231233

232234
out_page:
233235
unlock_page(pg);
234236
page_cache_release(pg);
237+
mutex_unlock(&f->sem);
235238
return ret;
236239
}
237240

0 commit comments

Comments
 (0)