[PATCH v4 4/4] iio: humidity: si7020: added No Hold read mode

Nicola Corna nicola at corna.info
Wed Oct 28 11:35:17 PDT 2015


October 28 2015 10:38 AM, "Lars-Peter Clausen" <lars at metafoo.de> wrote:

> On 10/28/2015 07:58 AM, Nicola Corna wrote:
> [...]
> 
>> + holdmode = !((*client)->adapter->quirks &&
>> + (*client)->adapter->quirks->flags &
> 
> [...]
> 
>> + client->adapter->quirks &&
>> + client->adapter->quirks->flags & I2C_AQ_NO_CLK_STRETCH)
> 
> This is rather ugly, can we get a helper in the I2C core something along the
> lines of
> 
> i2c_check_quirks(client->adapter, I2C_AQ_NO_CLK_STRETCH)
> 
> - Lars

Something like this?

---
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a69a9a0..a06ffc0 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -613,6 +613,12 @@ static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
return (func & i2c_get_functionality(adap)) == func;
}

+/* Return 1 if adapter has the specified quirks, 0 if not. */
+static inline int i2c_check_quirks(struct i2c_adapter *adap, u64 quirks)
+{
+ return (quirks & (adap->quirks ? adap->quirks->flags : 0)) == quirks;
+}
+
/* Return the adapter number for a specific adapter */
static inline int i2c_adapter_id(struct i2c_adapter *adap)
{



More information about the linux-arm-kernel mailing list