[2/3] drivers/mmc/host/mmc_spi.c: Use get/put_unaligned_be32
diff mbox

Message ID 20140511100502.1491.qmail@ns.horizon.com
State New, archived
Headers show

Commit Message

George Spelvin May 11, 2014, 10:05 a.m. UTC
Very minor source and binary size reduction.

Signed-off-by: George Spelvin <linux@horizon.com>
---
I spotted this while making the previous crc7 change.

This looks simple enough, but I don't actually have one of these devices to test.
At least one other careful desk-check is solicited.

 drivers/mmc/host/mmc_spi.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Pavel Machek May 11, 2014, 10:33 a.m. UTC | #1
On Sun 2014-05-11 06:05:02, George Spelvin wrote:
> Very minor source and binary size reduction.
> 
> Signed-off-by: George Spelvin <linux@horizon.com>

Reviewed-by: Pavel Machek <pavel@ucw.cz>
Geert Uytterhoeven May 12, 2014, 8:05 a.m. UTC | #2
On Sun, May 11, 2014 at 12:05 PM, George Spelvin <linux@horizon.com> wrote:
> Very minor source and binary size reduction.
>
> Signed-off-by: George Spelvin <linux@horizon.com>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson May 14, 2014, 10:17 a.m. UTC | #3
On 11 May 2014 12:05, George Spelvin <linux@horizon.com> wrote:
> Very minor source and binary size reduction.
>
> Signed-off-by: George Spelvin <linux@horizon.com>
> ---
> I spotted this while making the previous crc7 change.
>
> This looks simple enough, but I don't actually have one of these devices to test.
> At least one other careful desk-check is solicited.

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Feel free to take this through the wireless tree as well. I assumes
it's that same patchset as the other spi related fixes?

Kind regards
Ulf Hansson

