From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Scot Doyle <lkml14@scotdoyle.com>
Cc: Benson Leung <bleung@chromium.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Olof Johansson <olof@lixom.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] platform/chrome: Probe multiple i2c adapters of the same name
Date: Wed, 11 Jun 2014 12:24:04 +0300 [thread overview]
Message-ID: <20140611092309.GC1657@lahna.fi.intel.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1406100610220.8274@scotdoyle.com>
On Tue, Jun 10, 2014 at 06:17:35AM +0100, Scot Doyle wrote:
> 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.
>
> Thanks to Mika Westerberg for identifying the need for unique bus addresses
> within each set of identically-named adapters.
>
> Signed-off-by: Scot Doyle <lkml14@scotdoyle.com>
> CC: Benson Leung <bleung@chromium.org>
> CC: Mika Westerberg <mika.westerberg@linux.intel.com>
Few comments about style:
> ---
> diff --git a/drivers/platform/chrome/chromeos_laptop.c
> b/drivers/platform/chrome/chromeos_laptop.c
> index 7f3aad0..8382315 100644
> --- a/drivers/platform/chrome/chromeos_laptop.c
> +++ b/drivers/platform/chrome/chromeos_laptop.c
> @@ -29,6 +29,8 @@
> #include <linux/module.h>
> #include <linux/platform_device.h>
>
> +/* Note: Bus addresses must be unique within each set of identically-named
> + adapters on a board, otherwise device probing may fail. */
Check Documentation/CodingStyle about format of block comments.
> #define ATMEL_TP_I2C_ADDR 0x4b
> #define ATMEL_TP_I2C_BL_ADDR 0x25
> #define ATMEL_TS_I2C_ADDR 0x4a
> @@ -173,7 +175,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 +196,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 +229,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;
Please add blank line here.
> + while (!client && adapter_num > -1) {
> + adapter_num = find_i2c_next_adapter_num(type, start);
> + client = __add_probed_i2c_device(name,
> + adapter_num,
> + info,
> + addrs);
Don't the above fit into one line, specifically if you call adapter_num
just num or something like that.
> + }
> + return client;
> }
>
> /*
> @@ -242,10 +252,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);
Same here.
> }
>
> static int setup_cyapa_tp(enum i2c_adapter_type type)
next prev parent reply other threads:[~2014-06-11 9:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 13:02 [PATCH] platform/chrome: Add support for Acer C720 Mika Westerberg
2014-06-03 19:46 ` Benson Leung
2014-06-04 8:37 ` Mika Westerberg
2014-06-04 20:12 ` Benson Leung
2014-06-06 22:06 ` [PATCH 0/1] platform/chrome: Probe multiple i2c adapters of the same name Scot Doyle
2014-06-06 22:25 ` [PATCH 1/1] " Scot Doyle
2014-06-09 12:47 ` Mika Westerberg
2014-06-10 5:08 ` Scot Doyle
2014-06-10 5:17 ` [PATCH v2 " Scot Doyle
2014-06-11 9:24 ` Mika Westerberg [this message]
2014-06-11 17:51 ` [PATCH v3 " Scot Doyle
2014-06-11 17:09 ` Benson Leung
2014-06-11 22:23 ` Scot Doyle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140611092309.GC1657@lahna.fi.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=bleung@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml14@scotdoyle.com \
--cc=olof@lixom.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.