Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742837 > unrolled thread

Re: [RFC v3 4/7] platform: x86: Add generic Intel IPC driver

Started byAndy Shevchenko <andy.shevchenko@gmail.com>
First post2017-10-01 17:00 +0200
Last post2017-10-01 17:00 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC v3 4/7] platform: x86: Add generic Intel IPC driver Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-10-01 17:00 +0200

#1742837 — Re: [RFC v3 4/7] platform: x86: Add generic Intel IPC driver

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2017-10-01 17:00 +0200
SubjectRe: [RFC v3 4/7] platform: x86: Add generic Intel IPC driver
Message-ID<uvNSN-3pJ-1@gated-at.bofh.it>
On Tue, Sep 5, 2017 at 8:37 AM,
<sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> Currently intel_scu_ipc.c, intel_pmc_ipc.c and intel_punit_ipc.c
> redundantly implements the same IPC features and has lot of code
> duplication between them. This driver addresses this issue by grouping
> the common IPC functionalities under the same driver.

> +static const char *ipc_dev_err_string(struct intel_ipc_dev *ipc_dev,
> +       int error)
> +{
> +       switch (error) {
> +       case IPC_DEV_ERR_NONE:
> +               return "No error";
> +       case IPC_DEV_ERR_CMD_NOT_SUPPORTED:
> +               return "Command not-supported/Invalid";
> +       case IPC_DEV_ERR_CMD_NOT_SERVICED:
> +               return "Command not-serviced/Invalid param";
> +       case IPC_DEV_ERR_UNABLE_TO_SERVICE:
> +               return "Unable-to-service/Cmd-timeout";
> +       case IPC_DEV_ERR_CMD_INVALID:
> +               return "Command-invalid/Cmd-locked";
> +       case IPC_DEV_ERR_CMD_FAILED:
> +               return "Command-failed/Invalid-VR-id";
> +       case IPC_DEV_ERR_EMSECURITY:
> +               return "Invalid Battery/VR-Error";
> +       case IPC_DEV_ERR_UNSIGNEDKERNEL:
> +               return "Unsigned kernel";
> +       default:
> +               return "Unknown Command";
> +       };
> +}

Since it's continuous list you can define an array of messages like

const char * const *errors = {
 [..._ERR_...] = "",
 ...

};

Also you can use enum in the header and define _ERR_MAX there.
Thus, code would be transformed to

if (error < _ERR_MAX)
 return errors[error];

return "Unknown Command";

-- 
With Best Regards,
Andy Shevchenko

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web