usb: typec: tps6598x: handle block reads separately with plain-I2C adapters
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Wed, 25 Apr 2018 14:22:09 +0000 (17:22 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 May 2018 17:55:31 +0000 (10:55 -0700)
commit1a2f474d328f292ee706414824ec4ca690cdf5ba
tree785580246bf5876d87b0715364df50c313baec46
parent5671a4608c326b8ec16dec2f0f32e64a33cdd317
usb: typec: tps6598x: handle block reads separately with plain-I2C adapters

If the I2C adapter that the PD controller is attached to
does not support SMBus protocol, the driver needs to handle
block reads separately. The first byte returned in block
read protocol will show the total number of bytes. It needs
to be stripped away.

This is handled separately in the driver only because right
now we have no way of requesting the used protocol with
regmap-i2c. This is in practice a workaround for what is
really a problem in regmap-i2c. The other option would have
been to register custom regmap, or not use regmap at all,
however, since the solution is very simple, I choose to use
it in this case for convenience. It is easy to remove once
we figure out how to handle this kind of cases in
regmap-i2c.

Fixes: 0a4c005bd171 ("usb: typec: driver for TI TPS6598x USB Power Delivery controllers")
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/tps6598x.c