ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / drivers / rpmsg / rpmsg_server_sample.c
blob67da0127858a6ba549fb7b1746509a7e10985d3c
1 /*
2 * Remote processor messaging transport - sample server driver
4 * Copyright (C) 2011 Texas Instruments, Inc.
5 * Copyright (C) 2011 Google, Inc.
7 * Ohad Ben-Cohen <ohad@wizery.com>
8 * Brian Swetland <swetland@google.com>
10 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms.
15 #define pr_fmt(fmt) "%s: " fmt, __func__
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/virtio.h>
20 #include <linux/scatterlist.h>
21 #include <linux/slab.h>
22 #include <linux/rpmsg.h>
24 #define MSG ("hello world!")
25 #define MSG_LIMIT 100
27 static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len,
28 void *priv, u32 src)
30 int err;
31 static int rx_count;
33 dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", ++rx_count, src);
35 print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1,
36 data, len, true);
38 /* samples should not live forever */
39 if (rx_count >= MSG_LIMIT) {
40 dev_info(&rpdev->dev, "goodbye!\n");
41 return;
44 /* reply */
45 err = rpmsg_sendto(rpdev, MSG, strlen(MSG), src);
46 if (err)
47 pr_err("rpmsg_send failed: %d\n", err);
50 static int rpmsg_sample_probe(struct rpmsg_channel *rpdev)
52 int err;
54 dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
55 rpdev->src, rpdev->dst);
57 err = rpmsg_sendto(rpdev, MSG, strlen(MSG), 50);
58 if (err) {
59 pr_err("rpmsg_send failed: %d\n", err);
60 return err;
63 return 0;
66 static void __devexit rpmsg_sample_remove(struct rpmsg_channel *rpdev)
68 dev_info(&rpdev->dev, "rpmsg sample driver is removed\n");
71 static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
72 { .name = "rpmsg-server-sample" },
73 { },
75 MODULE_DEVICE_TABLE(platform, rpmsg_driver_sample_id_table);
77 static struct rpmsg_driver rpmsg_sample_server_driver = {
78 .drv.name = KBUILD_MODNAME,
79 .drv.owner = THIS_MODULE,
80 .id_table = rpmsg_driver_sample_id_table,
81 .probe = rpmsg_sample_probe,
82 .callback = rpmsg_sample_cb,
83 .remove = __devexit_p(rpmsg_sample_remove),
86 static int __init init(void)
88 return register_rpmsg_driver(&rpmsg_sample_server_driver);
91 static void __exit fini(void)
93 unregister_rpmsg_driver(&rpmsg_sample_server_driver);
95 module_init(init);
96 module_exit(fini);
98 MODULE_DESCRIPTION("Virtio remote processor messaging sample driver");
99 MODULE_LICENSE("GPL v2");