aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-09-06 11:14:28 -0400
committerLee Jones <lee.jones@linaro.org>2013-10-23 11:20:37 -0400
commitb5f90240e1ef0568a8c666da3c3be4c6a682c5a6 (patch)
treee8d25ef536822cd09371903a9e3b65e03c043e9f
parent8a8320c2e78d1b619a8fa8eb5ae946b8691de604 (diff)
mfd: wm8994: Inline register I/O functions
Since the register I/O functions are all simple wrappers for the regmap equivalents inline them to provide a small code size saving and an example of good practice. Signed-off-by: Mark Brown <broonie@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/wm8994-core.c78
-rw-r--r--include/linux/mfd/wm8994/core.h45
2 files changed, 36 insertions, 87 deletions
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index e1c283e6d4e5..030827511667 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -33,84 +33,6 @@
33 33
34#include "wm8994.h" 34#include "wm8994.h"
35 35
36/**
37 * wm8994_reg_read: Read a single WM8994 register.
38 *
39 * @wm8994: Device to read from.
40 * @reg: Register to read.
41 */
42int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
43{
44 unsigned int val;
45 int ret;
46
47 ret = regmap_read(wm8994->regmap, reg, &val);
48
49 if (ret < 0)
50 return ret;
51 else
52 return val;
53}
54EXPORT_SYMBOL_GPL(wm8994_reg_read);
55
56/**
57 * wm8994_bulk_read: Read multiple WM8994 registers
58 *
59 * @wm8994: Device to read from
60 * @reg: First register
61 * @count: Number of registers
62 * @buf: Buffer to fill. The data will be returned big endian.
63 */
64int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
65 int count, u16 *buf)
66{
67 return regmap_bulk_read(wm8994->regmap, reg, buf, count);
68}
69
70/**
71 * wm8994_reg_write: Write a single WM8994 register.
72 *
73 * @wm8994: Device to write to.
74 * @reg: Register to write to.
75 * @val: Value to write.
76 */
77int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
78 unsigned short val)
79{
80 return regmap_write(wm8994->regmap, reg, val);
81}
82EXPORT_SYMBOL_GPL(wm8994_reg_write);
83
84/**
85 * wm8994_bulk_write: Write multiple WM8994 registers
86 *
87 * @wm8994: Device to write to
88 * @reg: First register
89 * @count: Number of registers
90 * @buf: Buffer to write from. Data must be big-endian formatted.
91 */
92int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
93 int count, const u16 *buf)
94{
95 return regmap_raw_write(wm8994->regmap, reg, buf, count * sizeof(u16));
96}
97EXPORT_SYMBOL_GPL(wm8994_bulk_write);
98
99/**
100 * wm8994_set_bits: Set the value of a bitfield in a WM8994 register
101 *
102 * @wm8994: Device to write to.
103 * @reg: Register to write to.
104 * @mask: Mask of bits to set.
105 * @val: Value to set (unshifted)
106 */
107int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
108 unsigned short mask, unsigned short val)
109{
110 return regmap_update_bits(wm8994->regmap, reg, mask, val);
111}
112EXPORT_SYMBOL_GPL(wm8994_set_bits);
113
114static struct mfd_cell wm8994_regulator_devs[] = { 36static struct mfd_cell wm8994_regulator_devs[] = {
115 { 37 {
116 .name = "wm8994-ldo", 38 .name = "wm8994-ldo",
diff --git a/include/linux/mfd/wm8994/core.h b/include/linux/mfd/wm8994/core.h
index 40854ac0ba3d..3fbcf3d4a0fe 100644
--- a/include/linux/mfd/wm8994/core.h
+++ b/include/linux/mfd/wm8994/core.h
@@ -85,16 +85,43 @@ struct wm8994 {
85}; 85};
86 86
87/* Device I/O API */ 87/* Device I/O API */
88int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg);
89int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
90 unsigned short val);
91int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
92 unsigned short mask, unsigned short val);
93int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
94 int count, u16 *buf);
95int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
96 int count, const u16 *buf);
97 88
89static inline int wm8994_reg_read(struct wm8994 *wm8994, unsigned short reg)
90{
91 unsigned int val;
92 int ret;
93
94 ret = regmap_read(wm8994->regmap, reg, &val);
95
96 if (ret < 0)
97 return ret;
98 else
99 return val;
100}
101
102static inline int wm8994_reg_write(struct wm8994 *wm8994, unsigned short reg,
103 unsigned short val)
104{
105 return regmap_write(wm8994->regmap, reg, val);
106}
107
108static inline int wm8994_bulk_read(struct wm8994 *wm8994, unsigned short reg,
109 int count, u16 *buf)
110{
111 return regmap_bulk_read(wm8994->regmap, reg, buf, count);
112}
113
114static inline int wm8994_bulk_write(struct wm8994 *wm8994, unsigned short reg,
115 int count, const u16 *buf)
116{
117 return regmap_raw_write(wm8994->regmap, reg, buf, count * sizeof(u16));
118}
119
120static inline int wm8994_set_bits(struct wm8994 *wm8994, unsigned short reg,
121 unsigned short mask, unsigned short val)
122{
123 return regmap_update_bits(wm8994->regmap, reg, mask, val);
124}
98 125
99/* Helper to save on boilerplate */ 126/* Helper to save on boilerplate */
100static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq, 127static inline int wm8994_request_irq(struct wm8994 *wm8994, int irq,