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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.9 ] ~ [ 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 
 18 static int count = 100;
 19 module_param(count, int, 0644);
 20 
 21 struct instance_data {
 22         int rx_count;
 23 };
 24 
 25 static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len,
 26                                                 void *priv, u32 src)
 27 {
 28         int ret;
 29         struct instance_data *idata = dev_get_drvdata(&rpdev->dev);
 30 
 31         dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n",
 32                  ++idata->rx_count, src);
 33 
 34         print_hex_dump_debug(__func__, DUMP_PREFIX_NONE, 16, 1, data, len,
 35                              true);
 36 
 37         /* samples should not live forever */
 38         if (idata->rx_count >= count) {
 39                 dev_info(&rpdev->dev, "goodbye!\n");
 40                 return 0;
 41         }
 42 
 43         /* send a new message now */
 44         ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
 45         if (ret)
 46                 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
 47 
 48         return 0;
 49 }
 50 
 51 static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
 52 {
 53         int ret;
 54         struct instance_data *idata;
 55 
 56         dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
 57                                         rpdev->src, rpdev->dst);
 58 
 59         idata = devm_kzalloc(&rpdev->dev, sizeof(*idata), GFP_KERNEL);
 60         if (!idata)
 61                 return -ENOMEM;
 62 
 63         dev_set_drvdata(&rpdev->dev, idata);
 64 
 65         /* send a message to our remote processor */
 66         ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
 67         if (ret) {
 68                 dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
 69                 return ret;
 70         }
 71 
 72         return 0;
 73 }
 74 
 75 static void rpmsg_sample_remove(struct rpmsg_device *rpdev)
 76 {
 77         dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n");
 78 }
 79 
 80 static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
 81         { .name = "rpmsg-client-sample" },
 82         { },
 83 };
 84 MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_sample_id_table);
 85 
 86 static struct rpmsg_driver rpmsg_sample_client = {
 87         .drv.name       = KBUILD_MODNAME,
 88         .id_table       = rpmsg_driver_sample_id_table,
 89         .probe          = rpmsg_sample_probe,
 90         .callback       = rpmsg_sample_cb,
 91         .remove         = rpmsg_sample_remove,
 92 };
 93 module_rpmsg_driver(rpmsg_sample_client);
 94 
 95 MODULE_DESCRIPTION("Remote processor messaging sample client driver");
 96 MODULE_LICENSE("GPL v2");
 97 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php