Re: [PATCH v7 6/6] platform/x86: dell-smo8800: Add support for probing for the accelerometer i2c address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 5, 2024 at 3:39 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
>
> Unfortunately the SMOxxxx ACPI device does not contain the i2c-address
> of the accelerometer. So a DMI product-name to address mapping table
> is used.
>
> At support to have the kernel probe for the i2c-address for modesl

models

> which are not on the list.
>
> The new probing code sits behind a new probe_i2c_addr module parameter,
> which is disabled by default because probing might be dangerous.

...

> +static int detect_lis3lv02d(struct i2c_adapter *adap, unsigned short addr)
> +{
> +       union i2c_smbus_data smbus_data;
> +       int err;
> +
> +       pr_info("Probing for lis3lv02d on address 0x%02x\n", addr);

Using dev_info() against an adapter device might be more useful, no?

> +       err = i2c_smbus_xfer(adap, addr, 0, I2C_SMBUS_READ, LIS3_WHO_AM_I,
> +                            I2C_SMBUS_BYTE_DATA, &smbus_data);
> +       if (err < 0)
> +               return 0; /* Not found */
> +
> +       /* valid who-am-i values are from drivers/misc/lis3lv02d/lis3lv02d.c */
> +       switch (smbus_data.byte) {
> +       case 0x32:
> +       case 0x33:
> +       case 0x3a:
> +       case 0x3b:
> +               break;
> +       default:
> +               pr_warn("Unknown who-am-i register value 0x%02x\n", smbus_data.byte);
> +               return 0; /* Not found */
> +       }
> +
> +       pr_debug("Detected lis3lv02d on address 0x%02x\n", addr);

Ditto for the rest of pr_*() in this function.

> +       return 1; /* Found */
> +}

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux