Skip to content

Commit 48e9912

Browse files
Merge tag 'cfi/for-5.8' of gitolite.kernel.org:pub/scm/linux/kernel/git/mtd/linux into mtd/next
CFI changes: * Support the absence of protection registers for Intel CFI flashes * Replace zero-length array with flexible-arrays
2 parents 3f55400 + 1139934 commit 48e9912

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

drivers/mtd/chips/cfi_cmdset_0001.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,9 @@ read_pri_intelext(struct map_info *map, __u16 adr)
420420
extra_size = 0;
421421

422422
/* Protection Register info */
423-
extra_size += (extp->NumProtectionFields - 1) *
424-
sizeof(struct cfi_intelext_otpinfo);
423+
if (extp->NumProtectionFields)
424+
extra_size += (extp->NumProtectionFields - 1) *
425+
sizeof(struct cfi_intelext_otpinfo);
425426
}
426427

427428
if (extp->MinorVersion >= '1') {
@@ -695,14 +696,16 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
695696
*/
696697
if (extp && extp->MajorVersion == '1' && extp->MinorVersion >= '3'
697698
&& extp->FeatureSupport & (1 << 9)) {
699+
int offs = 0;
698700
struct cfi_private *newcfi;
699701
struct flchip *chip;
700702
struct flchip_shared *shared;
701-
int offs, numregions, numparts, partshift, numvirtchips, i, j;
703+
int numregions, numparts, partshift, numvirtchips, i, j;
702704

703705
/* Protection Register info */
704-
offs = (extp->NumProtectionFields - 1) *
705-
sizeof(struct cfi_intelext_otpinfo);
706+
if (extp->NumProtectionFields)
707+
offs = (extp->NumProtectionFields - 1) *
708+
sizeof(struct cfi_intelext_otpinfo);
706709

707710
/* Burst Read info */
708711
offs += extp->extra[offs+1]+2;

include/linux/mtd/cfi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct cfi_ident {
138138
uint16_t InterfaceDesc;
139139
uint16_t MaxBufWriteSize;
140140
uint8_t NumEraseRegions;
141-
uint32_t EraseRegionInfo[0]; /* Not host ordered */
141+
uint32_t EraseRegionInfo[]; /* Not host ordered */
142142
} __packed;
143143

144144
/* Extended Query Structure for both PRI and ALT */
@@ -165,7 +165,7 @@ struct cfi_pri_intelext {
165165
uint16_t ProtRegAddr;
166166
uint8_t FactProtRegSize;
167167
uint8_t UserProtRegSize;
168-
uint8_t extra[0];
168+
uint8_t extra[];
169169
} __packed;
170170

171171
struct cfi_intelext_otpinfo {
@@ -286,7 +286,7 @@ struct cfi_private {
286286
map_word sector_erase_cmd;
287287
unsigned long chipshift; /* Because they're of the same type */
288288
const char *im_name; /* inter_module name for cmdset_setup */
289-
struct flchip chips[0]; /* per-chip data structure for each chip */
289+
struct flchip chips[]; /* per-chip data structure for each chip */
290290
};
291291

292292
uint32_t cfi_build_cmd_addr(uint32_t cmd_ofs,

include/linux/mtd/qinfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct lpddr_private {
2424
struct qinfo_chip *qinfo;
2525
int numchips;
2626
unsigned long chipshift;
27-
struct flchip chips[0];
27+
struct flchip chips[];
2828
};
2929

3030
/* qinfo_query_info structure contains request information for

0 commit comments

Comments
 (0)