Re: [PATCH v2 3/3] gpio: Add Spreadtrum PMIC EIC driver support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26 February 2018 at 20:02, Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
> On Mon, Feb 26, 2018 at 5:01 AM, Baolin Wang <baolin.wang@xxxxxxxxxx> wrote:
>> On 25 February 2018 at 20:19, Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
>>> On Sat, Feb 24, 2018 at 12:44 PM, Baolin Wang <baolin.wang@xxxxxxxxxx> wrote:
>
>>>> +static int sprd_pmic_eic_direction_input(struct gpio_chip *chip,
>>>> +                                        unsigned int offset)
>>>> +{
>>>> +       /* EICs are always input, nothing need to do here. */
>>>> +       return 0;
>>>> +}
>>>> +
>>>> +static void sprd_pmic_eic_set(struct gpio_chip *chip, unsigned int offset,
>>>> +                             int value)
>>>> +{
>>>> +       /* EICs are always input, nothing need to do here. */
>>>> +}
>>>
>>> Remove both.
>>>
>>> Look at what GPIO core does.
>>
>> I've checked the GPIO core, we need the
>> sprd_pmic_eic_direction_input() returns 0, since user can set GPIOD_IN
>> flag when requesting one GPIO, otherwise it will return errors.
>
> Right. I thought it depends on presence of direction_output().
>
>> We also need one dummy sprd_pmic_eic_set() when setting debounce for
>> one GPIO, otherwise it will return errors.
>
> This is pretty much a "feature" of GPIO framework. It shouldn't
> require ->set() by logic if there is no output facility.
> OK.
>
>>>> +       for (n = 0; n < chip->ngpio; n++) {
>>>> +               if (!(BIT(n) & val))
>>>
>>> for_each_set_bit().
>>>
>>> At some point you may need just to go across lib/ in the kernel and
>>> see what we have there.
>>
>> I've considered the for_each_set_bit(), it need one 'unsigned long'
>> type parameter, but we get the value from regmap is 'u32' type. So we
>> need one extra conversion from 'u32' to 'unsigned long' like:
>>
>> unsigned long reg = val;
>>
>> for_each_set_bit(n, &reg, chip->ngpio) {
>>         .......
>> }
>>
>> If you like this conversion, then I can change to use
>> for_each_set_bit(). Thanks.
>
> Wouldn't it work like
>
> unsigned long val;
>
> ...regmap_read(..., &val);
>
> ?

It can not work, regmap_read() expects 'unsigned int *'. But I can
convert it like this:

for_each_set_bit(n, (unsigned long *)&val, chip->ngpio) {
         .......
}

-- 
Baolin.wang
Best Regards
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux