summaryrefslogtreecommitdiff
path: root/drivers/hwmon/lis3lv02d.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2010-10-02 01:14:25 +0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2010-10-26 01:11:20 +0400
commit2ee321440e3a594dcdd9981e68e5e302447047a2 (patch)
treec2dde23d160339ff713f9fd12f7922cca0c8c6d3 /drivers/hwmon/lis3lv02d.c
parent37394050b5be0fe87f96ed8848f11c3c2cd4d556 (diff)
downloadlinux-2ee321440e3a594dcdd9981e68e5e302447047a2.tar.xz
hwmon: (lis3) add axes module parameter for custom axis-mapping
The axis-mapping of lis3dev device on many (rather most) HP machines doesn't follow the standard. When each new model appears, users need to adjust again. Testing this requires the rebuild of kernel, thus it's not trivial for end-users. This patch adds a module parameter "axes" to allow a custom axis-mapping without patching and recompiling the kernel driver. User can pass the parameter such as axes=3,2,1. Also it can be changed via sysfs. Signed-off-by: Takashi Iwai <tiwai@suse.de> Acked-by: Eric Piel <eric.piel@tremplin-utc.net> Cc: Jean Delvare <khali@linux-fr.org> Cc: Guenter Roeck <guenter.roeck@ericsson.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/lis3lv02d.c')
-rw-r--r--drivers/hwmon/lis3lv02d.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index ef7510d83603..25f385010953 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -75,6 +75,30 @@ struct lis3lv02d lis3_dev = {
EXPORT_SYMBOL_GPL(lis3_dev);
+/* just like param_set_int() but does sanity-check so that it won't point
+ * over the axis array size
+ */
+static int param_set_axis(const char *val, const struct kernel_param *kp)
+{
+ int ret = param_set_int(val, kp);
+ if (!ret) {
+ int val = *(int *)kp->arg;
+ if (val < 0)
+ val = -val;
+ if (!val || val > 3)
+ return -EINVAL;
+ }
+ return ret;
+}
+
+static struct kernel_param_ops param_ops_axis = {
+ .set = param_set_axis,
+ .get = param_get_int,
+};
+
+module_param_array_named(axes, lis3_dev.ac.as_array, axis, NULL, 0644);
+MODULE_PARM_DESC(axes, "Axis-mapping for x,y,z directions");
+
static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg)
{
s8 lo;