diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-20 18:06:09 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-20 18:06:09 -0800 |
commit | 786856b6d111a30d51c98526cc7a283ecc73f00f (patch) | |
tree | c9577b59d34b36009d11131c547d3df60de8534b /drivers/i2c | |
parent | 43e31e40473a00c936ffb9c2eebedc0566c92e89 (diff) | |
parent | d3e1b617ae20c459627f501b4bc55b1ea91f662b (diff) | |
download | linux-786856b6d111a30d51c98526cc7a283ecc73f00f.tar.bz2 |
Merge tag 'device-properties-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device property updates from Rafael J. Wysocki:
"Generic device properties framework updates for v4.11-rc1
Allow built-in (static) device properties to be declared as constant,
make it possible to save memory by discarding alternative (but unused)
built-in (static) property sets and add support for automatic handling
of built-in properties to the I2C code"
* tag 'device-properties-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
i2c: allow specify device properties in i2c_board_info
device property: export code duplicating array of property entries
device property: constify property arrays values
device property: allow to constify properties
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 1e52395e90a7..bfb6ba7cac00 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1336,15 +1336,29 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info) client->dev.fwnode = info->fwnode; i2c_dev_set_name(adap, client); + + if (info->properties) { + status = device_add_properties(&client->dev, info->properties); + if (status) { + dev_err(&adap->dev, + "Failed to add properties to client %s: %d\n", + client->name, status); + goto out_err; + } + } + status = device_register(&client->dev); if (status) - goto out_err; + goto out_free_props; dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", client->name, dev_name(&client->dev)); return client; +out_free_props: + if (info->properties) + device_remove_properties(&client->dev); out_err: dev_err(&adap->dev, "Failed to register i2c client %s at 0x%02x (%d)\n", |