>
>  drivers/mmc/host/mmc_spi.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> index 338e2202ea..cc8d4a6099 100644
> --- a/drivers/mmc/host/mmc_spi.c
> +++ b/drivers/mmc/host/mmc_spi.c
> @@ -448,7 +448,6 @@ mmc_spi_command_send(struct mmc_spi_host *host,
>  {
>         struct scratch          *data = host->data;
>         u8                      *cp = data->status;
> -       u32                     arg = cmd->arg;
>         int                     status;
>         struct spi_transfer     *t;
>
> @@ -465,14 +464,12 @@ mmc_spi_command_send(struct mmc_spi_host *host,
>          * We init the whole buffer to all-ones, which is what we need
>          * to write while we're reading (later) response data.
>          */
> -       memset(cp++, 0xff, sizeof(data->status));
> +       memset(cp, 0xff, sizeof(data->status));
>
> -       *cp++ = 0x40 | cmd->opcode;
> -       *cp++ = (u8)(arg >> 24);
> -       *cp++ = (u8)(arg >> 16);
> -       *cp++ = (u8)(arg >> 8);
> -       *cp++ = (u8)arg;
> -       *cp++ = crc7_be(0, &data->status[1], 5) | 0x01;
> +       cp[1] = 0x40 | cmd->opcode;
> +       put_unaligned_be32(cmd->arg, cp+2);
> +       cp[6] = crc7_be(0, cp+1, 5) | 0x01;
> +       cp += 7;
>
>         /* Then, read up to 13 bytes (while writing all-ones):
>          *  - N(CR) (== 1..8) bytes of all-ones
> @@ -711,10 +708,7 @@ mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t,
>          * so we have to cope with this situation and check the response
>          * bit-by-bit. Arggh!!!
>          */
> -       pattern  = scratch->status[0] << 24;
> -       pattern |= scratch->status[1] << 16;
> -       pattern |= scratch->status[2] << 8;
> -       pattern |= scratch->status[3];
> +       pattern = get_unaligned_be32(scratch->status);
>
>         /* First 3 bit of pattern are undefined */
>         pattern |= 0xE0000000;
> --
> 1.9.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
George Spelvin May 14, 2014, 12:23 p.m. UTC | #4
Ulf Hansson wrote:
> Feel free to take this through the wireless tree as well. I assumes
> it's that same patchset as the other spi related fixes?

I'd like to answer, but I'm not sure which "other spi related fixes"
you're referring to.  If you mean patches 1 and 3 of this series, then
obviously.  If you mean something else then probably not.

[PATCH 1/3] lib/crc7: Shift crc7() output left 1 bit
[PATCH 3/3] drivers/net/wireless/ti/wl*/spi.c: Simplify CRC computation


As there seems to be no objection to sending the mmc change via the
wireless tree, are they ready to be queued there?

The additional reviews are:
All 3: Reviewed-by: Pavel Machek <pavel@ucw.cz>
2/3: Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
2/3: Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

I can resend everything with the additional signoff lines
if that's easier for you.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson May 14, 2014, 12:30 p.m. UTC | #5
On 14 May 2014 14:23, George Spelvin <linux@horizon.com> wrote:
> Ulf Hansson wrote:
>> Feel free to take this through the wireless tree as well. I assumes
>> it's that same patchset as the other spi related fixes?
>
> I'd like to answer, but I'm not sure which "other spi related fixes"
> you're referring to.  If you mean patches 1 and 3 of this series, then
> obviously.  If you mean something else then probably not.
>
> [PATCH 1/3] lib/crc7: Shift crc7() output left 1 bit
> [PATCH 3/3] drivers/net/wireless/ti/wl*/spi.c: Simplify CRC computation
>

Sorry for being unclear. It's those above I referred to.

Kind regards
Ulf Hansson
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
John W. Linville May 14, 2014, 2:50 p.m. UTC | #6
On Wed, May 14, 2014 at 08:23:57AM -0400, George Spelvin wrote:
> Ulf Hansson wrote:
> > Feel free to take this through the wireless tree as well. I assumes
> > it's that same patchset as the other spi related fixes?
> 
> I'd like to answer, but I'm not sure which "other spi related fixes"
> you're referring to.  If you mean patches 1 and 3 of this series, then
> obviously.  If you mean something else then probably not.
> 
> [PATCH 1/3] lib/crc7: Shift crc7() output left 1 bit
> [PATCH 3/3] drivers/net/wireless/ti/wl*/spi.c: Simplify CRC computation
> 
> 
> As there seems to be no objection to sending the mmc change via the
> wireless tree, are they ready to be queued there?
> 
> The additional reviews are:
> All 3: Reviewed-by: Pavel Machek <pavel@ucw.cz>
> 2/3: Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> 2/3: Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
> 
> I can resend everything with the additional signoff lines
> if that's easier for you.

I can take them, sure.

John

Patch
diff mbox

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 338e2202ea..cc8d4a6099 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -448,7 +448,6 @@  mmc_spi_command_send(struct mmc_spi_host *host,
 {
 	struct scratch		*data = host->data;
 	u8			*cp = data->status;
-	u32			arg = cmd->arg;
 	int			status;
 	struct spi_transfer	*t;
 
@@ -465,14 +464,12 @@  mmc_spi_command_send(struct mmc_spi_host *host,
 	 * We init the whole buffer to all-ones, which is what we need
 	 * to write while we're reading (later) response data.
 	 */
-	memset(cp++, 0xff, sizeof(data->status));
+	memset(cp, 0xff, sizeof(data->status));
 
-	*cp++ = 0x40 | cmd->opcode;
-	*cp++ = (u8)(arg >> 24);
-	*cp++ = (u8)(arg >> 16);
-	*cp++ = (u8)(arg >> 8);
-	*cp++ = (u8)arg;
-	*cp++ = crc7_be(0, &data->status[1], 5) | 0x01;
+	cp[1] = 0x40 | cmd->opcode;
+	put_unaligned_be32(cmd->arg, cp+2);
+	cp[6] = crc7_be(0, cp+1, 5) | 0x01;
+	cp += 7;
 
 	/* Then, read up to 13 bytes (while writing all-ones):
 	 *  - N(CR) (== 1..8) bytes of all-ones
@@ -711,10 +708,7 @@  mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t,
 	 * so we have to cope with this situation and check the response
 	 * bit-by-bit. Arggh!!!
 	 */
-	pattern  = scratch->status[0] << 24;
-	pattern |= scratch->status[1] << 16;
-	pattern |= scratch->status[2] << 8;
-	pattern |= scratch->status[3];
+	pattern = get_unaligned_be32(scratch->status);
 
 	/* First 3 bit of pattern are undefined */
 	pattern |= 0xE0000000;