hmc6352.c (9a64e8e0ace51b309fdcff4b4754b3649250382a) hmc6352.c (f7b41276b6b07f47c5f5212fa244385b0e3aaa30)
1/*
2 * hmc6352.c - Honeywell Compass Driver
3 *
4 * Copyright (C) 2009 Intel Corp
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 32 unchanged lines hidden (view full) ---

41
42static int compass_store(struct device *dev, const char *buf, size_t count,
43 const char *map)
44{
45 struct i2c_client *c = to_i2c_client(dev);
46 int ret;
47 unsigned long val;
48
1/*
2 * hmc6352.c - Honeywell Compass Driver
3 *
4 * Copyright (C) 2009 Intel Corp
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 32 unchanged lines hidden (view full) ---

41
42static int compass_store(struct device *dev, const char *buf, size_t count,
43 const char *map)
44{
45 struct i2c_client *c = to_i2c_client(dev);
46 int ret;
47 unsigned long val;
48
49 if (strict_strtoul(buf, 10, &val))
50 return -EINVAL;
49 ret = kstrtoul(buf, 10, &val);
50 if (ret)
51 return ret;
51 if (val >= strlen(map))
52 return -EINVAL;
53 mutex_lock(&compass_mutex);
54 ret = compass_command(c, map[val]);
55 mutex_unlock(&compass_mutex);
56 if (ret < 0)
57 return ret;
58 return count;

--- 97 unchanged lines hidden ---
52 if (val >= strlen(map))
53 return -EINVAL;
54 mutex_lock(&compass_mutex);
55 ret = compass_command(c, map[val]);
56 mutex_unlock(&compass_mutex);
57 if (ret < 0)
58 return ret;
59 return count;

--- 97 unchanged lines hidden ---