diff options
author | Nicholas Mc Guire <hofrat@osadl.org> | 2015-02-01 11:55:37 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-03-30 21:30:30 -0400 |
commit | e5860c18e68606446a10c3e926a2a0162c385cbf (patch) | |
tree | 095bbb1a3bc8e864e8dc37f1178b128c0f733398 | |
parent | 899b834a462921a087f92f705d9f85def5892242 (diff) |
mtd: pxa3xx_nand: cleanup wait_for_completion handling
return type of wait_for_completion_timeout is unsigned long not int, this
patch uses the return value of wait_for_completion_timeout in the condition
directly rather than assigning it to an incorrect type variable.
The variable used for handling the return of wait_for_cmpletion_timeout
was int but should be unsigned long, where it was not in use for
anything else and the return value in case of completion (>0) is not
used it was removed and wait_for_completion_timeout() used directly in
the if condition.
To make the timeout values a bit simpler to read and also handle all of
the corner cases correctly the declarations are moved to
msecs_to_jiffies().
The timeout declaration cleanup is just for readability
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | drivers/mtd/nand/pxa3xx_nand.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index b1ecb570d154..a4615fcc3d00 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c | |||
@@ -38,8 +38,8 @@ | |||
38 | 38 | ||
39 | #include <linux/platform_data/mtd-nand-pxa3xx.h> | 39 | #include <linux/platform_data/mtd-nand-pxa3xx.h> |
40 | 40 | ||
41 | #define CHIP_DELAY_TIMEOUT (2 * HZ/10) | 41 | #define CHIP_DELAY_TIMEOUT msecs_to_jiffies(200) |
42 | #define NAND_STOP_DELAY (2 * HZ/50) | 42 | #define NAND_STOP_DELAY msecs_to_jiffies(40) |
43 | #define PAGE_CHUNK_SIZE (2048) | 43 | #define PAGE_CHUNK_SIZE (2048) |
44 | 44 | ||
45 | /* | 45 | /* |
@@ -965,7 +965,7 @@ static void nand_cmdfunc(struct mtd_info *mtd, unsigned command, | |||
965 | { | 965 | { |
966 | struct pxa3xx_nand_host *host = mtd->priv; | 966 | struct pxa3xx_nand_host *host = mtd->priv; |
967 | struct pxa3xx_nand_info *info = host->info_data; | 967 | struct pxa3xx_nand_info *info = host->info_data; |
968 | int ret, exec_cmd; | 968 | int exec_cmd; |
969 | 969 | ||
970 | /* | 970 | /* |
971 | * if this is a x16 device ,then convert the input | 971 | * if this is a x16 device ,then convert the input |
@@ -997,9 +997,8 @@ static void nand_cmdfunc(struct mtd_info *mtd, unsigned command, | |||
997 | info->need_wait = 1; | 997 | info->need_wait = 1; |
998 | pxa3xx_nand_start(info); | 998 | pxa3xx_nand_start(info); |
999 | 999 | ||
1000 | ret = wait_for_completion_timeout(&info->cmd_complete, | 1000 | if (!wait_for_completion_timeout(&info->cmd_complete, |
1001 | CHIP_DELAY_TIMEOUT); | 1001 | CHIP_DELAY_TIMEOUT)) { |
1002 | if (!ret) { | ||
1003 | dev_err(&info->pdev->dev, "Wait time out!!!\n"); | 1002 | dev_err(&info->pdev->dev, "Wait time out!!!\n"); |
1004 | /* Stop State Machine for next command cycle */ | 1003 | /* Stop State Machine for next command cycle */ |
1005 | pxa3xx_nand_stop(info); | 1004 | pxa3xx_nand_stop(info); |
@@ -1014,7 +1013,7 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd, | |||
1014 | { | 1013 | { |
1015 | struct pxa3xx_nand_host *host = mtd->priv; | 1014 | struct pxa3xx_nand_host *host = mtd->priv; |
1016 | struct pxa3xx_nand_info *info = host->info_data; | 1015 | struct pxa3xx_nand_info *info = host->info_data; |
1017 | int ret, exec_cmd, ext_cmd_type; | 1016 | int exec_cmd, ext_cmd_type; |
1018 | 1017 | ||
1019 | /* | 1018 | /* |
1020 | * if this is a x16 device then convert the input | 1019 | * if this is a x16 device then convert the input |
@@ -1077,9 +1076,8 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd, | |||
1077 | init_completion(&info->cmd_complete); | 1076 | init_completion(&info->cmd_complete); |
1078 | pxa3xx_nand_start(info); | 1077 | pxa3xx_nand_start(info); |
1079 | 1078 | ||
1080 | ret = wait_for_completion_timeout(&info->cmd_complete, | 1079 | if (!wait_for_completion_timeout(&info->cmd_complete, |
1081 | CHIP_DELAY_TIMEOUT); | 1080 | CHIP_DELAY_TIMEOUT)) { |
1082 | if (!ret) { | ||
1083 | dev_err(&info->pdev->dev, "Wait time out!!!\n"); | 1081 | dev_err(&info->pdev->dev, "Wait time out!!!\n"); |
1084 | /* Stop State Machine for next command cycle */ | 1082 | /* Stop State Machine for next command cycle */ |
1085 | pxa3xx_nand_stop(info); | 1083 | pxa3xx_nand_stop(info); |
@@ -1212,13 +1210,11 @@ static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) | |||
1212 | { | 1210 | { |
1213 | struct pxa3xx_nand_host *host = mtd->priv; | 1211 | struct pxa3xx_nand_host *host = mtd->priv; |
1214 | struct pxa3xx_nand_info *info = host->info_data; | 1212 | struct pxa3xx_nand_info *info = host->info_data; |
1215 | int ret; | ||
1216 | 1213 | ||
1217 | if (info->need_wait) { | 1214 | if (info->need_wait) { |
1218 | ret = wait_for_completion_timeout(&info->dev_ready, | ||
1219 | CHIP_DELAY_TIMEOUT); | ||
1220 | info->need_wait = 0; | 1215 | info->need_wait = 0; |
1221 | if (!ret) { | 1216 | if (!wait_for_completion_timeout(&info->dev_ready, |
1217 | CHIP_DELAY_TIMEOUT)) { | ||
1222 | dev_err(&info->pdev->dev, "Ready time out!!!\n"); | 1218 | dev_err(&info->pdev->dev, "Ready time out!!!\n"); |
1223 | return NAND_STATUS_FAIL; | 1219 | return NAND_STATUS_FAIL; |
1224 | } | 1220 | } |