All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org
Cc: Geert Uytterhoeven
	<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-spi <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 3/4] spi: loopback-test: make dump_messages module parameter a bitmask
Date: Sat, 19 Dec 2015 03:43:40 +0200	[thread overview]
Message-ID: <CAHp75VdEm0iyOxfWmM8E-uU0cekGras71D03VT1P5WKXdEAG4g@mail.gmail.com> (raw)
In-Reply-To: <1450442668-2391-4-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>

On Fri, Dec 18, 2015 at 2:44 PM,  <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org> wrote:
> From: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
>
> Make dump_messages module parameter a bitmask to allow for better
> granularity when dumping messages.
>
> Signed-off-by: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
> ---
>  drivers/spi/spi-loopback-test.c |   40 ++++++++++++++++++++++++++++-----------
>  1 file changed, 29 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
> index 8dac6a4..6e76c3e 100644
> --- a/drivers/spi/spi-loopback-test.c
> +++ b/drivers/spi/spi-loopback-test.c
> @@ -36,11 +36,17 @@ MODULE_PARM_DESC(simulate_only, "if not 0 do not execute the spi message");
>
>  /* dump spi messages */
>  int dump_messages;
> +#define DUMP_MESSAGE_AFTER             BIT(0)
> +#define DUMP_MESSAGE_BEFORE            BIT(1)
> +#define DUMP_MESSAGE_DATA_AFTER                BIT(2)
> +#define DUMP_MESSAGE_DATA_BEFORE       BIT(3)

DUMP is used in lib/hexdump.c, I would suggest
SPI_DUMP_MSG_

>  module_param(dump_messages, int, 0);
> -MODULE_PARM_DESC(dump_message,
> -                "=1 dump the basic spi_message_structure, " \
> -                "=2 dump the spi_message_structure including data, " \
> -                "=3 dump the spi_message structure before and after execution");
> +MODULE_PARM_DESC(dump_messages,
> +                "BIT(0) - dump the basic spi_message_structure after processing, "
> +                "BIT(1) - dump the basic spi_message_structure before processing, "
> +                "BIT(2) - also dump the spi_message data after processing, "
> +                "BIT(3) - also dump the spi_message data before processing");

Logically it is exactly two bits, not four.

> +
>  /* the device is jumpered for loopback - enabling some rx_buf tests */
>  int loopback;
>  module_param(loopback, int, 0);
> @@ -749,9 +755,15 @@ int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test,
>
>         /* only if we do not simulate */
>         if (!simulate_only) {
> -               /* dump the complete message before and after the transfer */
> -               if (dump_messages == 3)
> -                       spi_message_dump_data(spi, msg, 1024);
> +               /* dump the complete message before the transfer */
> +               if (dump_messages & DUMP_MESSAGE_BEFORE) {
> +                       /* calc bytes to dump */

> +                       if (dump_messages & DUMP_MESSAGE_DATA_BEFORE)
> +                               i = 1024;
> +                       else
> +                               i = 0;

Ternary operator ?

> +                       spi_message_dump_data(spi, msg, i);
> +               }
>
>                 /* run spi message */
>                 ret = spi_sync(spi, msg);
> @@ -786,10 +798,16 @@ int spi_test_execute_msg(struct spi_device *spi, struct spi_test *test,
>
>         /* if requested or on error dump message (including data) */
>  exit:
> -       if (dump_messages || ret)
> -               spi_message_dump_data(spi, msg,
> -                                     ((dump_messages >= 2) || (ret)) ?
> -                                     1024 : 0);
> +       if ((dump_messages & DUMP_MESSAGE_AFTER) || ret) {
> +               /* calc bytes to dump */

> +               i = 0;
> +               if (dump_messages & DUMP_MESSAGE_DATA_AFTER)
> +                       i = 1024;
> +               if (ret)
> +                       i = 1024;

Ditto.

i = (dump_messages & DUMP_MESSAGE_DATA_AFTER) || ret ? 1024 : 0;

> +               /* dump the message */
> +               spi_message_dump_data(spi, msg, i);
> +       }
>
>         return ret;
>  }
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-spi" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-12-19  1:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 12:44 [PATCH 0/4] spi: loopback-test: improvements and move dump method kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found] ` <1450442668-2391-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-18 12:44   ` [PATCH 1/4] spi: core: add spi_message_dump and spi_transfer_dump kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found]     ` <1450442668-2391-2-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-18 13:32       ` Andy Shevchenko
     [not found]         ` <CAHp75VfYQf2nfxNxNhtwwbg2_OJdiU3RFgyoyZB-THCRtfJWBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-18 16:53           ` Martin Sperl
     [not found]             ` <407EFA5A-72AE-4609-8081-887CCA3C2944-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-18 19:28               ` Andy Shevchenko
2015-12-18 12:44   ` [PATCH 2/4] spi: loopback-test: move to use spi_message_dump_data kernel-TqfNSX0MhmxHKSADF0wUEw
2015-12-18 12:44   ` [PATCH 3/4] spi: loopback-test: make dump_messages module parameter a bitmask kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found]     ` <1450442668-2391-4-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-19  1:43       ` Andy Shevchenko [this message]
2015-12-18 12:44   ` [PATCH 4/4] spi: loopback-test: added support for HW-loopback mode kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found]     ` <1450442668-2391-5-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-12-19  2:12       ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHp75VdEm0iyOxfWmM8E-uU0cekGras71D03VT1P5WKXdEAG4g@mail.gmail.com \
    --to=andy.shevchenko-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
    --cc=kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --subject='Re: [PATCH 3/4] spi: loopback-test: make dump_messages module parameter a bitmask' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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.