On Thu, 2021-09-23 at 20:58 +0900, Jaehoon Chung wrote: > Hi, > > On 9/22/21 9:30 PM, Matthias Schiffer wrote: > > From: Markus Niebel <markus.nie...@ew.tq-group.com> > > > > This helper will be used later on in an extension of the mmc > > command. > > > > Signed-off-by: Markus Niebel <markus.nie...@ew.tq-group.com> > > Signed-off-by: Matthias Schiffer <matthias.schif...@ew.tq-group.com> > > --- > > drivers/mmc/mmc.c | 38 ++++++++++++++++++++++++++++++++++++++ > > include/mmc.h | 1 + > > 2 files changed, 39 insertions(+) > > > > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c > > index d3babbfeb1c..c1b1ef7eb0b 100644 > > --- a/drivers/mmc/mmc.c > > +++ b/drivers/mmc/mmc.c > > @@ -1039,6 +1039,44 @@ int mmc_switch_part(struct mmc *mmc, unsigned int > > part_num) > > } > > > > #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) > > +int mmc_max_enhanced_size_sectors(struct mmc *mmc, u64 *size) > > +{ > > + u64 sz; > > + int err; > > + > > + ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN); > > + > > + if (IS_SD(mmc) || mmc->version < MMC_VERSION_4_41) { > > + pr_err("eMMC >= 4.4 required for enhanced user data area\n"); > > Error log is considering about only eMMC. It can be SD-card.
This check and message were taken from mmc_hwpart_config(). I think it is okay (after all it tells you "eMMC [...] required [...]" if you try the command on an SD card), but I can extend the message if you want. I also noticed another slight difference between the check and the message: The check is for eMMC 4.41, while the message talks about eMMC 4.4. I'd like to make both match, but I don't know whether 4.4 or 4.41 is the correct requirement. > > > + return -EMEDIUMTYPE; > > + } > > + > > + if (!(mmc->part_support & PART_SUPPORT)) { > > + pr_err("Card does not support partitioning\n"); > > + return -EMEDIUMTYPE; > > + } > > + > > + if (!mmc->hc_wp_grp_size) { > > + pr_err("Card does not define HC WP group size\n"); > > + return -EMEDIUMTYPE; > > + } > > + > > + err = mmc_send_ext_csd(mmc, ext_csd); > > + if (err) > > + return err; > > + > > + sz = > > + (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT + 2] << 16) + > > + (ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT + 1] << 8) + > > + ext_csd[EXT_CSD_MAX_ENH_SIZE_MULT]; > > + sz *= ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]; > > + sz *= ext_csd[EXT_CSD_HC_WP_GRP_SIZE]; > > + sz *= SZ_1K; > > To use the num of sector, i think better that is adding Comment. > And using not "sz" as variable. It seems to describe real size, not sector. > According to spec, it's 512kByte. It can be confused. Makes sense, I'll change the variable name. > > Best Regards, > Jaehoon Chung > > > + *size = sz; > > + > > + return 0; > > +} > > + > > int mmc_hwpart_config(struct mmc *mmc, > > const struct mmc_hwpart_conf *conf, > > enum mmc_hwpart_conf_mode mode) > > diff --git a/include/mmc.h b/include/mmc.h > > index b92e2553402..3e1fc82d9b4 100644 > > --- a/include/mmc.h > > +++ b/include/mmc.h > > @@ -846,6 +846,7 @@ void print_mmc_devices(char separator); > > */ > > int get_mmc_num(void); > > int mmc_switch_part(struct mmc *mmc, unsigned int part_num); > > +int mmc_max_enhanced_size_sectors(struct mmc *mmc, u64 *size); > > int mmc_hwpart_config(struct mmc *mmc, const struct mmc_hwpart_conf *conf, > > enum mmc_hwpart_conf_mode mode); > > > > > >