accel: Fix getting scale for sensors with IIO_SHARED_BY_ALL mask

Properties with the IIO_SHARED_BY_ALL mask don't have the sensor type prefix
before the filename, causing some devices to not have a scale set from sysfs.

Fix this by searching through sysfs for both properties name: scale and
in_accel_scale.

Tested on: Cyan (Acer Chromebook R11, with 2 accelerometers)
Affects: All chromebooks with cros-ec sensors
https://github.com/torvalds/linux/tree/master/drivers/iio/common/cros_ec_sensors
This commit is contained in:
Daniel Stuart
2019-10-04 13:38:45 -03:00
committed by hadess
parent eb8fde8fd2
commit 43e5ff769e
6 changed files with 34 additions and 13 deletions

24
src/accel-attributes.h Normal file
View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2019 Luís Ferreira <luis@aurorafoss.org>
* Copyright (c) 2019 Daniel Stuart <daniel.stuart@pucpr.edu.br>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
*/
#include <glib.h>
#include <gudev/gudev.h>
typedef enum {
ACCEL_LOCATION_DISPLAY,
ACCEL_LOCATION_BASE,
} AccelLocation;
AccelLocation setup_accel_location (GUdevDevice *device);
gboolean parse_accel_location (const char *location,
AccelLocation *value);
gdouble get_accel_scale (GUdevDevice *device);