mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benson Leung <bleung@google.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	linux-input@vger.kernel.org, Benson Leung <bleung@chromium.org>
Cc: Nick Dyer <nick@shmanahar.org>, Olof Johansson <olof@lixom.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/14] platform/chrome: chromeos_laptop - factor out getting IRQ from DMI
Date: Mon, 19 Mar 2018 19:14:37 -0700	[thread overview]
Message-ID: <b0457b4a-2e0d-41e1-66fe-6fdb7a00f2db@google.com> (raw)
In-Reply-To: <20180312190907.174301-8-dmitry.torokhov@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2645 bytes --]



On 03/12/2018 12:09 PM, Dmitry Torokhov wrote:
> This will make code instantiating I2C device a bit clearer.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Applied to my working branch for atmel_mxt_ts + chromeos_laptop.c for
v4.17. Thanks!

> ---
>  drivers/platform/chrome/chromeos_laptop.c | 35 +++++++++++++++--------
>  1 file changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c
> index 08ce7a105e768..96e962ff38e87 100644
> --- a/drivers/platform/chrome/chromeos_laptop.c
> +++ b/drivers/platform/chrome/chromeos_laptop.c
> @@ -120,36 +120,47 @@ static struct i2c_board_info atmel_1664s_device = {
>  	.flags		= I2C_CLIENT_WAKE,
>  };
>  
> +static int chromeos_laptop_get_irq_from_dmi(const char *dmi_name)
> +{
> +	const struct dmi_device *dmi_dev;
> +	const struct dmi_dev_onboard *dev_data;
> +
> +	dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, dmi_name, NULL);
> +	if (!dmi_dev) {
> +		pr_err("failed to find DMI device '%s'\n", dmi_name);
> +		return -ENOENT;
> +	}
> +
> +	dev_data = dmi_dev->device_data;
> +	if (!dev_data) {
> +		pr_err("failed to get data from DMI for '%s'\n", dmi_name);
> +		return -EINVAL;
> +	}
> +
> +	return dev_data->instance;
> +}
> +
>  static struct i2c_client *__add_probed_i2c_device(
>  		const char *name,
>  		int bus,
>  		struct i2c_board_info *info,
>  		const unsigned short *alt_addr_list)
>  {
> -	const struct dmi_device *dmi_dev;
> -	const struct dmi_dev_onboard *dev_data;
>  	struct i2c_adapter *adapter;
>  	struct i2c_client *client = NULL;
>  	const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END };
>  
>  	if (bus < 0)
>  		return NULL;
> +
>  	/*
>  	 * If a name is specified, look for irq platform information stashed
>  	 * in DMI_DEV_TYPE_DEV_ONBOARD by the Chrome OS custom system firmware.
>  	 */
>  	if (name) {
> -		dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, name, NULL);
> -		if (!dmi_dev) {
> -			pr_err("failed to dmi find device %s\n", name);
> -			return NULL;
> -		}
> -		dev_data = (struct dmi_dev_onboard *)dmi_dev->device_data;
> -		if (!dev_data) {
> -			pr_err("failed to get data from dmi for %s\n", name);
> +		info->irq = chromeos_laptop_get_irq_from_dmi(name);
> +		if (info->irq < 0)
>  			return NULL;
> -		}
> -		info->irq = dev_data->instance;
>  	}
>  
>  	adapter = i2c_get_adapter(bus);
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-03-20  2:14 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 19:08 [PATCH 00/14] chrome_laptop: stop being a platform driver Dmitry Torokhov
2018-03-12 19:08 ` [PATCH 01/14] Input: atmel_mxt_ts - do not pass suspend mode in platform data Dmitry Torokhov
2018-03-14 20:51   ` Nick Dyer
2018-03-15 23:56     ` Dmitry Torokhov
2018-03-16 20:40       ` Nick Dyer
2018-03-17 17:42         ` Dmitry Torokhov
2018-03-17 20:42           ` Nick Dyer
2018-03-12 19:08 ` [PATCH 02/14] Input: atmel_mxt_ts - switch from OF to generic device properties Dmitry Torokhov
2018-03-14 20:51   ` Nick Dyer
2018-03-12 19:08 ` [PATCH 03/14] Input: atmel_mxt_ts - switch ChromeOS ACPI devices to generic props Dmitry Torokhov
2018-03-14 20:52   ` Nick Dyer
2018-03-12 19:08 ` [PATCH 04/14] platform/chrome: chromeos_laptop - add SPDX identifier Dmitry Torokhov
2018-03-20  1:53   ` Benson Leung
2018-03-12 19:08 ` [PATCH 05/14] platform/chrome: chromeos_laptop - stop setting suspend mode for Atmel devices Dmitry Torokhov
2018-03-12 19:08 ` [PATCH 06/14] platform/chrome: chromeos_laptop - introduce pr_fmt() Dmitry Torokhov
2018-03-20  2:03   ` Benson Leung
2018-03-12 19:09 ` [PATCH 07/14] platform/chrome: chromeos_laptop - factor out getting IRQ from DMI Dmitry Torokhov
2018-03-20  2:14   ` Benson Leung [this message]
2018-03-12 19:09 ` [PATCH 08/14] platform/chrome: chromeos_laptop - rework i2c peripherals initialization Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 09/14] platform/chrome: chromeos_laptop - parse DMI IRQ data once Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 10/14] platform/chrome: chromeos_laptop - use I2C notifier to create devices Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 11/14] platform/chrome: chromeos_laptop - rely on I2C to set up interrupt trigger Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 12/14] platform/chrome: chromeos_laptop - use device properties for Pixel Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 13/14] platform/chrome: chromeos_laptop - discard data for unneeded boards Dmitry Torokhov
2018-03-12 19:09 ` [PATCH 14/14] Input: atmel_mxt_ts - remove platform data support Dmitry Torokhov
2018-03-14 20:59   ` Nick Dyer
2018-03-16  0:06     ` Dmitry Torokhov
2018-03-16 20:41       ` Nick Dyer
2018-03-12 19:17 ` [PATCH 00/14] chrome_laptop: stop being a platform driver Benson Leung

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=b0457b4a-2e0d-41e1-66fe-6fdb7a00f2db@google.com \
    --to=bleung@google.com \
    --cc=bleung@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick@shmanahar.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome