lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 6 Jun 2014 23:25:14 +0100 (BST)
From:	Scot Doyle <lkml14@...tdoyle.com>
To:	Benson Leung <bleung@...omium.org>,
	Mika Westerberg <mika.westerberg@...ux.intel.com>
cc:	"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
	Olof Johansson <olof@...om.net>, linux-kernel@...r.kernel.org
Subject: [PATCH 1/1] platform/chrome: Probe multiple i2c adapters of the same
 name

The chromeos_laptop module probes the first i2c adapter with a specific 
name for expected hardware. However, the Acer C720 Chromebook has two i2c 
adapters with the same name. This patch probes each i2c adapter with a 
specific name in turn, until locating the expected hardware.

Signed-off-by: Scot Doyle <lkml14@...tdoyle.com>
CC: Benson Leung <bleung@...omium.org>
CC: Mika Westerberg <mika.westerberg@...ux.intel.com>
---
diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
index 7f3aad0..3a3382e 100644
--- a/drivers/platform/chrome/chromeos_laptop.c
+++ b/drivers/platform/chrome/chromeos_laptop.c
@@ -173,7 +173,7 @@ static struct i2c_client *__add_probed_i2c_device(
  	/* add the i2c device */
  	client = i2c_new_probed_device(adapter, info, addrs, NULL);
  	if (!client)
-		pr_err("%s failed to register device %d-%02x\n",
+		pr_debug("%s did not add i2c device %d-%02x\n",
  		       __func__, bus, info->addr);
  	else
  		pr_debug("%s added i2c device %d-%02x\n",
@@ -194,13 +194,14 @@ static int __find_i2c_adap(struct device *dev, void *data)
  	return (strncmp(adapter->name, name, strlen(name)) == 0);
  }

-static int find_i2c_adapter_num(enum i2c_adapter_type type)
+static int find_i2c_next_adapter_num(enum i2c_adapter_type type,
+		struct device *start)
  {
  	struct device *dev = NULL;
  	struct i2c_adapter *adapter;
  	const char *name = i2c_adapter_names[type];
-	/* find the adapter by name */
-	dev = bus_find_device(&i2c_bus_type, NULL, (void *)name,
+	/* find the next adapter by name */
+	dev = bus_find_device(&i2c_bus_type, start, (void *)name,
  			      __find_i2c_adap);
  	if (!dev) {
  		/* Adapters may appear later. Deferred probing will retry */
@@ -226,10 +227,17 @@ static struct i2c_client *add_probed_i2c_device(
  		struct i2c_board_info *info,
  		const unsigned short *addrs)
  {
-	return __add_probed_i2c_device(name,
-				       find_i2c_adapter_num(type),
-				       info,
-				       addrs);
+	struct i2c_client *client = NULL;
+	struct device *start = NULL;
+	int adapter_num = 0;
+	while (!client && adapter_num > -1) {
+		adapter_num = find_i2c_next_adapter_num(type, start);
+		client = __add_probed_i2c_device(name,
+						 adapter_num,
+						 info,
+						 addrs);
+	}
+	return client;
  }

  /*
@@ -242,10 +250,10 @@ static struct i2c_client *add_i2c_device(const char *name,
  						struct i2c_board_info *info)
  {
  	const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
-	return __add_probed_i2c_device(name,
-				       find_i2c_adapter_num(type),
-				       info,
-				       addr_list);
+	return add_probed_i2c_device(name,
+				     type,
+				     info,
+				     addr_list);
  }

  static int setup_cyapa_tp(enum i2c_adapter_type type)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