]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp()
authorTudor Ambarus <tudor.ambarus@microchip.com>
Sat, 6 Mar 2021 09:50:00 +0000 (11:50 +0200)
committerTudor Ambarus <tudor.ambarus@microchip.com>
Mon, 15 Mar 2021 16:01:47 +0000 (18:01 +0200)
spi_nor_parse_sfdp(nor, nor->params);
passes for the second argument a member within the first argument.
Drop the second argument and obtain it directly from the first,
and do it across all the children functions. This is a follow up for
'commit 69a8eed58cc0 ("mtd: spi-nor: Don't copy self-pointing struct around")'

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20210306095002.22983-4-tudor.ambarus@microchip.com
drivers/mtd/spi-nor/core.c
drivers/mtd/spi-nor/core.h
drivers/mtd/spi-nor/issi.c
drivers/mtd/spi-nor/macronix.c
drivers/mtd/spi-nor/sfdp.c
drivers/mtd/spi-nor/sfdp.h
drivers/mtd/spi-nor/spansion.c
drivers/mtd/spi-nor/winbond.c

index dd35ec778339a81105558306619a412544c46c8f..d5dbbad8bd328eb85d5d3e071ec28a94cf1c58d7 100644 (file)
@@ -2626,22 +2626,20 @@ void spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,
 
 int spi_nor_post_bfpt_fixups(struct spi_nor *nor,
                             const struct sfdp_parameter_header *bfpt_header,
-                            const struct sfdp_bfpt *bfpt,
-                            struct spi_nor_flash_parameter *params)
+                            const struct sfdp_bfpt *bfpt)
 {
        int ret;
 
        if (nor->manufacturer && nor->manufacturer->fixups &&
            nor->manufacturer->fixups->post_bfpt) {
                ret = nor->manufacturer->fixups->post_bfpt(nor, bfpt_header,
-                                                          bfpt, params);
+                                                          bfpt);
                if (ret)
                        return ret;
        }
 
        if (nor->info->fixups && nor->info->fixups->post_bfpt)
-               return nor->info->fixups->post_bfpt(nor, bfpt_header, bfpt,
-                                                   params);
+               return nor->info->fixups->post_bfpt(nor, bfpt_header, bfpt);
 
        return 0;
 }
@@ -2896,7 +2894,7 @@ static void spi_nor_sfdp_init_params(struct spi_nor *nor)
 
        memcpy(&sfdp_params, nor->params, sizeof(sfdp_params));
 
