aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-07-29 17:39:37 -0400
committerJonathan Cameron <jic23@kernel.org>2015-08-08 07:22:16 -0400
commit03ecd50c50450b3e3173c9dda8adab241b46ae1e (patch)
treebcc701901d0ece4fd5d3a89cab48a286dc4d6883
parent18422bb3c1d89b510bb7c590c716dd6ad8e1a1e4 (diff)
iio:accel:stk8312: rework macro definitions
Make use of BIT to describe register bits, GENMASK for consecutive bitmasks, rename and sort existing definitions, replace magic value with an expressive definition, drop an unused definition. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Reviewed-by: Tiberiu Breana <tiberiu.a.breana@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/accel/stk8312.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index 82ad283b8c60..d406ad05b8e5 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -37,16 +37,16 @@
37#define STK8312_REG_OTPDATA 0x3E 37#define STK8312_REG_OTPDATA 0x3E
38#define STK8312_REG_OTPCTRL 0x3F 38#define STK8312_REG_OTPCTRL 0x3F
39 39
40#define STK8312_MODE_ACTIVE 0x01 40#define STK8312_MODE_ACTIVE BIT(0)
41#define STK8312_MODE_STANDBY 0x00 41#define STK8312_MODE_STANDBY 0x00
42#define STK8312_DREADY_BIT 0x10 42#define STK8312_MODE_INT_AH_PP 0xC0 /* active-high, push-pull */
43#define STK8312_INT_MODE 0xC0 43#define STK8312_DREADY_BIT BIT(4)
44#define STK8312_RNG_MASK 0xC0 44#define STK8312_RNG_6G 1
45#define STK8312_SR_MASK 0x07
46#define STK8312_SR_400HZ_IDX 0
47#define STK8312_RNG_SHIFT 6 45#define STK8312_RNG_SHIFT 6
48#define STK8312_READ_RETRIES 16 46#define STK8312_RNG_MASK GENMASK(7, 6)
49#define STK8312_ALL_CHANNEL_MASK 7 47#define STK8312_SR_MASK GENMASK(2, 0)
48#define STK8312_SR_400HZ_IDX 0
49#define STK8312_ALL_CHANNEL_MASK GENMASK(2, 0)
50#define STK8312_ALL_CHANNEL_SIZE 3 50#define STK8312_ALL_CHANNEL_SIZE 3
51 51
52#define STK8312_DRIVER_NAME "stk8312" 52#define STK8312_DRIVER_NAME "stk8312"
@@ -144,7 +144,7 @@ static int stk8312_otp_init(struct stk8312_data *data)
144 if (ret < 0) 144 if (ret < 0)
145 goto exit_err; 145 goto exit_err;
146 count--; 146 count--;
147 } while (!(ret & 0x80) && count > 0); 147 } while (!(ret & BIT(7)) && count > 0);
148 148
149 if (count == 0) { 149 if (count == 0) {
150 ret = -ETIMEDOUT; 150 ret = -ETIMEDOUT;
@@ -565,11 +565,12 @@ static int stk8312_probe(struct i2c_client *client,
565 return ret; 565 return ret;
566 } 566 }
567 data->sample_rate_idx = STK8312_SR_400HZ_IDX; 567 data->sample_rate_idx = STK8312_SR_400HZ_IDX;
568 ret = stk8312_set_range(data, 1); 568 ret = stk8312_set_range(data, STK8312_RNG_6G);
569 if (ret < 0) 569 if (ret < 0)
570 return ret; 570 return ret;
571 571
572 ret = stk8312_set_mode(data, STK8312_INT_MODE | STK8312_MODE_ACTIVE); 572 ret = stk8312_set_mode(data,
573 STK8312_MODE_INT_AH_PP | STK8312_MODE_ACTIVE);
573 if (ret < 0) 574 if (ret < 0)
574 return ret; 575 return ret;
575 576
@@ -691,7 +692,7 @@ MODULE_DEVICE_TABLE(acpi, stk8312_acpi_id);
691 692
692static struct i2c_driver stk8312_driver = { 693static struct i2c_driver stk8312_driver = {
693 .driver = { 694 .driver = {
694 .name = "stk8312", 695 .name = STK8312_DRIVER_NAME,
695 .pm = STK8312_PM_OPS, 696 .pm = STK8312_PM_OPS,
696 .acpi_match_table = ACPI_PTR(stk8312_acpi_id), 697 .acpi_match_table = ACPI_PTR(stk8312_acpi_id),
697 }, 698 },