mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fenglin Wu <quic_fenglinw@quicinc.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <robh+dt@kernel.org>,
	<agross@kernel.org>, <andersson@kernel.org>,
	<dmitry.baryshkov@linaro.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	<linux-input@vger.kernel.org>
Cc: <quic_collinsd@quicinc.com>, <quic_subbaram@quicinc.com>,
	<quic_kamalw@quicinc.com>, <jestar@qti.qualcomm.com>
Subject: Re: [PATCH v3 1/3] input: pm8xxx-vib: refactor to easily support new SPMI vibrator
Date: Thu, 27 Jul 2023 15:43:51 +0800	[thread overview]
Message-ID: <4e416602-8dea-fa6d-d083-f93b730552c3@quicinc.com> (raw)
In-Reply-To: <2a09e743-7423-65b0-c70d-87ae8105182a@linaro.org>



On 7/27/2023 3:07 PM, Krzysztof Kozlowski wrote:
> On 25/07/2023 08:16, Fenglin Wu wrote:
>>>>    
>>>> -static const struct pm8xxx_regs pm8058_regs = {
>>>> -	.drv_addr = 0x4A,
>>>> -	.drv_mask = 0xf8,
>>>> -	.drv_shift = 3,
>>>> -	.drv_en_manual_mask = 0xfc,
>>>> +static struct reg_field ssbi_vib_regs[VIB_MAX_REG] = {
>>>
>>> Change from const to non-const is wrong. How do you support multiple
>>> devices? No, this is way too fragile now.
>>>
>>
>> The register definition is no longer used as the match data, hw_type is
>> used.
>>
>> The last suggestion was getting the register base address from the DT
>> and it has to be added into the offset of SPMI vibrator registers
>> (either in the previous hard-coded format or the later the reg_filed
>> data structure), so it's not appropriated to make it constant.
>>
>> I don't understand this question: "How do you support multiple devices?"
>> For SSBI vibrator, since all the registers are fixed, and I would assume
>> that there is no chance to support multiple vibrator devices on the same
>> SSBI bus. If they are not on the same bus, the regmap device will be
>> different while the registers definition is the same, and we are still
>> able to support multiple devices, right?
> 
> No, you have static memory. One device probes and changes static memory
> to reg+=base1. Second device probes and changes the same to reg+=base2.

Thanks, got it.  I can update it with following 2 options:

1) keep the register definition in 'reg_filed' data structure and make 
it constant, copy it to a dynamically allocated memory before adding the 
'reg_base' to the '.reg' variable.

2) Define the register offsets as constant data and add the 'reg_base' 
to the 'reg' while using 'regmap_read()'/'regmap_write()' functions.

which one is the preferred way?

> 
>> The similar story for SPMI vibrators and it can support multiple devices
>> if they are located on different SPMI bus, or even if they are on the
>> same SPMI bus but just having different SID or PID.
> 
> Sorry, such code cannot go in. These must stay const and you must write
> driver without any static allocations or singleton-like patterns.
> 
> 
> Best regards,
> Krzysztof
> 

  reply	other threads:[~2023-07-27  7:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25  5:41 [PATCH v3 0/3] Add support for vibrator in multiple PMICs Fenglin Wu
2023-07-25  5:41 ` [PATCH v3 1/3] input: pm8xxx-vib: refactor to easily support new SPMI vibrator Fenglin Wu
2023-07-25  5:52   ` Krzysztof Kozlowski
2023-07-25  6:16     ` Fenglin Wu
2023-07-27  7:07       ` Krzysztof Kozlowski
2023-07-27  7:43         ` Fenglin Wu [this message]
2023-07-27  9:22           ` Krzysztof Kozlowski
2023-07-27  9:40             ` Fenglin Wu
2023-07-25 10:01   ` kernel test robot
2023-07-27  7:07     ` Krzysztof Kozlowski
2023-07-25  5:41 ` [PATCH v3 2/3] dt-bindings: input: qcom,pm8xxx-vib: add new SPMI vibrator module Fenglin Wu
2023-07-25  5:53   ` Krzysztof Kozlowski
2023-07-25  6:26     ` Fenglin Wu
2023-07-27  7:09       ` Krzysztof Kozlowski
2023-07-25  5:41 ` [PATCH v3 3/3] input: pm8xxx-vibrator: add new SPMI vibrator support Fenglin Wu

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=4e416602-8dea-fa6d-d083-f93b730552c3@quicinc.com \
    --to=quic_fenglinw@quicinc.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jestar@qti.qualcomm.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_collinsd@quicinc.com \
    --cc=quic_kamalw@quicinc.com \
    --cc=quic_subbaram@quicinc.com \
    --cc=robh+dt@kernel.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

all inboxes | Powered by JetHome®