Re: [PATCH V6 2/2] i2c/designware: Provide i2c bus recovery support

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

 



On 25 November 2012 02:33, Wolfram Sang <w.sang@xxxxxxxxxxxxxx> wrote:
>> diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c

>> @@ -538,7 +538,12 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
>>       ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ);
>>       if (ret == 0) {
>>               dev_err(dev->dev, "controller timed out\n");
>> -             i2c_dw_init(dev);
>> +             if (adap->bus_recovery_info &&
>> +                             adap->bus_recovery_info->recover_bus) {
>> +                     dev_dbg(dev->dev, "try i2c bus recovery\n");
>> +                     adap->bus_recovery_info->recover_bus(adap);
>> +             }
>> +
>
> This should be in the core?

Because wait_for_completion() would fail in controllers, so i kept this
code here. How will we come to know about xfer failure in core?

Though i realize that check for adap->bus_recovery_info->recover_bus()
is just not required.

>> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
>> +     /* Bus recovery support */
>> +     pdata = dev_get_platdata(&pdev->dev);
>> +     if (pdata) {
>> +             recovery_info = kzalloc(sizeof(*recovery_info), GFP_KERNEL);
>> +             if (!recovery_info) {
>> +                     adap->bus_recovery_info = NULL;
>> +                     dev_err(&pdev->dev,
>> +                             "failure to allocate memory for bus recovery\n");
>> +                     goto skip_recovery;
>> +             }
>> +
>> +             recovery_info->is_gpio_recovery = true;
>> +             recovery_info->get_gpio = pdata->get_gpio;
>> +             recovery_info->put_gpio = pdata->put_gpio;
>> +             recovery_info->scl_gpio = pdata->scl_gpio;
>> +             recovery_info->scl_gpio_flags = pdata->scl_gpio_flags;
>> +             recovery_info->clock_rate_khz = clk_get_rate(dev->clk) / 1000;
>
> It is probably easier to define the whole bri structure in the platform
> and simply pass it on here? Hmm, now devicetree also comes to my mind.
> Will think about that a little, too, but main implementation should be
> left for someone needing that.

Ok. I didn't went for DT as recovery_info also has some routines, for which
we need special implementation for platforms.

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


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux