Re: [PATCH RESEND v2 1/4] mfd: intel_soc_pmic: Core driver

From: Zhu, Lejun
Date: Tue May 27 2014 - 20:55:28 EST



On 5/27/2014 7:20 PM, Mark Brown wrote:
> On Tue, May 27, 2014 at 08:48:58AM +0800, Zhu, Lejun wrote:
>> On 5/26/2014 10:51 PM, Mark Brown wrote:
>
>>>> We created these names to hide the implementation of how read/write is
>>>> done from other platform specific patches interacting with this driver.
>>>> So when we change the implementation, e.g. from I2C read/write to
>>>> regmap, we don't have to touch all these patches.
>
>>> This sort of HAL is frowned upon in the upstream kernel.
>
>> We want to do what other MFD drivers' been doing, and make it easier for
>> the callers. A couple of similar examples are intel_msic_reg_read() and
>> lp3943_read_byte(). We want to do the same with intel_soc_pmic_readb(),
>> and I don't think it's too odd.
>
> The odd and problematic bit is the global variable part of things -
> these wrappers are usually just doing lookup of the underlying I/O
> handle in the struct for the device and can be implemented as static
> inlines in the header.
>

Oh I see. Sorry I missed your point. So you are saying "int
intel_soc_pmic_readb(int reg)" is bad, but if I have:

int intel_soc_pmic_readb(struct intel_soc_pmic *pmic, int reg)
{
int ret;
unsigned int val;

ret = regmap_read(pmic->regmap, reg, &val);
if (!ret)
ret = val;

return ret;
}

And have the caller (device or core) look up and pass *pmic in, this
will be OK?

Best Regards
Lejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/