9 #define KMSG_COMPONENT "monwriter"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
15 #include <linux/errno.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
19 #include <linux/ctype.h>
20 #include <linux/poll.h>
23 #include <linux/slab.h>
24 #include <asm/uaccess.h>
30 #define MONWRITE_MAX_DATALEN 4010
32 static int mon_max_bufs = 255;
33 static int mon_buf_count;
64 id.prod_fn = myhdr->
applid;
69 rc = appldata_asm(&
id, fcn, (
void *) buffer, myhdr->
datalen);
72 pr_err(
"Writing monitor data failed with rc=%i\n", rc);
108 monbuf = monwrite_find_hdr(monpriv, monhdr);
112 rc = monwrite_diag(monhdr, monbuf->
data,
121 if (mon_buf_count >= mon_max_bufs)
137 monpriv->current_buf = monbuf;
141 static int monwrite_new_data(
struct mon_private *monpriv)
150 rc = monwrite_diag(monhdr, monbuf->
data,
157 rc = monwrite_diag(monhdr, monbuf->
data,
163 rc = monwrite_diag(monhdr, monbuf->
data,
188 INIT_LIST_HEAD(&monpriv->
list);
196 static int monwrite_close(
struct inode *inode,
struct file *filp)
203 monwrite_diag(&entry->
hdr, entry->
data,
215 static ssize_t monwrite_write(
struct file *filp,
const char __user *
data,
216 size_t count, loff_t *ppos)
224 for (written = 0; written <
count; ) {
227 to = (
char *) &monpriv->
hdr +
237 rc = monwrite_new_hdr(monpriv);
256 rc = monwrite_new_data(monpriv);
274 .open = &monwrite_open,
275 .release = &monwrite_close,
276 .write = &monwrite_write,
282 .fops = &monwrite_fops,
290 static int monwriter_freeze(
struct device *
dev)
298 monwrite_diag(&monbuf->
hdr, monbuf->
data,
305 static int monwriter_restore(
struct device *dev)
313 monwrite_diag(&monbuf->
hdr, monbuf->
data,
316 monwrite_diag(&monbuf->
hdr, monbuf->
data,
323 static int monwriter_thaw(
struct device *dev)
325 return monwriter_restore(dev);
328 static const struct dev_pm_ops monwriter_pm_ops = {
329 .freeze = monwriter_freeze,
330 .thaw = monwriter_thaw,
331 .restore = monwriter_restore,
338 .pm = &monwriter_pm_ops,
348 static int __init mon_init(
void)
359 monwriter_pdev = platform_device_register_simple(
"monwriter", -1, NULL,
361 if (IS_ERR(monwriter_pdev)) {
362 rc = PTR_ERR(monwriter_pdev);
382 static void __exit mon_exit(
void)
394 "that can be active at one time");
398 "APPLDATA monitor records.");