diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-06 20:03:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-06 20:03:49 -0400 |
commit | 521f3970853a4b2ff7f833763532bdba2ea11257 (patch) | |
tree | 671b7ae7f048c8ae1a00ad1e491716563dc236cf /samples | |
parent | d880e5ad0df3c2e1d69bb356737a46abb5087d42 (diff) | |
parent | 395317bbc200fbc164e65cc8ec31fa9d766aeaf1 (diff) |
Merge tag 'rpmsg-v4.9' of git://github.com/andersson/remoteproc
Pull rpmsg updates from Bjorn Andersson:
"The bulk of these patches involve splitting the rpmsg implementation
into a framework/API part and a virtio specific backend part. It then
adds the Qualcomm Shared Memory Device (SMD) as an additional
supported wire format.
Also included is a set of code style cleanups that have been lingering
for a while"
* tag 'rpmsg-v4.9' of git://github.com/andersson/remoteproc: (26 commits)
rpmsg: smd: fix dependency on QCOM_SMD=n
rpmsg: Introduce Qualcomm SMD backend
rpmsg: Allow callback to return errors
rpmsg: Move virtio specifics from public header
rpmsg: virtio: Hide vrp pointer from the public API
rpmsg: Hide rpmsg indirection tables
rpmsg: Split rpmsg core and virtio backend
rpmsg: Split off generic tail of create_channel()
rpmsg: Move helper for finding rpmsg devices to core
rpmsg: Move endpoint related interface to rpmsg core
rpmsg: Indirection table for rpmsg_endpoint operations
rpmsg: Move rpmsg_device API to new file
rpmsg: Introduce indirection table for rpmsg_device operations
rpmsg: Clean up rpmsg device vs channel naming
rpmsg: Make rpmsg_create_ept() take channel_info struct
rpmsg: rpmsg_send() operations takes rpmsg_endpoint
rpmsg: Name rpmsg devices based on channel id
rpmsg: Enable matching devices with drivers based on DT
rpmsg: Drop prototypes for non-existing functions
samples/rpmsg: add support for multiple instances
...
Diffstat (limited to 'samples')
-rw-r--r-- | samples/rpmsg/rpmsg_client_sample.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/samples/rpmsg/rpmsg_client_sample.c b/samples/rpmsg/rpmsg_client_sample.c index d0e249c90668..f161dfd3e70a 100644 --- a/samples/rpmsg/rpmsg_client_sample.c +++ b/samples/rpmsg/rpmsg_client_sample.c | |||
@@ -24,38 +24,52 @@ | |||
24 | #define MSG "hello world!" | 24 | #define MSG "hello world!" |
25 | #define MSG_LIMIT 100 | 25 | #define MSG_LIMIT 100 |
26 | 26 | ||
27 | static void rpmsg_sample_cb(struct rpmsg_channel *rpdev, void *data, int len, | 27 | struct instance_data { |
28 | int rx_count; | ||
29 | }; | ||
30 | |||
31 | static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, | ||
28 | void *priv, u32 src) | 32 | void *priv, u32 src) |
29 | { | 33 | { |
30 | int ret; | 34 | int ret; |
31 | static int rx_count; | 35 | struct instance_data *idata = dev_get_drvdata(&rpdev->dev); |
32 | 36 | ||
33 | dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", ++rx_count, src); | 37 | dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", |
38 | ++idata->rx_count, src); | ||
34 | 39 | ||
35 | print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1, | 40 | print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1, |
36 | data, len, true); | 41 | data, len, true); |
37 | 42 | ||
38 | /* samples should not live forever */ | 43 | /* samples should not live forever */ |
39 | if (rx_count >= MSG_LIMIT) { | 44 | if (idata->rx_count >= MSG_LIMIT) { |
40 | dev_info(&rpdev->dev, "goodbye!\n"); | 45 | dev_info(&rpdev->dev, "goodbye!\n"); |
41 | return; | 46 | return 0; |
42 | } | 47 | } |
43 | 48 | ||
44 | /* send a new message now */ | 49 | /* send a new message now */ |
45 | ret = rpmsg_send(rpdev, MSG, strlen(MSG)); | 50 | ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); |
46 | if (ret) | 51 | if (ret) |
47 | dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); | 52 | dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); |
53 | |||
54 | return 0; | ||
48 | } | 55 | } |
49 | 56 | ||
50 | static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) | 57 | static int rpmsg_sample_probe(struct rpmsg_device *rpdev) |
51 | { | 58 | { |
52 | int ret; | 59 | int ret; |
60 | struct instance_data *idata; | ||
53 | 61 | ||
54 | dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n", | 62 | dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n", |
55 | rpdev->src, rpdev->dst); | 63 | rpdev->src, rpdev->dst); |
56 | 64 | ||
65 | idata = devm_kzalloc(&rpdev->dev, sizeof(*idata), GFP_KERNEL); | ||
66 | if (!idata) | ||
67 | return -ENOMEM; | ||
68 | |||
69 | dev_set_drvdata(&rpdev->dev, idata); | ||
70 | |||
57 | /* send a message to our remote processor */ | 71 | /* send a message to our remote processor */ |
58 | ret = rpmsg_send(rpdev, MSG, strlen(MSG)); | 72 | ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); |
59 | if (ret) { | 73 | if (ret) { |
60 | dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); | 74 | dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); |
61 | return ret; | 75 | return ret; |
@@ -64,7 +78,7 @@ static int rpmsg_sample_probe(struct rpmsg_channel *rpdev) | |||
64 | return 0; | 78 | return 0; |
65 | } | 79 | } |
66 | 80 | ||
67 | static void rpmsg_sample_remove(struct rpmsg_channel *rpdev) | 81 | static void rpmsg_sample_remove(struct rpmsg_device *rpdev) |
68 | { | 82 | { |
69 | dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n"); | 83 | dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n"); |
70 | } | 84 | } |