Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1712466

[PATCH v2 01/14] i2c: Allow overriding dev_name through board_info

From Hans de Goede <hdegoede@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v2 01/14] i2c: Allow overriding dev_name through board_info
Date 2017-08-15 22:10 +0200
Message-ID <ueQk5-5RL-69@gated-at.bofh.it> (permalink)
References <ueQk1-5RL-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/i2c/i2c-core-base.c | 10 ++++++++--
 include/linux/i2c.h         |  2 ++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 1d28454..22dc8ba 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -672,10 +672,16 @@ static void i2c_adapter_unlock_bus(struct i2c_adapter *adapter,
 }
 
 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);
 
+	if (info && info->dev_name) {
+		dev_set_name(&client->dev, "i2c-%s", info->dev_name);
+		return;
+	}
+
 	if (adev) {
 		dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev));
 		return;
@@ -772,7 +778,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
 	client->dev.of_node = info->of_node;
 	client->dev.fwnode = info->fwnode;
 
-	i2c_dev_set_name(adap, client);
+	i2c_dev_set_name(adap, client, info);
 
 	if (info->properties) {
 		status = device_add_properties(&client->dev, info->properties);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 701ad26..d3655cf 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -310,6 +310,7 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
  * @type: chip type, to initialize i2c_client.name
  * @flags: to initialize i2c_client.flags
  * @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
  * @archdata: copied into i2c_client.dev.archdata
  * @of_node: pointer to OpenFirmware device node
@@ -334,6 +335,7 @@ struct i2c_board_info {
 	char		type[I2C_NAME_SIZE];
 	unsigned short	flags;
 	unsigned short	addr;
+	const char	*dev_name;
 	void		*platform_data;
 	struct dev_archdata	*archdata;
 	struct device_node *of_node;
-- 
2.9.4

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/14] Hookup typec power-negotation to the PMIC and charger Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
  [PATCH v2 11/14] power: supply: bq24190_charger: Get input_current_limit from our supplier Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
    Re: [PATCH v2 11/14] power: supply: bq24190_charger: Get  input_current_limit from our supplier Liam Breck <liam@networkimprov.net> - 2017-08-16 22:30 +0200
  [PATCH v2 09/14] power: supply: bq24190_charger: Export 5V boost converter as regulator Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
  [PATCH v2 06/14] staging: typec: fusb302: Add support for USB2 charger detection through extcon Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
  [PATCH v2 02/14] staging: typec: tcpm: Add get_current_limit tcpc_dev callback Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
    Re: [PATCH v2 02/14] staging: typec: tcpm: Add get_current_limit  tcpc_dev callback Guenter Roeck <linux@roeck-us.net> - 2017-08-16 17:20 +0200
  [PATCH v2 12/14] power: supply: bq24190_charger: Remove extcon handling Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
  [PATCH v2 08/14] power: supply: Add power_supply_set_input_current_limit_from_supplier helper Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200
    Re: [PATCH v2 08/14] power: supply: Add  power_supply_set_input_current_limit_from_supplier helper Tony Lindgren <tony@atomide.com> - 2017-08-16 18:00 +0200
      Re: [PATCH v2 08/14] power: supply: Add  power_supply_set_input_current_limit_from_supplier helper Hans de Goede <hdegoede@redhat.com> - 2017-08-16 19:40 +0200
        Re: [PATCH v2 08/14] power: supply: Add  power_supply_set_input_current_limit_from_supplier helper Tony Lindgren <tony@atomide.com> - 2017-08-16 21:30 +0200
  [PATCH v2 01/14] i2c: Allow overriding dev_name through board_info Hans de Goede <hdegoede@redhat.com> - 2017-08-15 22:10 +0200

csiph-web