Re: [PATCH v3 2/2] mci: implement command to switch a mmc device to enhanced mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
> +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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux