Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: narmstrong@baylibre.com (Neil Armstrong)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/8] scpi: Add cmd indirection table to prepare for legacy commands
Date: Mon, 19 Sep 2016 17:03:50 +0200	[thread overview]
Message-ID: <0d03c4df-93db-840e-e750-64cb9f12b6cb@baylibre.com> (raw)
In-Reply-To: <213c023d-bac8-5148-4846-8501501bddf2@arm.com>

On 09/19/2016 04:41 PM, Sudeep Holla wrote:
> Hi Neil,
> 
> On 07/09/16 16:34, Neil Armstrong wrote:
>> Add indirection table to permit multiple command values for legacy support.
>>
> 
> I wrote the most of the patch and you changed the author too ;)

Sorry, forgot this ! v4 will have it !
> 
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  drivers/firmware/arm_scpi.c | 145 ++++++++++++++++++++++++++++++++++++++------
>>  1 file changed, 127 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
>> index 4388937..9a87687 100644
>> --- a/drivers/firmware/arm_scpi.c
>> +++ b/drivers/firmware/arm_scpi.c
> 
> [..]
> 
>> @@ -161,6 +194,7 @@ struct scpi_drvinfo {
>>      u32 protocol_version;
>>      u32 firmware_version;
>>      int num_chans;
>> +    int *scpi_cmds;
>>      atomic_t next_chan;
>>      struct scpi_ops *scpi_ops;
>>      struct scpi_chan *channels;
>> @@ -390,6 +424,19 @@ static u32 scpi_get_version(void)
>>      return scpi_info->protocol_version;
>>  }
>>
>> +static inline int check_cmd(unsigned int offset)
>> +{
>> +    if (offset >= CMD_MAX_COUNT ||
> 
> If we call scpi_send_message internally(as it's static) why is this
> check needed ?
> 
> 
>> +        !scpi_info ||
>> +        !scpi_info->scpi_cmds)
> 
> Will be even reach to this point if above is true ?
> 
>> +        return -EINVAL;
>> +
>> +    if (scpi_info->scpi_cmds[offset] < 0)
>> +        return -EOPNOTSUPP;
> 
> IMO just above couple of lines in the beginning of scpi_send_message
> will suffice. You can just add this to my original patch.

Will do.

> 
>>  static int
>>  scpi_clk_get_range(u16 clk_id, unsigned long *min, unsigned long *max)
>>  {
>> @@ -397,8 +444,13 @@ scpi_clk_get_range(u16 clk_id, unsigned long *min, unsigned long *max)
>>      struct clk_get_info clk;
>>      __le16 le_clk_id = cpu_to_le16(clk_id);
>>
>> -    ret = scpi_send_message(SCPI_CMD_GET_CLOCK_INFO, &le_clk_id,
>> -                sizeof(le_clk_id), &clk, sizeof(clk));
>> +    ret = check_cmd(CMD_GET_CLOCK_INFO);
>> +    if (ret)
>> +        return ret;
>> +
> 
> It's totally unnecessary to add check in each and every function calling
> scpi_send_message, why not add it to scpi_send_message instead.
> 

This was my first thought, I should have stayed at this !

Thanks,
Neil

  reply	other threads:[~2016-09-19 15:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07 15:34 [PATCH v3 0/8] scpi: Add support for legacy SCPI protocol Neil Armstrong
2016-09-07 15:34 ` [PATCH v3 1/8] scpi: Add cmd indirection table to prepare for legacy commands Neil Armstrong
2016-09-19 14:41   ` Sudeep Holla
2016-09-19 15:03     ` Neil Armstrong [this message]
2016-09-07 15:34 ` [PATCH v3 2/8] scpi: Add alternative legacy structures, functions and macros Neil Armstrong
2016-09-19 15:24   ` Sudeep Holla
2016-10-04 12:04     ` Neil Armstrong
2016-09-07 15:34 ` [PATCH v3 3/8] scpi: Do not fail if get_capabilities is not implemented Neil Armstrong
2016-09-07 15:34 ` [PATCH v3 4/8] scpi: Add support for Legacy match table for Amlogic GXBB SoC Neil Armstrong
2016-09-19 15:50   ` Sudeep Holla
2016-09-19 15:51     ` Sudeep Holla
2016-09-07 15:34 ` [PATCH v3 5/8] scpi: grow MAX_DVFS_OPPS to 16 entries Neil Armstrong
2016-09-07 15:34 ` [PATCH v3 6/8] dt-bindings: Add support for Amlogic GXBB SCPI Interface Neil Armstrong
2016-09-07 15:34 ` [PATCH v3 7/8] ARM64: dts: meson-gxbb: Add SRAM node Neil Armstrong
2016-09-07 15:34 ` [PATCH v3 8/8] ARM64: dts: meson-gxbb: Add SCPI with cpufreq & sensors Nodes Neil Armstrong

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=0d03c4df-93db-840e-e750-64cb9f12b6cb@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox