mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v3 2/2] mci: implement command to switch a mmc device to enhanced mode
Date: Wed, 10 Oct 2018 08:44:29 +0200	[thread overview]
Message-ID: <20181010064429.dbslv4umft4fetdk@pengutronix.de> (raw)
In-Reply-To: <20181008082921.26922-2-u.kleine-koenig@pengutronix.de>

On Mon, Oct 08, 2018 at 10:29:21AM +0200, Uwe Kleine-König wrote:
> The command structure allows adding more subcommands and is designed to
> match the Linux program mmc from the mmc-utils. So later more commands
> can easily be added if need be.
> 
> Compared to mmc-utils'
> 
> 	mmc enh_area set <-y|-n|-c> <start KiB> <length KiB> <device>
> 
> the command that is implemented here (
> 
> 	mmc enh_area setmax [-c] <device>
> 
> ) is easier to use (because you don't have to check the maximal allowed
> size by reading some registers and calculate the available size from
> them (which then must be calculated back to register values by the mmc
> command)) but less flexible as it doesn't allow all the crazy
> possibilities specified in the eMMC standard but just creates an
> enhanced area with maximal size.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> +static u8 *mci_get_ext_csd(struct mci *mci)
> +{
> +	u8 *ext_csd;
> +	int ret;
> +
> +	ext_csd = xmalloc(512);
> +
> +	ret = mci_send_ext_csd(mci, ext_csd);
> +	if (ret) {
> +		printf("Failure to read EXT_CSD register\n");
> +		return ERR_PTR(-EIO);

Please free malloced memory.

> +	}
> +
> +	return ext_csd;
> +}
> +
> +/* enh_area setmax [-c] /dev/mmcX */
> +static int do_mmc_enh_area(int argc, char *argv[])
> +{
> +	char *devpath;
> +	struct mci *mci;
> +	u8 *ext_csd;
> +	int set_completed = 0;
> +	int ret;
> +
> +	if (argc < 2 || strcmp(argv[1], "setmax") != 0)
> +		goto usage;
> +
> +	if (argc == 3) {
> +		/* enh_area setmax /dev/mmcX */
> +		devpath = argv[2];
> +		set_completed = false;
> +	} else if (argc == 4 || strcmp(argv[2], "-c") == 0) {
> +		/* enh_area setmax -c /dev/mmcX */
> +		devpath = argv[3];
> +		set_completed = true;
> +	} else {

This option parsing already is quite hard to read and will be harder if
it is extended in the future. Can't we use getopt() here?

Usage:
enh_area [options] <mmcdev>
 -m	Use maximum available space
 -c	complete partitioning

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-10-10  6:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 13:28 [PATCH v2 1/2] mci: drop unused parameter from mci_switch() Uwe Kleine-König
2018-01-19 13:28 ` [PATCH v2 2/2] mci: implement command to switch a mmc device to enhanced mode Uwe Kleine-König
2018-01-22  8:12   ` Sascha Hauer
2018-10-02  8:33     ` Uwe Kleine-König
2018-10-08  7:49       ` Sascha Hauer
2018-10-08  8:29         ` [PATCH v3 1/2] mci: provide wrapper for mci_get_device_by_name ∘ devpath_to_name Uwe Kleine-König
2018-10-08  8:29           ` [PATCH v3 2/2] mci: implement command to switch a mmc device to enhanced mode Uwe Kleine-König
2018-10-10  6:44             ` Sascha Hauer [this message]
2018-10-02  9:03   ` [PATCH v2] " Uwe Kleine-König
2018-01-22  8:48 ` [PATCH v2 1/2] mci: drop unused parameter from mci_switch() Sascha Hauer

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=20181010064429.dbslv4umft4fetdk@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=u.kleine-koenig@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox