Re: [PATCH 2/3] drivers: regulator: qcom: add PMS405 SPMI regulator

From: Mark Brown
Date: Thu Apr 25 2019 - 14:37:51 EST


On Fri, Apr 19, 2019 at 07:29:48PM +0200, Jorge Ramirez wrote:
> On 2/4/19 10:03, Mark Brown wrote:

> >> + /* we know we only have one range for this type */
> >> + if (vreg->logical_type == SPMI_REGULATOR_LOGICAL_TYPE_HFS430)
> >> + return range;

> > Rather than have special casing for the logical type in here it seems
> > better to just provide a specific op for this logical type, you could
> > always make _find_range() call into that one if you really want code
> > reuse here. You already have separate ops for this regulator type
> > anyway.

> sorry I dont quite understand your point.

If you need to skip the majority of the contents of the function for
some regulators just define a separate function for those regulators and
give them different ops structures rather than using the same ops
structure and handling it in the functions.

> But also I am not sure I see the benefits with respect to the proposed
> change...

The benefit is that the selection of which operations to use is done in
only one place (the selection of the ops structure) rather than in
multiple places (the selection of the ops structure and the contents of
the operations).

Attachment: signature.asc
Description: PGP signature