-       if (spi_nor_parse_sfdp(nor, nor->params)) {
+       if (spi_nor_parse_sfdp(nor)) {
                memcpy(nor->params, &sfdp_params, sizeof(*nor->params));
                nor->addr_width = 0;
                nor->flags &= ~SNOR_F_4B_OPCODES;
index 4a3f7f150b5d677f74c97153af659f1185587341..db07832ee66c4195d21a3b0ec55570c319dfaece 100644 (file)
@@ -261,8 +261,7 @@ struct spi_nor_fixups {
        void (*default_init)(struct spi_nor *nor);
        int (*post_bfpt)(struct spi_nor *nor,
                         const struct sfdp_parameter_header *bfpt_header,
-                        const struct sfdp_bfpt *bfpt,
-                        struct spi_nor_flash_parameter *params);
+                        const struct sfdp_bfpt *bfpt);
        void (*post_sfdp)(struct spi_nor *nor);
 };
 
@@ -470,8 +469,7 @@ void spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,
 
 int spi_nor_post_bfpt_fixups(struct spi_nor *nor,
                             const struct sfdp_parameter_header *bfpt_header,
-                            const struct sfdp_bfpt *bfpt,
-                            struct spi_nor_flash_parameter *params);
+                            const struct sfdp_bfpt *bfpt);
 
 static struct spi_nor __maybe_unused *mtd_to_spi_nor(struct mtd_info *mtd)
 {
index ffcb60e54a804071d9f7a93c478331f9f8ae6f7f..1e5bb5408b6835c56eff58cced8bfdc99c241547 100644 (file)
@@ -11,8 +11,7 @@
 static int
 is25lp256_post_bfpt_fixups(struct spi_nor *nor,
                           const struct sfdp_parameter_header *bfpt_header,
-                          const struct sfdp_bfpt *bfpt,
-                          struct spi_nor_flash_parameter *params)
+                          const struct sfdp_bfpt *bfpt)
 {
        /*
         * IS25LP256 supports 4B opcodes, but the BFPT advertises a
index 9203abaac2297c94af83d392c138369772c9959f..6c2680b4cdad462adf95097d01b202a2371868d3 100644 (file)
@@ -11,8 +11,7 @@
 static int
 mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
                            const struct sfdp_parameter_header *bfpt_header,
-                           const struct sfdp_bfpt *bfpt,
-                           struct spi_nor_flash_parameter *params)
+                           const struct sfdp_bfpt *bfpt)
 {
        /*
         * MX25L25635F supports 4B opcodes but MX25L25635E does not.
index 25142ec4737b79f49cd40f101ad34b8184d183e9..23c28e91f698ea9be4ae5da8214b66af4c22e5b8 100644 (file)
@@ -405,8 +405,6 @@ static void spi_nor_regions_sort_erase_types(struct spi_nor_erase_map *map)
  * @nor:               pointer to a 'struct spi_nor'
  * @bfpt_header:       pointer to the 'struct sfdp_parameter_header' describing
  *                     the Basic Flash Parameter Table length and version
- * @params:            pointer to the 'struct spi_nor_flash_parameter' to be
- *                     filled
  *
  * The Basic Flash Parameter Table is the main and only mandatory table as
  * defined by the SFDP (JESD216) specification.
@@ -431,9 +429,9 @@ static void spi_nor_regions_sort_erase_types(struct spi_nor_erase_map *map)
  * Return: 0 on success, -errno otherwise.
  */
 static int spi_nor_parse_bfpt(struct spi_nor *nor,
-                             const struct sfdp_parameter_header *bfpt_header,
-                             struct spi_nor_flash_parameter *params)
+                             const struct sfdp_parameter_header *bfpt_header)
 {
+       struct spi_nor_flash_parameter *params = nor->params;
        struct spi_nor_erase_map *map = &params->erase_map;
        struct spi_nor_erase_type *erase_type = map->erase_type;
        struct sfdp_bfpt bfpt;
@@ -552,8 +550,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 
        /* Stop here if not JESD216 rev A or later. */
        if (bfpt_header->length == BFPT_DWORD_MAX_JESD216)
-               return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
-                                               params);
+               return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
 
        /* Page size: this field specifies 'N' so the page size = 2^N bytes. */
        val = bfpt.dwords[BFPT_DWORD(11)];
@@ -614,8 +611,8 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 
        /* Stop here if not JESD216 rev C or later. */
        if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
-               return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
-                                               params);
+               return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
+
        /* 8D-8D-8D command extension. */
        switch (bfpt.dwords[BFPT_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
        case BFPT_DWORD18_CMD_EXT_REP:
@@ -635,7 +632,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
                return -EOPNOTSUPP;
        }
 
-       return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params);
+       return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
 }
 
 /**
@@ -800,18 +797,14 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region,
 /**
  * spi_nor_init_non_uniform_erase_map() - initialize the non-uniform erase map
  * @nor:       pointer to a 'struct spi_nor'
- * @params:     pointer to a duplicate 'struct spi_nor_flash_parameter' that is
- *              used for storing SFDP parsed data
  * @smpt:      pointer to the sector map parameter table
  *
  * Return: 0 on success, -errno otherwise.
  */
-static int
-spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
-                                  struct spi_nor_flash_parameter *params,
-                                  const u32 *smpt)
+static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
+                                             const u32 *smpt)
 {
-       struct spi_nor_erase_map *map = &params->erase_map;
+       struct spi_nor_erase_map *map = &nor->params->erase_map;
        struct spi_nor_erase_type *erase = map->erase_type;
        struct spi_nor_erase_region *region;
        u64 offset;
@@ -889,8 +882,6 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
  * spi_nor_parse_smpt() - parse Sector Map Parameter Table
  * @nor:               pointer to a 'struct spi_nor'
  * @smpt_header:       sector map parameter table header
- * @params:            pointer to a duplicate 'struct spi_nor_flash_parameter'
- *                      that is used for storing SFDP parsed data
  *
  * This table is optional, but when available, we parse it to identify the
  * location and size of sectors within the main data array of the flash memory
@@ -899,8 +890,7 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
  * Return: 0 on success, -errno otherwise.
  */
 static int spi_nor_parse_smpt(struct spi_nor *nor,
-                             const struct sfdp_parameter_header *smpt_header,
-                             struct spi_nor_flash_parameter *params)
+                             const struct sfdp_parameter_header *smpt_header)
 {
        const u32 *sector_map;
        u32 *smpt;
@@ -928,11 +918,11 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,
                goto out;
        }
 
