* [PATCHv4 2/2] mmc-utils: Allow for custom sanitize timeout
@ 2022-10-15 11:19 Christian Löhle
2022-10-15 11:31 ` Christian Löhle
2022-10-24 17:01 ` Ulf Hansson
0 siblings, 2 replies; 3+ messages in thread
From: Christian Löhle @ 2022-10-15 11:19 UTC (permalink / raw)
To: Ulf Hansson, Linux MMC List; +Cc: Avri Altman
Some cards with certain preconditioning require a higher timeout
when sanitizing. Let the user set the maximum timeout.
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
-v4: Fix argument order in help text
mmc.c | 2 +-
mmc_cmds.c | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/mmc.c b/mmc.c
index 6c56387..4c09b79 100644
--- a/mmc.c
+++ b/mmc.c
@@ -150,7 +150,7 @@ static struct Command commands[] = {
NULL
},
{ do_sanitize, -1,
- "sanitize", "<device>\n"
+ "sanitize", "<device> [timeout_ms]\n"
"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device.",
NULL
},
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 3337ded..9e0571f 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1986,12 +1986,16 @@ int do_sanitize(int nargs, char **argv)
{
int fd, ret;
char *device;
+ unsigned int timeout = 0;
- if (nargs != 2) {
- fprintf(stderr, "Usage: mmc sanitize </path/to/mmcblkX>\n");
+ if (nargs != 2 && nargs != 3) {
+ fprintf(stderr, "Usage: mmc sanitize </path/to/mmcblkX> [timeout_in_ms]\n");
exit(1);
}
+ if (nargs == 3)
+ timeout = strtol(argv[2], NULL, 10);
+
device = argv[1];
fd = open(device, O_RDWR);
@@ -2000,7 +2004,7 @@ int do_sanitize(int nargs, char **argv)
exit(1);
}
- ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1, 0);
+ ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1, timeout);
if (ret) {
fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
1, EXT_CSD_SANITIZE_START, device);
--
2.37.3
Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCHv4 2/2] mmc-utils: Allow for custom sanitize timeout
2022-10-15 11:19 [PATCHv4 2/2] mmc-utils: Allow for custom sanitize timeout Christian Löhle
@ 2022-10-15 11:31 ` Christian Löhle
2022-10-24 17:01 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Christian Löhle @ 2022-10-15 11:31 UTC (permalink / raw)
To: Christian Löhle, Ulf Hansson, Linux MMC List; +Cc: Avri Altman
> Some cards with certain preconditioning require a higher timeout when sanitizing. Let the user set the maximum > > timeout.
>
> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Forgot to add, my bad.
Regards,
Christian
Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHv4 2/2] mmc-utils: Allow for custom sanitize timeout
2022-10-15 11:19 [PATCHv4 2/2] mmc-utils: Allow for custom sanitize timeout Christian Löhle
2022-10-15 11:31 ` Christian Löhle
@ 2022-10-24 17:01 ` Ulf Hansson
1 sibling, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2022-10-24 17:01 UTC (permalink / raw)
To: Christian Löhle; +Cc: Linux MMC List, Avri Altman
On Sat, 15 Oct 2022 at 13:19, Christian Löhle <CLoehle@hyperstone.com> wrote:
>
> Some cards with certain preconditioning require a higher timeout
> when sanitizing. Let the user set the maximum timeout.
>
> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Applied to git.kernel.org/pub/scm//utils/mmc/mmc-utils.git master, thanks!
Kind regards
Uffe
> ---
> -v4: Fix argument order in help text
> mmc.c | 2 +-
> mmc_cmds.c | 10 +++++++---
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/mmc.c b/mmc.c
> index 6c56387..4c09b79 100644
> --- a/mmc.c
> +++ b/mmc.c
> @@ -150,7 +150,7 @@ static struct Command commands[] = {
> NULL
> },
> { do_sanitize, -1,
> - "sanitize", "<device>\n"
> + "sanitize", "<device> [timeout_ms]\n"
> "Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device.",
> NULL
> },
> diff --git a/mmc_cmds.c b/mmc_cmds.c
> index 3337ded..9e0571f 100644
> --- a/mmc_cmds.c
> +++ b/mmc_cmds.c
> @@ -1986,12 +1986,16 @@ int do_sanitize(int nargs, char **argv)
> {
> int fd, ret;
> char *device;
> + unsigned int timeout = 0;
>
> - if (nargs != 2) {
> - fprintf(stderr, "Usage: mmc sanitize </path/to/mmcblkX>\n");
> + if (nargs != 2 && nargs != 3) {
> + fprintf(stderr, "Usage: mmc sanitize </path/to/mmcblkX> [timeout_in_ms]\n");
> exit(1);
> }
>
> + if (nargs == 3)
> + timeout = strtol(argv[2], NULL, 10);
> +
> device = argv[1];
>
> fd = open(device, O_RDWR);
> @@ -2000,7 +2004,7 @@ int do_sanitize(int nargs, char **argv)
> exit(1);
> }
>
> - ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1, 0);
> + ret = write_extcsd_value(fd, EXT_CSD_SANITIZE_START, 1, timeout);
> if (ret) {
> fprintf(stderr, "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
> 1, EXT_CSD_SANITIZE_START, device);
> --
> 2.37.3
>
> Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz
> Managing Director: Dr. Jan Peter Berns.
> Commercial register of local courts: Freiburg HRB381782
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-24 18:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-15 11:19 [PATCHv4 2/2] mmc-utils: Allow for custom sanitize timeout Christian Löhle
2022-10-15 11:31 ` Christian Löhle
2022-10-24 17:01 ` Ulf Hansson
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.