i2c: Allow overriding dev_name through board_info
For devices not instantiated through ACPI the i2c-client's device-name gets set to <busnr>-<addr> by default, e.g. "0-0022" this means that the device-name is dependent on the order in which the i2c-busses are enumerated. In some cases having a predictable constant device-name is desirable, for example on non device-tree platforms the link between a regulator and its consumers is specified by the platform code by setting regulator_init_data.consumers. This array identifies the regulator's consumers by dev_name and supply(-name). Which requires a constant dev_name. This commit adds a dev_name field to i2c_board_info allowing platform code to set a contstant dev_name so that the device can be identified by its dev_name in other platform code. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Mark Brown <broonie@kernel.org> (live at ELCE17) Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> (live at ELCE17) Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
committed by
Wolfram Sang
parent
bb176f6709
commit
728fe6cef2
@@ -666,10 +666,16 @@ static void i2c_adapter_unlock_bus(struct i2c_adapter *adapter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void i2c_dev_set_name(struct i2c_adapter *adap,
|
static void i2c_dev_set_name(struct i2c_adapter *adap,
|
||||||
struct i2c_client *client)
|
struct i2c_client *client,
|
||||||
|
struct i2c_board_info const *info)
|
||||||
{
|
{
|
||||||
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
|
struct acpi_device *adev = ACPI_COMPANION(&client->dev);
|
||||||
|
|
||||||
|
if (info && info->dev_name) {
|
||||||
|
dev_set_name(&client->dev, "i2c-%s", info->dev_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (adev) {
|
if (adev) {
|
||||||
dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev));
|
dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev));
|
||||||
return;
|
return;
|
||||||
@@ -766,7 +772,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
|
|||||||
client->dev.of_node = info->of_node;
|
client->dev.of_node = info->of_node;
|
||||||
client->dev.fwnode = info->fwnode;
|
client->dev.fwnode = info->fwnode;
|
||||||
|
|
||||||
i2c_dev_set_name(adap, client);
|
i2c_dev_set_name(adap, client, info);
|
||||||
|
|
||||||
if (info->properties) {
|
if (info->properties) {
|
||||||
status = device_add_properties(&client->dev, info->properties);
|
status = device_add_properties(&client->dev, info->properties);
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
|
|||||||
* @type: chip type, to initialize i2c_client.name
|
* @type: chip type, to initialize i2c_client.name
|
||||||
* @flags: to initialize i2c_client.flags
|
* @flags: to initialize i2c_client.flags
|
||||||
* @addr: stored in i2c_client.addr
|
* @addr: stored in i2c_client.addr
|
||||||
|
* @dev_name: Overrides the default <busnr>-<addr> dev_name if set
|
||||||
* @platform_data: stored in i2c_client.dev.platform_data
|
* @platform_data: stored in i2c_client.dev.platform_data
|
||||||
* @archdata: copied into i2c_client.dev.archdata
|
* @archdata: copied into i2c_client.dev.archdata
|
||||||
* @of_node: pointer to OpenFirmware device node
|
* @of_node: pointer to OpenFirmware device node
|
||||||
@@ -328,6 +329,7 @@ struct i2c_board_info {
|
|||||||
char type[I2C_NAME_SIZE];
|
char type[I2C_NAME_SIZE];
|
||||||
unsigned short flags;
|
unsigned short flags;
|
||||||
unsigned short addr;
|
unsigned short addr;
|
||||||
|
const char *dev_name;
|
||||||
void *platform_data;
|
void *platform_data;
|
||||||
struct dev_archdata *archdata;
|
struct dev_archdata *archdata;
|
||||||
struct device_node *of_node;
|
struct device_node *of_node;
|
||||||
|
|||||||
Reference in New Issue
Block a user