-       ret = spi_nor_init_non_uniform_erase_map(nor, params, sector_map);
+       ret = spi_nor_init_non_uniform_erase_map(nor, sector_map);
        if (ret)
                goto out;
 
-       spi_nor_regions_sort_erase_types(&params->erase_map);
+       spi_nor_regions_sort_erase_types(&nor->params->erase_map);
        /* fall through */
 out:
        kfree(smpt);
@@ -944,13 +934,11 @@ out:
  * @nor:               pointer to a 'struct spi_nor'.
  * @param_header:      pointer to the 'struct sfdp_parameter_header' describing
  *                     the 4-Byte Address Instruction Table length and version.
- * @params:            pointer to the 'struct spi_nor_flash_parameter' to be.
  *
  * Return: 0 on success, -errno otherwise.
  */
 static int spi_nor_parse_4bait(struct spi_nor *nor,
-                              const struct sfdp_parameter_header *param_header,
-                              struct spi_nor_flash_parameter *params)
+                              const struct sfdp_parameter_header *param_header)
 {
        static const struct sfdp_4bait reads[] = {
                { SNOR_HWCAPS_READ,             BIT(0) },
@@ -974,6 +962,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
                { 0u /* not used */,            BIT(11) },
                { 0u /* not used */,            BIT(12) },
        };
+       struct spi_nor_flash_parameter *params = nor->params;
        struct spi_nor_pp_command *params_pp = params->page_programs;
        struct spi_nor_erase_map *map = &params->erase_map;
        struct spi_nor_erase_type *erase_type = map->erase_type;
@@ -1130,13 +1119,11 @@ out:
  * @nor:               pointer to a 'struct spi_nor'
  * @profile1_header:   pointer to the 'struct sfdp_parameter_header' describing
  *                     the Profile 1.0 Table length and version.
- * @params:            pointer to the 'struct spi_nor_flash_parameter' to be.
  *
  * Return: 0 on success, -errno otherwise.
  */
 static int spi_nor_parse_profile1(struct spi_nor *nor,
-                                 const struct sfdp_parameter_header *profile1_header,
-                                 struct spi_nor_flash_parameter *params)
+                                 const struct sfdp_parameter_header *profile1_header)
 {
        u32 *dwords, addr;
        size_t len;
@@ -1160,14 +1147,14 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
 
         /* Set the Read Status Register dummy cycles and dummy address bytes. */
        if (dwords[0] & PROFILE1_DWORD1_RDSR_DUMMY)
-               params->rdsr_dummy = 8;
+               nor->params->rdsr_dummy = 8;
        else
-               params->rdsr_dummy = 4;
+               nor->params->rdsr_dummy = 4;
 
        if (dwords[0] & PROFILE1_DWORD1_RDSR_ADDR_BYTES)
-               params->rdsr_addr_nbytes = 4;
+               nor->params->rdsr_addr_nbytes = 4;
        else
-               params->rdsr_addr_nbytes = 0;
+               nor->params->rdsr_addr_nbytes = 0;
 
        /*
         * We don't know what speed the controller is running at. Find the
@@ -1193,7 +1180,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
        dummy = round_up(dummy, 2);
 
        /* Update the fast read settings. */
-       spi_nor_set_read_settings(&params->reads[SNOR_CMD_READ_8_8_8_DTR],
+       spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR],
                                  0, dummy, opcode,
                                  SNOR_PROTO_8_8_8_DTR);
 
@@ -1210,13 +1197,11 @@ out:
  * @nor:               pointer to a 'struct spi_nor'
  * @sccr_header:       pointer to the 'struct sfdp_parameter_header' describing
  *                     the SCCR Map table length and version.
