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]
Message-ID: <1894651.a3DUuyBc1c@vostro.rjw.lan>
Date:	Wed, 20 May 2015 01:35:06 +0200
From:	"Rafael J. Wysocki" <rjw@...ysocki.net>
To:	Robert Dolca <robert.dolca@...el.com>
Cc:	linux-i2c@...r.kernel.org, linux-acpi@...r.kernel.org,
	linux-kernel@...r.kernel.org, Wolfram Sang <wsa@...-dreams.de>,
	Len Brown <lenb@...nel.org>,
	Daniel Baluta <daniel.baluta@...el.com>
Subject: Re: [PATCH RFC] i2c: Use ID table to detect ACPI I2C devices

On Tuesday, May 19, 2015 05:03:29 PM Robert Dolca wrote:
> For i2c devices enumerated with ACPI you need to declare both
> acpi_match_table and id_table. When using ACPI, the i2c_device_id structure
> supplied to the probe function is null and you have to handle this case
> in the driver.
> 
> The current name for the i2c client when using ACPI is "HID:UID" where the
> UID has 7 or 8 characters and the UID has 2 characters. The UID is not
> relevant for identifying the chip so it does not have any practical
> purpose.
> 
> Modifying i2c_match_id we make the comparison by ignoring the UID from the
> client name when the device was discovered using ACPI. The comparison is
> case insensitive because the ACPI names are uppercase and the DT and ID
> table names are lowercase. It would not make sense to have two different
> chips with the same name and the only diference being the capitalized
> letters.
> 
> With these changes the probe function gets a valid i2c_device_id and the
> driver doesn't have to declare acpi_match_table.
> 
> Signed-off-by: Robert Dolca <robert.dolca@...el.com>
> ---
>  drivers/i2c/i2c-core.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index fec0e0d..c9b30b7 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -447,8 +447,18 @@ static inline int acpi_i2c_install_space_handler(struct i2c_adapter *adapter)
>  static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
>  						const struct i2c_client *client)
>  {
> +	char name[I2C_NAME_SIZE], *c;
> +
> +	strlcpy(name, client->name, sizeof(name));
> +
> +	if (ACPI_HANDLE(&client->dev)) {

If you don't need to use the handle, it is better to call has_acpi_companion() here.

> +		c = strchr(name, ':');
> +		if (c)
> +			*c = 0;
> +	}
> +
>  	while (id->name[0]) {
> -		if (strcmp(client->name, id->name) == 0)
> +		if (strncasecmp(name, id->name, sizeof(id->name)) == 0)
>  			return id;
>  		id++;
>  	}
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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