Commit 714638e0 authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Wolfram Sang

i2c: Add support for software nodes

This makes it possible for the drivers to assign complete
software fwnodes to the devices instead of only the device
properties in those nodes.
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent e49d033b
...@@ -919,15 +919,27 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf ...@@ -919,15 +919,27 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
} }
} }
if (info->swnode) {
status = device_add_software_node(&client->dev, info->swnode);
if (status) {
dev_err(&adap->dev,
"Failed to add software node to client %s: %d\n",
client->name, status);
goto out_free_props;
}
}
status = device_register(&client->dev); status = device_register(&client->dev);
if (status) if (status)
goto out_free_props; goto out_remove_swnode;
dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n",
client->name, dev_name(&client->dev)); client->name, dev_name(&client->dev));
return client; return client;
out_remove_swnode:
device_remove_software_node(&client->dev);
out_free_props: out_free_props:
if (info->properties) if (info->properties)
device_remove_properties(&client->dev); device_remove_properties(&client->dev);
...@@ -960,6 +972,7 @@ void i2c_unregister_device(struct i2c_client *client) ...@@ -960,6 +972,7 @@ void i2c_unregister_device(struct i2c_client *client)
if (ACPI_COMPANION(&client->dev)) if (ACPI_COMPANION(&client->dev))
acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev)); acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev));
device_remove_software_node(&client->dev);
device_unregister(&client->dev); device_unregister(&client->dev);
} }
EXPORT_SYMBOL_GPL(i2c_unregister_device); EXPORT_SYMBOL_GPL(i2c_unregister_device);
......
...@@ -391,7 +391,8 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; } ...@@ -391,7 +391,8 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
* @platform_data: stored in i2c_client.dev.platform_data * @platform_data: stored in i2c_client.dev.platform_data
* @of_node: pointer to OpenFirmware device node * @of_node: pointer to OpenFirmware device node
* @fwnode: device node supplied by the platform firmware * @fwnode: device node supplied by the platform firmware
* @properties: additional device properties for the device * @properties: Deprecated - use swnode instead
* @swnode: software node for the device
* @resources: resources associated with the device * @resources: resources associated with the device
* @num_resources: number of resources in the @resources array * @num_resources: number of resources in the @resources array
* @irq: stored in i2c_client.irq * @irq: stored in i2c_client.irq
...@@ -416,6 +417,7 @@ struct i2c_board_info { ...@@ -416,6 +417,7 @@ struct i2c_board_info {
struct device_node *of_node; struct device_node *of_node;
struct fwnode_handle *fwnode; struct fwnode_handle *fwnode;
const struct property_entry *properties; const struct property_entry *properties;
const struct software_node *swnode;
const struct resource *resources; const struct resource *resources;
unsigned int num_resources; unsigned int num_resources;
int irq; int irq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment