]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mtd: rawnand: Pass a nand_chip object to chip->setup_data_interface()
authorBoris Brezillon <boris.brezillon@bootlin.com>
Thu, 6 Sep 2018 12:05:33 +0000 (14:05 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 3 Oct 2018 09:12:25 +0000 (11:12 +0200)
Let's make the raw NAND API consistent by patching all helpers and
hooks to take a nand_chip object instead of an mtd_info one or
remove the mtd_info object when both are passed.

Let's tackle the chip->setup_data_interface() hook.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
14 files changed:
drivers/mtd/nand/raw/atmel/nand-controller.c
drivers/mtd/nand/raw/denali.c
drivers/mtd/nand/raw/fsmc_nand.c
drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h
drivers/mtd/nand/raw/marvell_nand.c
drivers/mtd/nand/raw/mtk_nand.c
drivers/mtd/nand/raw/mxc_nand.c
drivers/mtd/nand/raw/nand_base.c
drivers/mtd/nand/raw/s3c2410.c
drivers/mtd/nand/raw/sunxi_nand.c
drivers/mtd/nand/raw/tango_nand.c
drivers/mtd/nand/raw/tegra_nand.c
include/linux/mtd/rawnand.h

index d5939114f999df69f5eaa76fe76b7a4aa6c5270a..a38633a67ead020a9c92bd5ab75b3bf266f1f2aa 100644 (file)
@@ -1448,10 +1448,9 @@ static int atmel_hsmc_nand_setup_data_interface(struct atmel_nand *nand,
        return 0;
 }
 
-static int atmel_nand_setup_data_interface(struct mtd_info *mtd, int csline,
+static int atmel_nand_setup_data_interface(struct nand_chip *chip, int csline,
                                        const struct nand_data_interface *conf)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        struct atmel_nand *nand = to_atmel_nand(chip);
        struct atmel_nand_controller *nc;
 
index bb4ad3b822adfab87fc3242cedd0de59c600993e..c5e35461d6b3a135de5b1c2c25cd45665de8d0a8 100644 (file)
@@ -932,10 +932,10 @@ static int denali_erase(struct nand_chip *chip, int page)
        return irq_status & INTR__ERASE_COMP ? 0 : -EIO;
 }
 
-static int denali_setup_data_interface(struct mtd_info *mtd, int chipnr,
+static int denali_setup_data_interface(struct nand_chip *chip, int chipnr,
                                       const struct nand_data_interface *conf)
 {
-       struct denali_nand_info *denali = mtd_to_denali(mtd);
+       struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip));
        const struct nand_sdr_timings *timings;
        unsigned long t_x, mult_x;
        int acc_clks, re_2_we, re_2_re, we_2_re, addr_2_data;
index 15bf533c907a3cf76339b6c46c886401ba4ecdb6..5e06fce4b295166fb79ee146a95a686ff2bbab05 100644 (file)
@@ -340,10 +340,9 @@ static int fsmc_calc_timings(struct fsmc_nand_data *host,
        return 0;
 }
 
-static int fsmc_setup_data_interface(struct mtd_info *mtd, int csline,
+static int fsmc_setup_data_interface(struct nand_chip *nand, int csline,
                                     const struct nand_data_interface *conf)
 {
-       struct nand_chip *nand = mtd_to_nand(mtd);
        struct fsmc_nand_data *host = nand_get_controller_data(nand);
        struct fsmc_nand_timings tims;
        const struct nand_sdr_timings *sdrt;
index 88ea2203e263bcdd1e54d3c4abc558fb42a1c895..bd4cfac6b5aa69e8dbc6cec34c02ca59a8399912 100644 (file)
@@ -471,10 +471,9 @@ void gpmi_nfc_apply_timings(struct gpmi_nand_data *this)
        udelay(dll_wait_time_us);
 }
 
-int gpmi_setup_data_interface(struct mtd_info *mtd, int chipnr,
+int gpmi_setup_data_interface(struct nand_chip *chip, int chipnr,
                              const struct nand_data_interface *conf)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        struct gpmi_nand_data *this = nand_get_controller_data(chip);
        const struct nand_sdr_timings *sdr;
 
index 69cd0cbde4f2070eb5bfcd6dd3c51158b6625320..d0b79bac2728072ff359a9137cdedac4fe13b67a 100644 (file)
@@ -178,7 +178,7 @@ int gpmi_is_ready(struct gpmi_nand_data *, unsigned chip);
 int gpmi_send_command(struct gpmi_nand_data *);
 int gpmi_enable_clk(struct gpmi_nand_data *this);
 int gpmi_disable_clk(struct gpmi_nand_data *this);
-int gpmi_setup_data_interface(struct mtd_info *mtd, int chipnr,
+int gpmi_setup_data_interface(struct nand_chip *chip, int chipnr,
                              const struct nand_data_interface *conf);
 void gpmi_nfc_apply_timings(struct gpmi_nand_data *this);
 int gpmi_read_data(struct gpmi_nand_data *, void *buf, int len);
index 1f4e75f8fa3e952caddbe316f16c9ad6c1f5a849..22481e9bfefcc49fefaba4ca8559254ad158dd35 100644 (file)
@@ -2250,11 +2250,10 @@ static struct nand_bbt_descr bbt_mirror_descr = {
        .pattern = bbt_mirror_pattern
 };
 
-static int marvell_nfc_setup_data_interface(struct mtd_info *mtd, int chipnr,
+static int marvell_nfc_setup_data_interface(struct nand_chip *chip, int chipnr,
                                            const struct nand_data_interface
                                            *conf)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        struct marvell_nand_chip *marvell_nand = to_marvell_nand(chip);
        struct marvell_nfc *nfc = to_marvell_nfc(chip->controller);
        unsigned int period_ns = 1000000000 / clk_get_rate(nfc->core_clk) * 2;
index cf8c42fb8feb15c7e9050ed87138d4198345dd9e..42f9dc2cd172603c39b4d988da665cd663ca64b0 100644 (file)
@@ -503,10 +503,10 @@ static void mtk_nfc_write_buf(struct nand_chip *chip, const u8 *buf, int len)
                mtk_nfc_write_byte(chip, buf[i]);
 }
 
-static int mtk_nfc_setup_data_interface(struct mtd_info *mtd, int csline,
+static int mtk_nfc_setup_data_interface(struct nand_chip *chip, int csline,
                                        const struct nand_data_interface *conf)
 {
-       struct mtk_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
+       struct mtk_nfc *nfc = nand_get_controller_data(chip);
        const struct nand_sdr_timings *timings;
        u32 rate, tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt;
 
index ec150e19a368ef50a83ac323cdd4b5ae662dd76f..895f85ee29dbb0d191435f337a2000d5368913cc 100644 (file)
@@ -137,7 +137,7 @@ struct mxc_nand_devtype_data {
        u32 (*get_ecc_status)(struct mxc_nand_host *);
        const struct mtd_ooblayout_ops *ooblayout;
        void (*select_chip)(struct nand_chip *chip, int cs);
-       int (*setup_data_interface)(struct mtd_info *mtd, int csline,
+       int (*setup_data_interface)(struct nand_chip *chip, int csline,
                                    const struct nand_data_interface *conf);
        void (*enable_hwecc)(struct nand_chip *chip, bool enable);
 
@@ -1139,11 +1139,10 @@ static void preset_v1(struct mtd_info *mtd)
        writew(0x4, NFC_V1_V2_WRPROT);
 }
 
-static int mxc_nand_v2_setup_data_interface(struct mtd_info *mtd, int csline,
+static int mxc_nand_v2_setup_data_interface(struct nand_chip *chip, int csline,
                                        const struct nand_data_interface *conf)
 {
-       struct nand_chip *nand_chip = mtd_to_nand(mtd);
-       struct mxc_nand_host *host = nand_get_controller_data(nand_chip);
+       struct mxc_nand_host *host = nand_get_controller_data(chip);
        int tRC_min_ns, tRC_ps, ret;
        unsigned long rate, rate_round;
        const struct nand_sdr_timings *timings;
index a7575aa68c4802b2fc31e796a11f0778b23b0c68..0a89ab6637286e783e47aafc5b72a833d57b3c11 100644 (file)
@@ -1200,7 +1200,6 @@ EXPORT_SYMBOL_GPL(nand_set_features);
  */
 static int nand_reset_data_interface(struct nand_chip *chip, int chipnr)
 {
-       struct mtd_info *mtd = nand_to_mtd(chip);
        int ret;
 
        if (!chip->setup_data_interface)
@@ -1221,7 +1220,7 @@ static int nand_reset_data_interface(struct nand_chip *chip, int chipnr)
         */
 
        onfi_fill_data_interface(chip, NAND_SDR_IFACE, 0);
-       ret = chip->setup_data_interface(mtd, chipnr, &chip->data_interface);
+       ret = chip->setup_data_interface(chip, chipnr, &chip->data_interface);
        if (ret)
                pr_err("Failed to configure data interface to SDR timing mode 0\n");
 
@@ -1243,7 +1242,6 @@ static int nand_reset_data_interface(struct nand_chip *chip, int chipnr)
  */
 static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
 {
-       struct mtd_info *mtd = nand_to_mtd(chip);
        u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
                chip->onfi_timing_mode_default,
        };
@@ -1263,7 +1261,7 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
        }
 
        /* Change the mode on the controller side */
-       ret = chip->setup_data_interface(mtd, chipnr, &chip->data_interface);
+       ret = chip->setup_data_interface(chip, chipnr, &chip->data_interface);
        if (ret)
                return ret;
 
@@ -1316,7 +1314,6 @@ err_reset_chip:
  */
 static int nand_init_data_interface(struct nand_chip *chip)
 {
-       struct mtd_info *mtd = nand_to_mtd(chip);
        int modes, mode, ret;
 
        if (!chip->setup_data_interface)
@@ -1345,7 +1342,7 @@ static int nand_init_data_interface(struct nand_chip *chip)
                 * Pass NAND_DATA_IFACE_CHECK_ONLY to only check if the
                 * controller supports the requested timings.
                 */
-               ret = chip->setup_data_interface(mtd,
+               ret = chip->setup_data_interface(chip,
                                                 NAND_DATA_IFACE_CHECK_ONLY,
                                                 &chip->data_interface);
                if (!ret) {
index 1d549f5e53f5a84771c9a6d2162ed431560b4635..1f70eb35320b2893cc3c0215c07e3df1572a28fd 100644 (file)
@@ -820,9 +820,10 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
        return -ENODEV;
 }
 
-static int s3c2410_nand_setup_data_interface(struct mtd_info *mtd, int csline,
+static int s3c2410_nand_setup_data_interface(struct nand_chip *chip, int csline,
                                        const struct nand_data_interface *conf)
 {
+       struct mtd_info *mtd = nand_to_mtd(chip);
        struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
        struct s3c2410_platform_nand *pdata = info->platform;
        const struct nand_sdr_timings *timings;
index fe30fb589ffb90388dfeda74d53bf0c60c00208a..a3700b79bdebc13823efd119967f7ed69af282ef 100644 (file)
@@ -1468,10 +1468,9 @@ static int _sunxi_nand_lookup_timing(const s32 *lut, int lut_size, u32 duration,
 #define sunxi_nand_lookup_timing(l, p, c) \
                        _sunxi_nand_lookup_timing(l, ARRAY_SIZE(l), p, c)
 
-static int sunxi_nfc_setup_data_interface(struct mtd_info *mtd, int csline,
+static int sunxi_nfc_setup_data_interface(struct nand_chip *nand, int csline,
                                        const struct nand_data_interface *conf)
 {
-       struct nand_chip *nand = mtd_to_nand(mtd);
        struct sunxi_nand_chip *chip = to_sunxi_nand(nand);
        struct sunxi_nfc *nfc = to_sunxi_nfc(chip->nand.controller);
        const struct nand_sdr_timings *timings;
index c21a0f2d26fcf22c5929a5d626eca0f31742103f..bf7012099790f08a2a10aa93fb1e631e4ed2c4b4 100644 (file)
@@ -479,11 +479,10 @@ static u32 to_ticks(int kHz, int ps)
        return DIV_ROUND_UP_ULL((u64)kHz * ps, NSEC_PER_SEC);
 }
 
-static int tango_set_timings(struct mtd_info *mtd, int csline,
+static int tango_set_timings(struct nand_chip *chip, int csline,
                             const struct nand_data_interface *conf)
 {
        const struct nand_sdr_timings *sdr = nand_get_sdr_timings(conf);
-       struct nand_chip *chip = mtd_to_nand(mtd);
        struct tango_nfc *nfc = to_tango_nfc(chip->controller);
        struct tango_chip *tchip = to_tango_chip(chip);
        u32 Trdy, Textw, Twc, Twpw, Tacc, Thold, Trpw, Textr;
index 1088741eed1db898c4aa6c7d8afe1b6d0098a254..9767e29d74e2924b46e18fc5625ccfbce075f920 100644 (file)
@@ -814,10 +814,9 @@ static void tegra_nand_setup_timing(struct tegra_nand_controller *ctrl,
        writel_relaxed(reg, ctrl->regs + TIMING_2);
 }
 
-static int tegra_nand_setup_data_interface(struct mtd_info *mtd, int csline,
+static int tegra_nand_setup_data_interface(struct nand_chip *chip, int csline,
                                        const struct nand_data_interface *conf)
 {
-       struct nand_chip *chip = mtd_to_nand(mtd);
        struct tegra_nand_controller *ctrl = to_tegra_ctrl(chip->controller);
        const struct nand_sdr_timings *timings;
 
index 14ce2b0782060bbc80641cd94d9e655fa85f73ea..5bfb9d543a8a11315601f8da83df8db8dc2f72e3 100644 (file)
@@ -1304,7 +1304,7 @@ struct nand_chip {
        int (*get_features)(struct nand_chip *chip, int feature_addr,
                            uint8_t *subfeature_para);
        int (*setup_read_retry)(struct nand_chip *chip, int retry_mode);
-       int (*setup_data_interface)(struct mtd_info *mtd, int chipnr,
+       int (*setup_data_interface)(struct nand_chip *chip, int chipnr,
                                    const struct nand_data_interface *conf);
 
        int chip_delay;