Re: [PATCHv6] lis3lv02d: support both one- and two-byte sensors

From: Ãric Piel
Date: Wed Feb 11 2009 - 04:47:52 EST


Giuseppe Bilotta schreef:
:
> Same as v5, with a couple of renames to have simpler and more meaningful
> names. The #define's for the LISxxxxx families have been renamed
> according to the actual functional distinction, and the struct member
> holding the data read function has been renamed to read_data.
>
Almost good... just a little thing more:
> @@ -254,10 +270,21 @@ static int lis3lv02d_add(struct acpi_device *device)
> strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
> device->driver_data = &adev;
>
> - lis3lv02d_acpi_read(device->handle, WHO_AM_I, &val);
> - if ((val != LIS3LV02DL_ID) && (val != LIS302DL_ID)) {
> - printk(KERN_ERR DRIVER_NAME
> - ": Accelerometer chip not LIS3LV02D{L,Q}\n");
> + lis3lv02d_acpi_read(device->handle, WHO_AM_I, &adev.whoami);
> + switch (adev.whoami) {
> + case LIS_DOUBLE_ID:
> + printk(KERN_INFO DRIVER_NAME ": 2-byte sensor found\n");
> + adev.read_data = lis3lv02d_read_16;
> + adev.mdps_max_val = 2048;
> + break;
> + case LIS_SINGLE_ID:
> + printk(KERN_INFO DRIVER_NAME ": 1-byte sensor found\n");
> + adev.read_data = lis3lv02d_read_8;
> + adev.mdps_max_val = 128;
> + break;
> + default:
> + printk(KERN_ERR DRIVER_NAME
> + ": unknown sensor type 0x%X\n", adev.whoami);
> }

In the default case, add:
return -EINVAL;
I don't want the driver to start messing with chips we have no idea what
they do!

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/