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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 24 Mar 2015 13:51:08 +0200
From:	Daniel Baluta <daniel.baluta@...el.com>
To:	Mika Westerberg <mika.westerberg@...ux.intel.com>,
	Denis CIOCCA <denis.ciocca@...com>
Cc:	Robert Dolca <robert.dolca@...el.com>,
	"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
	Jonathan Cameron <jic23@...nel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Hartmut Knaack <knaack.h@....de>,
	Lars-Peter Clausen <lars@...afoo.de>,
	Peter Meerwald <pmeerw@...erw.net>,
	Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH] IIO: Adds ACPI support for ST gyroscopes

On Mon, Mar 23, 2015 at 5:18 PM, Mika Westerberg
<mika.westerberg@...ux.intel.com> wrote:
> On Mon, Mar 23, 2015 at 03:40:24PM +0200, Robert Dolca wrote:
>> Signed-off-by: Robert Dolca <robert.dolca@...el.com>
>> ---
>>  drivers/iio/common/st_sensors/st_sensors_i2c.c | 35 ++++++++++++++++++++++++++
>>  drivers/iio/gyro/st_gyro_i2c.c                 | 29 ++++++++++++++++++++-
>>  include/linux/iio/common/st_sensors_i2c.h      |  3 +++
>>  3 files changed, 66 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c
>> index 98cfee29..2f612ec 100644
>> --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c
>> +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c
>> @@ -13,6 +13,8 @@
>>  #include <linux/slab.h>
>>  #include <linux/iio/iio.h>
>>  #include <linux/of_device.h>
>> +#include <linux/acpi.h>
>> +#include <linux/gpio/consumer.h>
>>
>>  #include <linux/iio/common/st_sensors_i2c.h>
>>
>> @@ -107,6 +109,39 @@ void st_sensors_of_i2c_probe(struct i2c_client *client,
>>  EXPORT_SYMBOL(st_sensors_of_i2c_probe);
>>  #endif
>>
>> +int st_sensors_acpi_i2c_probe(struct i2c_client *client,
>> +                            const struct acpi_device_id *match)
>> +{
>> +     const struct acpi_device_id *id;
>> +     struct gpio_desc *gpiod_irq;
>> +     int ret;
>> +
>> +     id = acpi_match_device(match, &client->dev);
>> +     if (!id)
>> +             return -ENODEV;
>> +
>> +     /* Get IRQ GPIO */
>> +     gpiod_irq = devm_gpiod_get_index(&client->dev, 0, 0);
>
> Please use plain devm_gpiod_get(&client->dev, NULL). That should work
> with DT and ACPI _DSD as well.
>
>> +     if (IS_ERR(gpiod_irq))
>> +             return -ENODEV;
>
> Why not return the original error here? Now you lose things like
> -EPROBE_DEFER.
>
>> +     /* Configure IRQ GPIO */
>> +     ret = gpiod_direction_input(gpiod_irq);
>> +     if (ret)
>> +             return ret;
>> +
>> +     /* Map the pin to an IRQ */
>> +     client->irq = gpiod_to_irq(gpiod_irq);
>> +
>> +     /* The name from the ACPI match takes precedence if present */
>> +     memset(client->name, 0, sizeof(client->name));
>> +     strncpy(client->name, (char *) id->driver_data,
>> +             min(sizeof(client->name), strlen((char *) id->driver_data)));
>
> Hmm, the above should not be required at all. If the device has an ACPI
> companion the I2C core will match first with that.
>
> Also you now modify the original i2c_client structure. Should you at
> least restore the original values when the driver is unbound?

Hi Mika,

This is similar with device tree  aproach. Looking at st_sensors_of_i2c_probe,
we have:

»       /* The name from the OF match takes precedence if present */
»       strncpy(client->name, of_id->data, sizeof(client->name));
»       client->name[sizeof(client->name) - 1] = '\0';

We want to keep the compatibility with the device tree implementation. Not
sure if the custom name is really required.

Denis, perhaps you can offer more info on this.

Daniel.
--
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