.. | .. |
---|
420 | 420 | extra_size = 0; |
---|
421 | 421 | |
---|
422 | 422 | /* 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); |
---|
425 | 426 | } |
---|
426 | 427 | |
---|
427 | 428 | if (extp->MinorVersion >= '1') { |
---|
.. | .. |
---|
695 | 696 | */ |
---|
696 | 697 | if (extp && extp->MajorVersion == '1' && extp->MinorVersion >= '3' |
---|
697 | 698 | && extp->FeatureSupport & (1 << 9)) { |
---|
| 699 | + int offs = 0; |
---|
698 | 700 | struct cfi_private *newcfi; |
---|
699 | 701 | struct flchip *chip; |
---|
700 | 702 | struct flchip_shared *shared; |
---|
701 | | - int offs, numregions, numparts, partshift, numvirtchips, i, j; |
---|
| 703 | + int numregions, numparts, partshift, numvirtchips, i, j; |
---|
702 | 704 | |
---|
703 | 705 | /* 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); |
---|
706 | 709 | |
---|
707 | 710 | /* Burst Read info */ |
---|
708 | 711 | offs += extp->extra[offs+1]+2; |
---|
.. | .. |
---|
756 | 759 | } |
---|
757 | 760 | |
---|
758 | 761 | numvirtchips = cfi->numchips * numparts; |
---|
759 | | - newcfi = kmalloc(sizeof(struct cfi_private) + numvirtchips * sizeof(struct flchip), GFP_KERNEL); |
---|
| 762 | + newcfi = kmalloc(struct_size(newcfi, chips, numvirtchips), |
---|
| 763 | + GFP_KERNEL); |
---|
760 | 764 | if (!newcfi) |
---|
761 | 765 | return -ENOMEM; |
---|
762 | 766 | shared = kmalloc_array(cfi->numchips, |
---|
.. | .. |
---|
833 | 837 | /* Someone else might have been playing with it. */ |
---|
834 | 838 | return -EAGAIN; |
---|
835 | 839 | } |
---|
836 | | - /* Fall through */ |
---|
| 840 | + fallthrough; |
---|
837 | 841 | case FL_READY: |
---|
838 | 842 | case FL_CFI_QUERY: |
---|
839 | 843 | case FL_JEDEC_QUERY: |
---|
.. | .. |
---|
906 | 910 | /* Only if there's no operation suspended... */ |
---|
907 | 911 | if (mode == FL_READY && chip->oldstate == FL_READY) |
---|
908 | 912 | return 0; |
---|
909 | | - /* Fall through */ |
---|
| 913 | + fallthrough; |
---|
910 | 914 | default: |
---|
911 | 915 | sleep: |
---|
912 | 916 | set_current_state(TASK_UNINTERRUPTIBLE); |
---|
.. | .. |
---|
1352 | 1356 | { |
---|
1353 | 1357 | unsigned long cmd_addr; |
---|
1354 | 1358 | struct cfi_private *cfi = map->fldrv_priv; |
---|
1355 | | - int ret = 0; |
---|
| 1359 | + int ret; |
---|
1356 | 1360 | |
---|
1357 | 1361 | adr += chip->start; |
---|
1358 | 1362 | |
---|
.. | .. |
---|
1382 | 1386 | struct cfi_private *cfi = map->fldrv_priv; |
---|
1383 | 1387 | unsigned long ofs, last_end = 0; |
---|
1384 | 1388 | int chipnum; |
---|
1385 | | - int ret = 0; |
---|
| 1389 | + int ret; |
---|
1386 | 1390 | |
---|
1387 | 1391 | if (!map->virt) |
---|
1388 | 1392 | return -EINVAL; |
---|
.. | .. |
---|
1549 | 1553 | { |
---|
1550 | 1554 | struct cfi_private *cfi = map->fldrv_priv; |
---|
1551 | 1555 | map_word status, write_cmd; |
---|
1552 | | - int ret=0; |
---|
| 1556 | + int ret; |
---|
1553 | 1557 | |
---|
1554 | 1558 | adr += chip->start; |
---|
1555 | 1559 | |
---|
.. | .. |
---|
1623 | 1627 | { |
---|
1624 | 1628 | struct map_info *map = mtd->priv; |
---|
1625 | 1629 | struct cfi_private *cfi = map->fldrv_priv; |
---|
1626 | | - int ret = 0; |
---|
| 1630 | + int ret; |
---|
1627 | 1631 | int chipnum; |
---|
1628 | 1632 | unsigned long ofs; |
---|
1629 | 1633 | |
---|
.. | .. |
---|
1870 | 1874 | struct map_info *map = mtd->priv; |
---|
1871 | 1875 | struct cfi_private *cfi = map->fldrv_priv; |
---|
1872 | 1876 | int wbufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; |
---|
1873 | | - int ret = 0; |
---|
| 1877 | + int ret; |
---|
1874 | 1878 | int chipnum; |
---|
1875 | 1879 | unsigned long ofs, vec_seek, i; |
---|
1876 | 1880 | size_t len = 0; |
---|