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


Groups > linux.kernel > #1468372

Re: [PATCH 04/13] scpi: Add legacy SCP functions calling legacy_scpi_send_message

From Neil Armstrong <narmstrong@baylibre.com>
Newsgroups linux.kernel
Subject Re: [PATCH 04/13] scpi: Add legacy SCP functions calling legacy_scpi_send_message
Date 2016-08-23 10:20 +0200
Message-ID <s9f69-1la-7@gated-at.bofh.it> (permalink)
References <s7sAx-6Nh-3@gated-at.bofh.it> <s7sAy-6Nh-25@gated-at.bofh.it> <s7UQ9-7Ui-11@gated-at.bofh.it>
Organization Baylibre

Show all headers | View raw


On 08/19/2016 06:22 PM, Sudeep Holla wrote:
> 
> 
> On 18/08/16 11:10, Neil Armstrong wrote:
>> In order to support legacy SCP functions from kernel-wide driver, add legacy
>> functions using the legacy command enums and calling legacy_scpi_send_message.
>>
>> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
>> ---
>>  drivers/firmware/arm_scpi.c | 118 ++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 118 insertions(+)
>>
>> diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
>> index 50b1297..bb9965f 100644
>> --- a/drivers/firmware/arm_scpi.c
>> +++ b/drivers/firmware/arm_scpi.c
>> @@ -578,6 +578,8 @@ scpi_clk_get_range(u16 clk_id, unsigned long *min, unsigned long *max)
>>      return ret;
>>  }
>>
>> +/* scpi_clk_get_range not available for legacy */
>> +
>>  static unsigned long scpi_clk_get_val(u16 clk_id)
>>  {
>>      int ret;
>> @@ -589,6 +591,18 @@ static unsigned long scpi_clk_get_val(u16 clk_id)
>>      return ret ? ret : le32_to_cpu(clk.rate);
>>  }
>>
>> +static unsigned long legacy_scpi_clk_get_val(u16 clk_id)
>> +{
>> +    int ret;
>> +    struct clk_get_value clk;
>> +    __le16 le_clk_id = cpu_to_le16(clk_id);
>> +
>> +    ret = legacy_scpi_send_message(LEGACY_SCPI_CMD_GET_CLOCK_VALUE,
>> +                       &le_clk_id, sizeof(le_clk_id),
>> +                       &clk, sizeof(clk));
>> +    return ret ? ret : le32_to_cpu(clk.rate);
>> +}
>> +
>>  static int scpi_clk_set_val(u16 clk_id, unsigned long rate)
>>  {
>>      int stat;
>> @@ -601,6 +615,19 @@ static int scpi_clk_set_val(u16 clk_id, unsigned long rate)
>>                   &stat, sizeof(stat));
>>  }
>>
>> +static int legacy_scpi_clk_set_val(u16 clk_id, unsigned long rate)
>> +{
>> +    int stat;
>> +    struct legacy_clk_set_value clk = {
>> +        .id = cpu_to_le16(clk_id),
>> +        .rate = cpu_to_le32(rate)
>> +    };
>> +
>> +    return legacy_scpi_send_message(LEGACY_SCPI_CMD_SET_CLOCK_VALUE,
>> +                    &clk, sizeof(clk),
>> +                    &stat, sizeof(stat));
> 
> Except this one which has a different structure format, why do we need
> to define legacy versions of other functions ? Can't we play with
> function pointer or have a boolean in drvinfo structure and use then in
> the existing functions as I had shown in one of the earlier emails.
> 

The main problem is that the command indexes deviates starting at
SCPI_CMD_SET_CSS_PWR_STATE, I'll be pleased to know how to implement it.

Should I add a test :
if (scpi_drvinfo->is_legacy)
	legacy_scpi_send_message(...)
else
	scpi_send_message(...)

In each function ?

My strategy was to leave the "final" function untouched ans provide
alternatives to legacy.
I can add this "is_legacy" if/else instead of ops structures.

Please tell me how you'll implement this, so I'll adapt the merge.

Neil

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/13] scpi: Add support for legacy SCPI protocol Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
  [PATCH 06/13] scpi: add priv_scpi_ops and fill legacy structure Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
    Re: [PATCH 06/13] scpi: add priv_scpi_ops and fill legacy structure Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 18:50 +0200
      Re: [PATCH 06/13] scpi: add priv_scpi_ops and fill legacy structure Neil Armstrong <narmstrong@baylibre.com> - 2016-08-23 10:30 +0200
        Re: [PATCH 06/13] scpi: add priv_scpi_ops and fill legacy structure Sudeep Holla <sudeep.holla@arm.com> - 2016-08-23 17:00 +0200
  [PATCH 04/13] scpi: Add legacy SCP functions calling legacy_scpi_send_message Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
    Re: [PATCH 04/13] scpi: Add legacy SCP functions calling  legacy_scpi_send_message Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 18:30 +0200
      Re: [PATCH 04/13] scpi: Add legacy SCP functions calling  legacy_scpi_send_message Neil Armstrong <narmstrong@baylibre.com> - 2016-08-23 10:20 +0200
        Re: [PATCH 04/13] scpi: Add legacy SCP functions calling  legacy_scpi_send_message Sudeep Holla <sudeep.holla@arm.com> - 2016-08-23 16:50 +0200
  [PATCH 09/13] scpi: implement rockchip support via the vendor_msg mechanism Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
  [PATCH 01/13] scpi: Add vendor_send_message to enable access to vendor commands Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
    Re: [PATCH 01/13] scpi: Add vendor_send_message to enable access to  vendor commands Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 03:30 +0200
      Re: [PATCH 01/13] scpi: Add vendor_send_message to enable access to  vendor commands Neil Armstrong <narmstrong@baylibre.com> - 2016-08-19 10:10 +0200
        Re: [PATCH 01/13] scpi: Add vendor_send_message to enable access to  vendor commands Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 12:40 +0200
  [PATCH 11/13] dt-bindings: Add support for Amlogic GXBB SCPI Interface Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
    Re: [PATCH 11/13] dt-bindings: Add support for Amlogic GXBB SCPI  Interface Rob Herring <robh@kernel.org> - 2016-08-19 15:50 +0200
  [PATCH 08/13] scpi: add a vendor_msg mechanism in case the mailbox message differs Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
    Re: [PATCH 08/13] scpi: add a vendor_msg mechanism in case the  mailbox message differs Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 18:50 +0200
  [PATCH 07/13] scpi: ignore init_versions failure if reported not supported Neil Armstrong <narmstrong@baylibre.com> - 2016-08-18 12:20 +0200
    Re: [PATCH 07/13] scpi: ignore init_versions failure if reported not  supported Sudeep Holla <sudeep.holla@arm.com> - 2016-08-19 18:50 +0200
      Re: [PATCH 07/13] scpi: ignore init_versions failure if reported not  supported Neil Armstrong <narmstrong@baylibre.com> - 2016-08-23 10:30 +0200
        Re: [PATCH 07/13] scpi: ignore init_versions failure if reported not  supported Sudeep Holla <sudeep.holla@arm.com> - 2016-08-23 17:00 +0200
          Re: [PATCH 07/13] scpi: ignore init_versions failure if reported not  supported Sudeep Holla <sudeep.holla@arm.com> - 2016-08-23 17:10 +0200
          Re: [PATCH 07/13] scpi: ignore init_versions failure if reported not  supported Neil Armstrong <narmstrong@baylibre.com> - 2016-08-23 17:10 +0200

csiph-web