diff options
-rw-r--r-- | drivers/base/regmap/regmap-debugfs.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index 246f459e9170..78d5f20c5f5b 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c | |||
@@ -155,6 +155,19 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map, | |||
155 | return ret; | 155 | return ret; |
156 | } | 156 | } |
157 | 157 | ||
158 | static inline void regmap_calc_tot_len(struct regmap *map, | ||
159 | void *buf, size_t count) | ||
160 | { | ||
161 | /* Calculate the length of a fixed format */ | ||
162 | if (!map->debugfs_tot_len) { | ||
163 | map->debugfs_reg_len = regmap_calc_reg_len(map->max_register, | ||
164 | buf, count); | ||
165 | map->debugfs_val_len = 2 * map->format.val_bytes; | ||
166 | map->debugfs_tot_len = map->debugfs_reg_len + | ||
167 | map->debugfs_val_len + 3; /* : \n */ | ||
168 | } | ||
169 | } | ||
170 | |||
158 | static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, | 171 | static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, |
159 | unsigned int to, char __user *user_buf, | 172 | unsigned int to, char __user *user_buf, |
160 | size_t count, loff_t *ppos) | 173 | size_t count, loff_t *ppos) |
@@ -173,14 +186,7 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, | |||
173 | if (!buf) | 186 | if (!buf) |
174 | return -ENOMEM; | 187 | return -ENOMEM; |
175 | 188 | ||
176 | /* Calculate the length of a fixed format */ | 189 | regmap_calc_tot_len(map, buf, count); |
177 | if (!map->debugfs_tot_len) { | ||
178 | map->debugfs_reg_len = regmap_calc_reg_len(map->max_register, | ||
179 | buf, count); | ||
180 | map->debugfs_val_len = 2 * map->format.val_bytes; | ||
181 | map->debugfs_tot_len = map->debugfs_reg_len + | ||
182 | map->debugfs_val_len + 3; /* : \n */ | ||
183 | } | ||
184 | 190 | ||
185 | /* Work out which register we're starting at */ | 191 | /* Work out which register we're starting at */ |
186 | start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); | 192 | start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p); |