[PATCH] i2c: sirf: get the i2c pin group by pinctrl api

Barry Song 21cnbao at gmail.com
Mon Mar 18 04:23:35 EDT 2013


2013/3/18 Sourav Poddar <sourav.poddar at ti.com>:
> Hi,
>
> On Monday 18 March 2013 12:52 PM, Barry Song wrote:
>>
>> From: Barry Song<Baohua.Song at csr.com>
>>
>> hardcode set i2c pin group to i2c function before, here we
>> move to use standard pinctrl API to get pins of the group.
>>
>> Signed-off-by: Barry Song<Baohua.Song at csr.com>
>> Cc: Linus Walleij<linus.walleij at linaro.org>
>> ---
>>   drivers/i2c/busses/i2c-sirf.c |    9 +++++++++
>>   1 files changed, 9 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
>> index 5a7ad24..dd4004e 100644
>> --- a/drivers/i2c/busses/i2c-sirf.c
>> +++ b/drivers/i2c/busses/i2c-sirf.c
>> @@ -16,6 +16,7 @@
>>   #include<linux/clk.h>
>>   #include<linux/err.h>
>>   #include<linux/io.h>
>> +#include<linux/pinctrl/consumer.h>
>>
>>   #define SIRFSOC_I2C_CLK_CTRL          0x00
>>   #define SIRFSOC_I2C_STATUS            0x0C
>> @@ -265,6 +266,7 @@ static int i2c_sirfsoc_probe(struct platform_device
>> *pdev)
>>         struct i2c_adapter *adap;
>>         struct resource *mem_res;
>>         struct clk *clk;
>> +       struct pinctrl *pinctrl;
>>         int bitrate;
>>         int ctrl_speed;
>>         int irq;
>> @@ -272,6 +274,12 @@ static int i2c_sirfsoc_probe(struct platform_device
>> *pdev)
>>         int err;
>>         u32 regval;
>>
>> +       pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>> +       if (IS_ERR(pinctrl)) {
>> +               err = PTR_ERR(pinctrl);
>> +               goto failed_pin;
>> +       }
>> +
>
> I think,  you should also add an "EPROBE_DEFER" check here ?

why would the driver require a probe retry since getting the pinctrl
has returned an error? before the driver executes, pinctrl driver has
run earlier and DT has been extended.

all people are using  IS_ERR(pinctrl) to check the ret of
devm_pinctrl_get_select_default.

>
>>         clk = clk_get(&pdev->dev, NULL);
>>         if (IS_ERR(clk)) {
>>                 err = PTR_ERR(clk);
>> @@ -385,6 +393,7 @@ err_clk_en:
>>   err_clk_prep:
>>         clk_put(clk);
>>   err_get_clk:
>> +failed_pin:
>>         return err;
>>   }

-barry



More information about the linux-arm-kernel mailing list