diff mbox series

mmc:sd:Replace the argument of mmc_sd_switch with the already declared define

Message ID 20240829024709.402285-1-cw9316.lee@samsung.com (mailing list archive)
State New
Headers show
Series mmc:sd:Replace the argument of mmc_sd_switch with the already declared define | expand

Commit Message

Chanwoo Lee Aug. 29, 2024, 2:47 a.m. UTC
Replace with already defined values for readability.
And since the value of the 'mode' parameter is only used as 0 or 1,
I changed the data type from 'int' to 'bool'.

--------------------------------------------------
/sd.h
/*
 * SD_SWITCH argument format:
 *      [31] Check (0) or switch (1)
...

/*
 * SD_SWITCH mode
 */
  define SD_SWITCH_CHECK         0
  define SD_SWITCH_SET           1
-------------------------------------------------

Signed-off-by: Chanwoo Lee <cw9316.lee@samsung.com>
---
 drivers/mmc/core/sd.c     | 13 ++++++++-----
 drivers/mmc/core/sd_ops.c |  3 +--
 include/linux/mmc/host.h  |  3 ++-
 3 files changed, 11 insertions(+), 8 deletions(-)

Comments

Ulf Hansson Sept. 3, 2024, 12:37 p.m. UTC | #1
On Thu, 29 Aug 2024 at 04:47, Chanwoo Lee <cw9316.lee@samsung.com> wrote:
>
> Replace with already defined values for readability.
> And since the value of the 'mode' parameter is only used as 0 or 1,
> I changed the data type from 'int' to 'bool'.
>
> --------------------------------------------------
> /sd.h
> /*
>  * SD_SWITCH argument format:
>  *      [31] Check (0) or switch (1)
> ...
>
> /*
>  * SD_SWITCH mode
>  */
>   define SD_SWITCH_CHECK         0
>   define SD_SWITCH_SET           1
> -------------------------------------------------
>
> Signed-off-by: Chanwoo Lee <cw9316.lee@samsung.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/core/sd.c     | 13 ++++++++-----
>  drivers/mmc/core/sd_ops.c |  3 +--
>  include/linux/mmc/host.h  |  3 ++-
>  3 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index ee37ad14e79e..d7318c2647da 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -346,7 +346,7 @@ static int mmc_read_switch(struct mmc_card *card)
>          * The argument does not matter, as the support bits do not
>          * change with the arguments.
>          */
> -       err = mmc_sd_switch(card, 0, 0, 0, status);
> +       err = mmc_sd_switch(card, SD_SWITCH_CHECK, 0, 0, status);
>         if (err) {
>                 /*
>                  * If the host or the card can't do the switch,
> @@ -402,7 +402,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
>         if (!status)
>                 return -ENOMEM;
>
> -       err = mmc_sd_switch(card, 1, 0, HIGH_SPEED_BUS_SPEED, status);
> +       err = mmc_sd_switch(card, SD_SWITCH_SET, 0,
> +                       HIGH_SPEED_BUS_SPEED, status);
>         if (err)
>                 goto out;
>
> @@ -434,7 +435,8 @@ static int sd_select_driver_type(struct mmc_card *card, u8 *status)
>                                                    card_drv_type, &drv_type);
>
>         if (drive_strength) {
> -               err = mmc_sd_switch(card, 1, 2, drive_strength, status);
> +               err = mmc_sd_switch(card, SD_SWITCH_SET, 2,
> +                               drive_strength, status);
>                 if (err)
>                         return err;
>                 if ((status[15] & 0xF) != drive_strength) {
> @@ -514,7 +516,7 @@ static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
>                 return 0;
>         }
>
> -       err = mmc_sd_switch(card, 1, 0, card->sd_bus_speed, status);
> +       err = mmc_sd_switch(card, SD_SWITCH_SET, 0, card->sd_bus_speed, status);
>         if (err)
>                 return err;
>
> @@ -605,7 +607,8 @@ static int sd_set_current_limit(struct mmc_card *card, u8 *status)
>                 current_limit = SD_SET_CURRENT_LIMIT_200;
>
>         if (current_limit != SD_SET_CURRENT_NO_CHANGE) {
> -               err = mmc_sd_switch(card, 1, 3, current_limit, status);
> +               err = mmc_sd_switch(card, SD_SWITCH_SET, 3,
> +                               current_limit, status);
>                 if (err)
>                         return err;
>
> diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
> index 8b9b34286ef3..f93c392040ae 100644
> --- a/drivers/mmc/core/sd_ops.c
> +++ b/drivers/mmc/core/sd_ops.c
> @@ -336,14 +336,13 @@ int mmc_app_send_scr(struct mmc_card *card)
>         return 0;
>  }
>
> -int mmc_sd_switch(struct mmc_card *card, int mode, int group,
> +int mmc_sd_switch(struct mmc_card *card, bool mode, int group,
>         u8 value, u8 *resp)
>  {
>         u32 cmd_args;
>
>         /* NOTE: caller guarantees resp is heap-allocated */
>
> -       mode = !!mode;
>         value &= 0xF;
>         cmd_args = mode << 31 | 0x00FFFFFF;
>         cmd_args &= ~(0xF << (group * 4));
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 7140e1a7edb4..8fc2b328ec4d 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -649,7 +649,8 @@ static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
>         host->err_stats[stat] += 1;
>  }
>
> -int mmc_sd_switch(struct mmc_card *card, int mode, int group, u8 value, u8 *resp);
> +int mmc_sd_switch(struct mmc_card *card, bool mode, int group,
> +               u8 value, u8 *resp);
>  int mmc_send_status(struct mmc_card *card, u32 *status);
>  int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
>  int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index ee37ad14e79e..d7318c2647da 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -346,7 +346,7 @@  static int mmc_read_switch(struct mmc_card *card)
 	 * The argument does not matter, as the support bits do not
 	 * change with the arguments.
 	 */
-	err = mmc_sd_switch(card, 0, 0, 0, status);
+	err = mmc_sd_switch(card, SD_SWITCH_CHECK, 0, 0, status);
 	if (err) {
 		/*
 		 * If the host or the card can't do the switch,
@@ -402,7 +402,8 @@  int mmc_sd_switch_hs(struct mmc_card *card)
 	if (!status)
 		return -ENOMEM;
 
-	err = mmc_sd_switch(card, 1, 0, HIGH_SPEED_BUS_SPEED, status);
+	err = mmc_sd_switch(card, SD_SWITCH_SET, 0,
+			HIGH_SPEED_BUS_SPEED, status);
 	if (err)
 		goto out;
 
@@ -434,7 +435,8 @@  static int sd_select_driver_type(struct mmc_card *card, u8 *status)
 						   card_drv_type, &drv_type);
 
 	if (drive_strength) {
-		err = mmc_sd_switch(card, 1, 2, drive_strength, status);
+		err = mmc_sd_switch(card, SD_SWITCH_SET, 2,
+				drive_strength, status);
 		if (err)
 			return err;
 		if ((status[15] & 0xF) != drive_strength) {
@@ -514,7 +516,7 @@  static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status)
 		return 0;
 	}
 
-	err = mmc_sd_switch(card, 1, 0, card->sd_bus_speed, status);
+	err = mmc_sd_switch(card, SD_SWITCH_SET, 0, card->sd_bus_speed, status);
 	if (err)
 		return err;
 
@@ -605,7 +607,8 @@  static int sd_set_current_limit(struct mmc_card *card, u8 *status)
 		current_limit = SD_SET_CURRENT_LIMIT_200;
 
 	if (current_limit != SD_SET_CURRENT_NO_CHANGE) {
-		err = mmc_sd_switch(card, 1, 3, current_limit, status);
+		err = mmc_sd_switch(card, SD_SWITCH_SET, 3,
+				current_limit, status);
 		if (err)
 			return err;
 
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index 8b9b34286ef3..f93c392040ae 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -336,14 +336,13 @@  int mmc_app_send_scr(struct mmc_card *card)
 	return 0;
 }
 
-int mmc_sd_switch(struct mmc_card *card, int mode, int group,
+int mmc_sd_switch(struct mmc_card *card, bool mode, int group,
 	u8 value, u8 *resp)
 {
 	u32 cmd_args;
 
 	/* NOTE: caller guarantees resp is heap-allocated */
 
-	mode = !!mode;
 	value &= 0xF;
 	cmd_args = mode << 31 | 0x00FFFFFF;
 	cmd_args &= ~(0xF << (group * 4));
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 7140e1a7edb4..8fc2b328ec4d 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -649,7 +649,8 @@  static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
 	host->err_stats[stat] += 1;
 }
 
-int mmc_sd_switch(struct mmc_card *card, int mode, int group, u8 value, u8 *resp);
+int mmc_sd_switch(struct mmc_card *card, bool mode, int group,
+		u8 value, u8 *resp);
 int mmc_send_status(struct mmc_card *card, u32 *status);
 int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
 int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);