ramips: use separated mtd patch reverting write_page() removal
[oweals/openwrt.git] / target / linux / ramips / patches-4.14 / 0038-Revert-mtd-nand-Remove-unused-chip-write_page-hook.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Subject: [PATCH] Revert "mtd: nand: Remove unused chip->write_page() hook"
3 MIME-Version: 1.0
4 Content-Type: text/plain; charset=UTF-8
5 Content-Transfer-Encoding: 8bit
6
7 This reverts commit f107d7a43923a83d837b3ea3c7b7de58cd014bbd.
8
9 OpenWrt's downstream driver mtk_nand2 still uses that callback.
10
11 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
12 ---
13
14 --- a/drivers/mtd/nand/nand_base.c
15 +++ b/drivers/mtd/nand/nand_base.c
16 @@ -2577,7 +2577,7 @@ static int nand_write_page_syndrome(stru
17  }
18  
19  /**
20 - * nand_write_page - write one page
21 + * nand_write_page - [REPLACEABLE] write one page
22   * @mtd: MTD device structure
23   * @chip: NAND chip descriptor
24   * @offset: address offset within the page
25 @@ -2761,9 +2761,9 @@ static int nand_do_write_ops(struct mtd_
26                         memset(chip->oob_poi, 0xff, mtd->oobsize);
27                 }
28  
29 -               ret = nand_write_page(mtd, chip, column, bytes, wbuf,
30 -                                     oob_required, page,
31 -                                     (ops->mode == MTD_OPS_RAW));
32 +               ret = chip->write_page(mtd, chip, column, bytes, wbuf,
33 +                                       oob_required, page,
34 +                                       (ops->mode == MTD_OPS_RAW));
35                 if (ret)
36                         break;
37  
38 @@ -4719,6 +4719,9 @@ int nand_scan_tail(struct mtd_info *mtd)
39                 }
40         }
41  
42 +       if (!chip->write_page)
43 +               chip->write_page = nand_write_page;
44 +
45         /*
46          * Check ECC mode, default to software if 3byte/512byte hardware ECC is
47          * selected and we have 256 byte pagesize fallback to software ECC
48 --- a/include/linux/mtd/rawnand.h
49 +++ b/include/linux/mtd/rawnand.h
50 @@ -862,6 +862,7 @@ struct nand_manufacturer_ops {
51   *                     structure which is shared among multiple independent
52   *                     devices.
53   * @priv:              [OPTIONAL] pointer to private chip data
54 + * @write_page:                [REPLACEABLE] High-level page write function
55   * @manufacturer:      [INTERN] Contains manufacturer information
56   */
57  
58 @@ -885,6 +886,9 @@ struct nand_chip {
59         int(*waitfunc)(struct mtd_info *mtd, struct nand_chip *this);
60         int (*erase)(struct mtd_info *mtd, int page);
61         int (*scan_bbt)(struct mtd_info *mtd);
62 +       int (*write_page)(struct mtd_info *mtd, struct nand_chip *chip,
63 +                       uint32_t offset, int data_len, const uint8_t *buf,
64 +                       int oob_required, int page, int raw);
65         int (*onfi_set_features)(struct mtd_info *mtd, struct nand_chip *chip,
66                         int feature_addr, uint8_t *subfeature_para);
67         int (*onfi_get_features)(struct mtd_info *mtd, struct nand_chip *chip,