Source
197
197
}
198
198
199
199
static ssize_t gpio_mockup_debugfs_read(struct file *file,
200
200
char __user *usr_buf,
201
201
size_t size, loff_t *ppos)
202
202
{
203
203
struct gpio_mockup_dbgfs_private *priv;
204
204
struct gpio_mockup_chip *chip;
205
205
struct seq_file *sfile;
206
206
struct gpio_chip *gc;
207
-
int val, rv, cnt;
207
+
int val, cnt;
208
208
char buf[3];
209
209
210
-
211
210
if (*ppos != 0)
212
211
return 0;
213
212
214
213
sfile = file->private_data;
215
214
priv = sfile->private;
216
215
chip = priv->chip;
217
216
gc = &chip->gc;
218
217
219
218
val = gpio_mockup_get(gc, priv->offset);
220
219
cnt = snprintf(buf, sizeof(buf), "%d\n", val);
221
220
222
-
rv = copy_to_user(usr_buf, buf, cnt);
223
-
if (rv)
224
-
return rv;
225
-
226
-
*ppos += cnt;
227
-
return cnt;
221
+
return simple_read_from_buffer(usr_buf, size, ppos, buf, cnt);
228
222
}
229
223
230
224
static ssize_t gpio_mockup_debugfs_write(struct file *file,
231
225
const char __user *usr_buf,
232
226
size_t size, loff_t *ppos)
233
227
{
234
228
struct gpio_mockup_dbgfs_private *priv;
235
229
int rv, val, curr, irq, irq_type;
236
230
struct gpio_mockup_chip *chip;
237
231
struct seq_file *sfile;