* [PATCH] mmc: test: clean up mmc_test_cleanup()
@ 2021-01-19 7:37 Yue Hu
2021-01-20 14:07 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: Yue Hu @ 2021-01-19 7:37 UTC (permalink / raw)
To: ulf.hansson; +Cc: linux-mmc, linux-kernel, huyue2, zbestahu
From: Yue Hu <huyue2@yulong.com>
mmc_test_cleanup() has same body as __mmc_test_prepare() with write
except the character to memset().
Signed-off-by: Yue Hu <huyue2@yulong.com>
---
drivers/mmc/core/mmc_test.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
index f999b48..39a4788 100644
--- a/drivers/mmc/core/mmc_test.c
+++ b/drivers/mmc/core/mmc_test.c
@@ -624,7 +624,7 @@ static unsigned int mmc_test_capacity(struct mmc_card *card)
* Fill the first couple of sectors of the card with known data
* so that bad reads/writes can be detected
*/
-static int __mmc_test_prepare(struct mmc_test_card *test, int write)
+static int __mmc_test_prepare(struct mmc_test_card *test, int write, int val)
{
int ret, i;
@@ -633,7 +633,7 @@ static int __mmc_test_prepare(struct mmc_test_card *test, int write)
return ret;
if (write)
- memset(test->buffer, 0xDF, 512);
+ memset(test->buffer, val, 512);
else {
for (i = 0; i < 512; i++)
test->buffer[i] = i;
@@ -650,31 +650,17 @@ static int __mmc_test_prepare(struct mmc_test_card *test, int write)
static int mmc_test_prepare_write(struct mmc_test_card *test)
{
- return __mmc_test_prepare(test, 1);
+ return __mmc_test_prepare(test, 1, 0xDF);
}
static int mmc_test_prepare_read(struct mmc_test_card *test)
{
- return __mmc_test_prepare(test, 0);
+ return __mmc_test_prepare(test, 0, 0);
}
static int mmc_test_cleanup(struct mmc_test_card *test)
{
- int ret, i;
-
- ret = mmc_test_set_blksize(test, 512);
- if (ret)
- return ret;
-
- memset(test->buffer, 0, 512);
-
- for (i = 0; i < BUFFER_SIZE / 512; i++) {
- ret = mmc_test_buffer_transfer(test, test->buffer, i, 512, 1);
- if (ret)
- return ret;
- }
-
- return 0;
+ return __mmc_test_prepare(test, 1, 0);
}
/*******************************************************************/
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: test: clean up mmc_test_cleanup()
2021-01-19 7:37 [PATCH] mmc: test: clean up mmc_test_cleanup() Yue Hu
@ 2021-01-20 14:07 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2021-01-20 14:07 UTC (permalink / raw)
To: Yue Hu; +Cc: linux-mmc, Linux Kernel Mailing List, Yue Hu, zbestahu
On Tue, 19 Jan 2021 at 08:37, Yue Hu <zbestahu@gmail.com> wrote:
>
> From: Yue Hu <huyue2@yulong.com>
>
> mmc_test_cleanup() has same body as __mmc_test_prepare() with write
> except the character to memset().
>
> Signed-off-by: Yue Hu <huyue2@yulong.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/core/mmc_test.c | 24 +++++-------------------
> 1 file changed, 5 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc_test.c b/drivers/mmc/core/mmc_test.c
> index f999b48..39a4788 100644
> --- a/drivers/mmc/core/mmc_test.c
> +++ b/drivers/mmc/core/mmc_test.c
> @@ -624,7 +624,7 @@ static unsigned int mmc_test_capacity(struct mmc_card *card)
> * Fill the first couple of sectors of the card with known data
> * so that bad reads/writes can be detected
> */
> -static int __mmc_test_prepare(struct mmc_test_card *test, int write)
> +static int __mmc_test_prepare(struct mmc_test_card *test, int write, int val)
> {
> int ret, i;
>
> @@ -633,7 +633,7 @@ static int __mmc_test_prepare(struct mmc_test_card *test, int write)
> return ret;
>
> if (write)
> - memset(test->buffer, 0xDF, 512);
> + memset(test->buffer, val, 512);
> else {
> for (i = 0; i < 512; i++)
> test->buffer[i] = i;
> @@ -650,31 +650,17 @@ static int __mmc_test_prepare(struct mmc_test_card *test, int write)
>
> static int mmc_test_prepare_write(struct mmc_test_card *test)
> {
> - return __mmc_test_prepare(test, 1);
> + return __mmc_test_prepare(test, 1, 0xDF);
> }
>
> static int mmc_test_prepare_read(struct mmc_test_card *test)
> {
> - return __mmc_test_prepare(test, 0);
> + return __mmc_test_prepare(test, 0, 0);
> }
>
> static int mmc_test_cleanup(struct mmc_test_card *test)
> {
> - int ret, i;
> -
> - ret = mmc_test_set_blksize(test, 512);
> - if (ret)
> - return ret;
> -
> - memset(test->buffer, 0, 512);
> -
> - for (i = 0; i < BUFFER_SIZE / 512; i++) {
> - ret = mmc_test_buffer_transfer(test, test->buffer, i, 512, 1);
> - if (ret)
> - return ret;
> - }
> -
> - return 0;
> + return __mmc_test_prepare(test, 1, 0);
> }
>
> /*******************************************************************/
> --
> 1.9.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-20 14:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19 7:37 [PATCH] mmc: test: clean up mmc_test_cleanup() Yue Hu
2021-01-20 14:07 ` 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.