The range parameter is changed as per convention. Signed-off-by: Shubhrajyoti D <shubhrajyoti@xxxxxx> --- drivers/staging/iio/magnetometer/hmc5843.c | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 92f6c6f..7582642 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -434,16 +434,28 @@ static ssize_t set_range(struct device *dev, struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct hmc5843_data *data = indio_dev->dev_data; unsigned long range = 0; - int error; - mutex_lock(&data->lock); - error = strict_strtoul(buf, 10, &range); - if (error) - return error; + dev_dbg(dev, "set range to %lu\n", range); - if (range > RANGE_6_5) + if (strncmp(buf, "700" , 4) == 0) + range = RANGE_0_7; + else if (strncmp(buf, "1000" , 4) == 0) + range = RANGE_1_0; + else if (strncmp(buf, "1500", 3) == 0) + range = RANGE_1_5; + else if (strncmp(buf, "2000", 3) == 0) + range = RANGE_2_0; + else if (strncmp(buf, "3200", 3) == 0) + range = RANGE_3_2; + else if (strncmp(buf, "3800" , 3) == 0) + range = RANGE_3_8; + else if (strncmp(buf, "4500" , 3) == 0) + range = RANGE_4_5; + else if (strncmp(buf, "6500" , 3) == 0) + range = RANGE_6_5; + else return -EINVAL; - + mutex_lock(&data->lock); data->range = range; range = range << RANGE_GAIN_OFFSET; if (i2c_smbus_write_byte_data(client, this_attr->address, range)) -- 1.5.4.7 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html