Interpret default_addr 0 in a way that the caller doesn't want a default. Note: i2c_new_dummy_device() would fail anyway, but it would leave an ugly error message complaining about invalid address 0. Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx> --- drivers/i2c/i2c-core-base.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 315ecd960..6ff245ef1 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1146,7 +1146,8 @@ static u32 i2c_prepare_ancillary_device(struct i2c_client *client, * and create the associated device * @client: Handle to the primary client * @name: Handle to specify which secondary address to get - * @default_addr: Used as a fallback if no secondary address was specified + * @default_addr: Used as a fallback if no secondary address was specified. + * Don't try to fall back if default_addr is zero. * Context: can sleep * * I2C clients can be composed of multiple I2C slaves bound together in a single @@ -1169,6 +1170,9 @@ struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, { u32 addr = i2c_prepare_ancillary_device(client, name, default_addr); + if (!addr && !default_addr) + return ERR_PTR(-ENOENT); + return i2c_new_dummy_device(client->adapter, addr); } EXPORT_SYMBOL_GPL(i2c_new_ancillary_device); @@ -1179,6 +1183,9 @@ struct i2c_client *devm_i2c_new_ancillary_device(struct i2c_client *client, { u32 addr = i2c_prepare_ancillary_device(client, name, default_addr); + if (!addr && !default_addr) + return ERR_PTR(-ENOENT); + return devm_i2c_new_dummy_device(&client->dev, client->adapter, addr); } EXPORT_SYMBOL_GPL(devm_i2c_new_ancillary_device); -- 2.39.1