[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZgXSBiQcBEbwF060@google.com>
Date: Thu, 28 Mar 2024 13:24:38 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Fenglin Wu <quic_fenglinw@...cinc.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org,
krzysztof.kozlowski+dt@...aro.org, robh+dt@...nel.org,
agross@...nel.org, andersson@...nel.org,
Konrad Dybcio <konrad.dybcio@...aro.org>,
linux-input@...r.kernel.org, quic_collinsd@...cinc.com,
quic_subbaram@...cinc.com, quic_kamalw@...cinc.com,
jestar@....qualcomm.com, Luca Weiss <luca.weiss@...rphone.com>
Subject: Re: [RESEND PATCH v6 3/3] input: pm8xxx-vibrator: add new SPMI
vibrator support
Hi Fenglin,
On Thu, Mar 28, 2024 at 02:52:32PM +0800, Fenglin Wu wrote:
>
>
> On 2023/10/1 0:17, Dmitry Torokhov wrote:
> > On Mon, Sep 25, 2023 at 10:54:45AM +0800, Fenglin Wu wrote:
> > >
> > >
> > > On 9/24/2023 3:07 AM, Dmitry Baryshkov wrote:
> > > > > +
> > > > > + switch (vib->data->hw_type) {
> > > > > + case SSBI_VIB:
> > > > > mask = SSBI_VIB_DRV_LEVEL_MASK;
> > > > > shift = SSBI_VIB_DRV_SHIFT;
> > > > > + break;
> > > > > + case SPMI_VIB:
> > > > > + mask = SPMI_VIB_DRV_LEVEL_MASK;
> > > > > + shift = SPMI_VIB_DRV_SHIFT;
> > > > > + break;
> > > > > + case SPMI_VIB_GEN2:
> > > > > + mask = SPMI_VIB_GEN2_DRV_MASK;
> > > > > + shift = SPMI_VIB_GEN2_DRV_SHIFT;
> > > > > + break;
> > > > > + default:
> > > > > + return -EINVAL;
> > > > Could you please move the switch to the previous patch? Then it would
> > > > be more obvious that you are just adding the SPMI_VIB_GEN2 here.
> > > >
> > > > Other than that LGTM.
> > >
> > > Sure, I can move the switch to the previous refactoring patch.
> >
> > Actually, the idea of having a const "reg" or "chip", etc. structure is
> > to avoid this kind of runtime checks based on hardware type and instead
> > use common computation. I believe you need to move mask and shift into
> > the chip-specific structure and avoid defining hw_type.
> >
> > Thanks.
>
> Hi Dmitry,
>
> The v7 changes have been pending for a while, I am not sure if you are still
> insist on this. As I explained, I actually did it this way in v2 and it got
> updated to this by following other comments.
>
> Can you respond and tell me if you prefer changes similar to v2? I can
> update and push v8 by following your suggestion.
>
> v7: https://lore.kernel.org/linux-arm-msm/20231108-pm8xxx-vibrator-v7-0-632c731d25a8@quicinc.com/
>
> v2: https://lore.kernel.org/linux-arm-msm/20230718062639.2339589-3-quic_fenglinw@quicinc.com/
Yes, I believe what you had in v2 was better, and Dmitry Baryshkov's
comments on v2 were also great.
You can have 2 styles of code - you have a hw type for each regulator
and then use it to do conditional logic in the code. If you do it this
way you and you need to add a new device type or model you have to go
through the code and validate all the checks. Or you could have a
structure that is defined flexibly enough to cover all existing
permutations, and you rely on the data in it to control the behavior.
You should not mix the 2 styles, as this just makes the code more
confusing.
Thanks.
--
Dmitry
Powered by blists - more mailing lists