From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751840AbdJDBHd (ORCPT ); Tue, 3 Oct 2017 21:07:33 -0400 Received: from mga02.intel.com ([134.134.136.20]:56636 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225AbdJDBHb (ORCPT ); Tue, 3 Oct 2017 21:07:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,475,1500966000"; d="scan'208";a="134888086" Reply-To: sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [RFC v3 4/7] platform: x86: Add generic Intel IPC driver To: Andy Shevchenko Cc: Alessandro Zummo , "x86@kernel.org" , Wim Van Sebroeck , Ingo Molnar , Alexandre Belloni , Zha Qipeng , "H. Peter Anvin" , "dvhart@infradead.org" , Thomas Gleixner , Lee Jones , Andy Shevchenko , Souvik Kumar Chakravarty , linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, "linux-kernel@vger.kernel.org" , Platform Driver , Sathyanarayanan Kuppuswamy Natarajan References: <7d1a79925df8d2e35cfbd6974706d0d1ef0fc0de.1504588701.git.sathyanarayanan.kuppuswamy@linux.intel.com> From: sathyanarayanan kuppuswamy Organization: Intel Message-ID: <96f8c550-da66-c11f-4db4-34fe520188aa@linux.intel.com> Date: Tue, 3 Oct 2017 18:07:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 10/01/2017 07:59 AM, Andy Shevchenko wrote: > On Tue, Sep 5, 2017 at 8:37 AM, > wrote: >> From: Kuppuswamy Sathyanarayanan >> >> 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"; Thanks will fix it in next version. > -- Sathyanarayanan Kuppuswamy Linux kernel developer