All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 6/6] drm/i915/sdvo: Add helpers to get the cmd/status string
Date: Wed, 19 Jun 2019 19:15:55 +0100	[thread overview]
Message-ID: <156096815595.664.4978579433721792478@skylake-alporthouse-com> (raw)
In-Reply-To: <20190619180312.31817-6-ville.syrjala@linux.intel.com>

Quoting Ville Syrjala (2019-06-19 19:03:12)
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Add sdvo_cmd_name() and sdvo_cmd_status() helpers to avoid bothering
> the callers with the implementation details of the storage for these
> strings.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_sdvo.c | 40 +++++++++++++++++------
>  1 file changed, 30 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
> index df3582bab076..184cd64a7f98 100644
> --- a/drivers/gpu/drm/i915/display/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
> @@ -395,11 +395,24 @@ static const struct {
>  
>  #undef SDVO_CMD_NAME_ENTRY
>  
> +static const char *sdvo_cmd_name(u8 cmd)
> +{
> +       int i;
> +
> +       for (i = 0; i < ARRAY_SIZE(sdvo_cmd_names); i++) {
> +               if (cmd == sdvo_cmd_names[i].cmd)
> +                       return sdvo_cmd_names[i].name;
> +       }
> +
> +       return NULL;
> +}
> +
>  #define SDVO_NAME(svdo) ((svdo)->port == PORT_B ? "SDVOB" : "SDVOC")
>  
>  static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd,
>                                    const void *args, int args_len)
>  {
> +       const char *cmd_name;
>         int i, pos = 0;
>         char buffer[64];
>  
> @@ -412,15 +425,12 @@ static void intel_sdvo_debug_write(struct intel_sdvo *intel_sdvo, u8 cmd,
>         for (; i < 8; i++) {
>                 BUF_PRINT("   ");
>         }
> -       for (i = 0; i < ARRAY_SIZE(sdvo_cmd_names); i++) {
> -               if (cmd == sdvo_cmd_names[i].cmd) {
> -                       BUF_PRINT("(%s)", sdvo_cmd_names[i].name);
> -                       break;
> -               }
> -       }
> -       if (i == ARRAY_SIZE(sdvo_cmd_names)) {
> +
> +       cmd_name = sdvo_cmd_name(cmd);
> +       if (cmd_name)
> +               BUF_PRINT("(%s)", cmd_name);
> +       else
>                 BUF_PRINT("(%02X)", cmd);
> -       }
>  
>         WARN_ON(pos >= sizeof(buffer) - 1);
>  #undef BUF_PRINT
> @@ -438,6 +448,14 @@ static const char * const cmd_status_names[] = {
>         [SDVO_CMD_STATUS_SCALING_NOT_SUPP] = "Scaling not supported",
>  };
>  
> +static const char *sdvo_cmd_status(u8 status)
> +{
> +       if (status < ARRAY_SIZE(cmd_status_names))
> +               return cmd_status_names[status];
> +       else
> +               return NULL;
> +}
> +
>  static bool __intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd,
>                                    const void *args, int args_len,
>                                    bool unlocked)
> @@ -516,6 +534,7 @@ static bool intel_sdvo_write_cmd(struct intel_sdvo *intel_sdvo, u8 cmd,
>  static bool intel_sdvo_read_response(struct intel_sdvo *intel_sdvo,
>                                      void *response, int response_len)
>  {
> +       const char *cmd_status;
>         u8 retry = 15; /* 5 quick checks, followed by 10 long checks */
>         u8 status;
>         int i, pos = 0;
> @@ -561,8 +580,9 @@ static bool intel_sdvo_read_response(struct intel_sdvo *intel_sdvo,
>  #define BUF_PRINT(args...) \
>         pos += snprintf(buffer + pos, max_t(int, sizeof(buffer) - pos, 0), args)
>  
> -       if (status < ARRAY_SIZE(cmd_status_names))
> -               BUF_PRINT("(%s)", cmd_status_names[status]);
> +       cmd_status = sdvo_cmd_status(status);
> +       if (cmd_status)
> +               BUF_PRINT("(%s)", cmd_status);

There's my earlier suggestion!

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-06-19 18:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-19 18:03 [PATCH 1/6] drm/i915/sdvo: Fix handling if zero hbuf size Ville Syrjala
2019-06-19 18:03 ` [PATCH 2/6] drm/i915/sdvo: Use named initializers for the SDVO command names Ville Syrjala
2019-06-19 18:08   ` Chris Wilson
2019-06-19 18:03 ` [PATCH 3/6] drm/i915/sdvo: Remove duplicate SET_INPUT_TIMINGS_PART1 cmd name string Ville Syrjala
2019-06-19 18:11   ` Chris Wilson
2019-06-19 18:03 ` [PATCH 4/6] drm/i915/sdvo: Shrink sdvo_cmd_names[] strings Ville Syrjala
2019-06-19 18:13   ` Chris Wilson
2019-06-19 18:03 ` [PATCH 5/6] drm/i915/sdvo: Reduce the size of the on stack buffers Ville Syrjala
2019-06-19 18:21   ` Chris Wilson
2019-06-24 16:40     ` Ville Syrjälä
2019-06-19 18:03 ` [PATCH 6/6] drm/i915/sdvo: Add helpers to get the cmd/status string Ville Syrjala
2019-06-19 18:15   ` Chris Wilson [this message]
2019-06-19 18:32 ` ✗ Fi.CI.SPARSE: warning for series starting with [1/6] drm/i915/sdvo: Fix handling if zero hbuf size Patchwork
2019-06-19 18:52 ` ✓ Fi.CI.BAT: success " Patchwork
2019-06-20 13:39 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-07-10 13:37 ` [PATCH 1/6] " Imre Deak

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=156096815595.664.4978579433721792478@skylake-alporthouse-com \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.