All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>,
	u-boot@lists.denx.de
Cc: Peng Fan <peng.fan@nxp.com>,
	Markus Niebel <Markus.Niebel@ew.tq-group.com>
Subject: Re: [PATCH 1/2] mmc: add helper to query max enhanced part size
Date: Thu, 23 Sep 2021 20:58:20 +0900	[thread overview]
Message-ID: <2ac1841d-ec38-07f2-268e-a5ddcb8e54d2@samsung.com> (raw)
In-Reply-To: <1d862733e0d4ae632eb036de13aaf048b31b8bdb.1632313515.git.matthias.schiffer@ew.tq-group.com>

Hi,

On 9/22/21 9:30 PM, Matthias Schiffer wrote:
> From: Markus Niebel <Markus.Niebel@ew.tq-group.com>
> 
> This helper will be used later on in an extension of the mmc
> command.
> 
> Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
> Signed-off-by: Matthias Schiffer <matthias.schiffer@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.

> +		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.

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);
>  
> 


  parent reply	other threads:[~2021-09-23 11:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210922123104epcas1p4ac210f3dfb4a2900f4a3b172953663b6@epcas1p4.samsung.com>
2021-09-22 12:30 ` [PATCH 1/2] mmc: add helper to query max enhanced part size Matthias Schiffer
2021-09-22 12:30   ` [PATCH 2/2] cmd/mmc: add subcommand to query max enhanced partition size Matthias Schiffer
2021-09-23 12:03     ` Jaehoon Chung
2021-09-23 11:58   ` Jaehoon Chung [this message]
2021-09-23 12:55     ` [PATCH 1/2] mmc: add helper to query max enhanced part size Matthias Schiffer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ac1841d-ec38-07f2-268e-a5ddcb8e54d2@samsung.com \
    --to=jh80.chung@samsung.com \
    --cc=Markus.Niebel@ew.tq-group.com \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.