- * @params:            pointer to the 'struct spi_nor_flash_parameter' to be.
  *
  * Return: 0 on success, -errno otherwise.
  */
 static int spi_nor_parse_sccr(struct spi_nor *nor,
-                             const struct sfdp_parameter_header *sccr_header,
-                             struct spi_nor_flash_parameter *params)
+                             const struct sfdp_parameter_header *sccr_header)
 {
        u32 *dwords, addr;
        size_t len;
@@ -1245,8 +1230,6 @@ out:
 /**
  * spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters.
  * @nor:               pointer to a 'struct spi_nor'
- * @params:            pointer to the 'struct spi_nor_flash_parameter' to be
- *                     filled
  *
  * The Serial Flash Discoverable Parameters are described by the JEDEC JESD216
  * specification. This is a standard which tends to supported by almost all
@@ -1256,8 +1239,7 @@ out:
  *
  * Return: 0 on success, -errno otherwise.
  */
-int spi_nor_parse_sfdp(struct spi_nor *nor,
-                      struct spi_nor_flash_parameter *params)
+int spi_nor_parse_sfdp(struct spi_nor *nor)
 {
        const struct sfdp_parameter_header *param_header, *bfpt_header;
        struct sfdp_parameter_header *param_headers = NULL;
@@ -1326,7 +1308,7 @@ int spi_nor_parse_sfdp(struct spi_nor *nor,
                        bfpt_header = param_header;
        }
 
-       err = spi_nor_parse_bfpt(nor, bfpt_header, params);
+       err = spi_nor_parse_bfpt(nor, bfpt_header);
        if (err)
                goto exit;
 
@@ -1336,19 +1318,19 @@ int spi_nor_parse_sfdp(struct spi_nor *nor,
 
                switch (SFDP_PARAM_HEADER_ID(param_header)) {
                case SFDP_SECTOR_MAP_ID:
-                       err = spi_nor_parse_smpt(nor, param_header, params);
+                       err = spi_nor_parse_smpt(nor, param_header);
                        break;
 
                case SFDP_4BAIT_ID:
-                       err = spi_nor_parse_4bait(nor, param_header, params);
+                       err = spi_nor_parse_4bait(nor, param_header);
                        break;
 
                case SFDP_PROFILE1_ID:
-                       err = spi_nor_parse_profile1(nor, param_header, params);
+                       err = spi_nor_parse_profile1(nor, param_header);
                        break;
 
                case SFDP_SCCR_MAP_ID:
-                       err = spi_nor_parse_sccr(nor, param_header, params);
+                       err = spi_nor_parse_sccr(nor, param_header);
                        break;
 
                default:
index 89152ae1cf3e28bb007e368290cf0cbb0293b09e..bbf80d2990ab6b5bfacd1af374b2dfd5a398d793 100644 (file)
@@ -107,7 +107,6 @@ struct sfdp_parameter_header {
        u8              id_msb;
 };
 
-int spi_nor_parse_sfdp(struct spi_nor *nor,
-                      struct spi_nor_flash_parameter *params);
+int spi_nor_parse_sfdp(struct spi_nor *nor);
 
 #endif /* __LINUX_MTD_SFDP_H */
index b0c5521c1e278cd42fb700d4a5223b46e78a4604..ee82dcd75310c52b24f0524b620504cf38af5176 100644 (file)
@@ -142,8 +142,7 @@ static void s28hs512t_post_sfdp_fixup(struct spi_nor *nor)
 
 static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor,
                                     const struct sfdp_parameter_header *bfpt_header,
-                                    const struct sfdp_bfpt *bfpt,
-                                    struct spi_nor_flash_parameter *params)
+                                    const struct sfdp_bfpt *bfpt)
 {
        /*
         * The BFPT table advertises a 512B page size but the page size is
@@ -162,9 +161,9 @@ static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor,
                return ret;
 
        if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3V_PGSZ)
-               params->page_size = 512;
+               nor->params->page_size = 512;
        else
-               params->page_size = 256;
+               nor->params->page_size = 256;
 
        return 0;
 }
@@ -178,8 +177,7 @@ static struct spi_nor_fixups s28hs512t_fixups = {
 static int
 s25fs_s_post_bfpt_fixups(struct spi_nor *nor,
                         const struct sfdp_parameter_header *bfpt_header,
-                        const struct sfdp_bfpt *bfpt,
-                        struct spi_nor_flash_parameter *params)
+                        const struct sfdp_bfpt *bfpt)
 {
        /*
         * The S25FS-S chip family reports 512-byte pages in BFPT but
@@ -187,7 +185,7 @@ s25fs_s_post_bfpt_fixups(struct spi_nor *nor,
         * of 256 bytes.  Overwrite the page size advertised by BFPT
         * to get the writes working.
         */
-       params->page_size = 256;
+       nor->params->page_size = 256;
 
        return 0;
 }
index e24bcb928be79879519b5b6332f7c3da3890e758..20b2c6f19d6f91aca28ebffd3d11a85083a8af6c 100644 (file)
@@ -11,8 +11,7 @@
 static int
 w25q256_post_bfpt_fixups(struct spi_nor *nor,
                         const struct sfdp_parameter_header *bfpt_header,
-                        const struct sfdp_bfpt *bfpt,
-                        struct spi_nor_flash_parameter *params)
+                        const struct sfdp_bfpt *bfpt)
 {
        /*
         * W25Q256JV supports 4B opcodes but W25Q256FV does not.