~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/samples/rpmsg/rpmsg_client_sample.c

Version: ~ [ linux-5.9 ] ~ [ linux-5.8.14 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.70 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.150 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.200 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.238 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.238 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Remote processor messaging - sample client driver
  4  *
  5  * Copyright (C) 2011 Texas Instruments, Inc.
  6  * Copyright (C) 2011 Google, Inc.
  7  *
  8  * Ohad Ben-Cohen <ohad@wizery.com>
  9  * Brian Swetland <swetland@google.com>
 10  */
 11 
 12 #include <linux/kernel.h>
 13 #include <linux/module.h>
 14 #include <linux/rpmsg.h>
 15 
 16 #define MSG             "hello world!"
 17 #define MSG_LIMIT       100
 18 
 19 struct instance_data {
 20         int rx_count;
 21 };
 22 
 23 static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len,
 24                                                 void *priv, u32 src)
 25 {
 26         int ret;
 27         struct instance_data *idata = dev_get_drvdata(&rpdev->dev);
 28 
 29         dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n",
 30                  ++idata->rx_count, src);
 31 
 32         print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1,
 33                        data, len,  true);
 34 
 35         /* samples should not live forever */
 36         if (idata->rx_count >= MSG_LIMIT) {
 37                 dev_info(&rpdev->dev, "goodbye!\n");
 38                 return 0;
 39         }
 40 
 41         /* send a new message now */
 42         ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
 43         if (ret)
 44                 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
 45 
 46         return 0;
 47 }
 48 
 49 static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
 50 {
 51         int ret;
 52         struct instance_data *idata;
 53 
 54         dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
 55                                         rpdev->src, rpdev->dst);
 56 
 57         idata = devm_kzalloc(&rpdev->dev, sizeof(*idata), GFP_KERNEL);
 58         if (!idata)
 59                 return -ENOMEM;
 60 
 61         dev_set_drvdata(&rpdev->dev, idata);
 62 
 63         /* send a message to our remote processor */
 64         ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
 65         if (ret) {
 66                 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
 67                 return ret;
 68         }
 69 
 70         return 0;
 71 }
 72 
 73 static void rpmsg_sample_remove(struct rpmsg_device *rpdev)
 74 {
 75         dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n");
 76 }
 77 
 78 static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
 79         { .name = "rpmsg-client-sample" },
 80         { },
 81 };
 82 MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_sample_id_table);
 83 
 84 static struct rpmsg_driver rpmsg_sample_client = {
 85         .drv.name       = KBUILD_MODNAME,
 86         .id_table       = rpmsg_driver_sample_id_table,
 87         .probe          = rpmsg_sample_probe,
 88         .callback       = rpmsg_sample_cb,
 89         .remove         = rpmsg_sample_remove,
 90 };
 91 module_rpmsg_driver(rpmsg_sample_client);
 92 
 93 MODULE_DESCRIPTION("Remote processor messaging sample client driver");
 94 MODULE_LICENSE("GPL v2");
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp