Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rpmsg: Constify buffer passed to send API

The rpmsg_send(), rpmsg_sendto() and other variants of sending
interfaces should only send the passed data, without modifying its
contents, so mark pointer 'data' as pointer to const. All users of this
interface already follow this approach, so only the function
declarations have to be updated.

Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260317-rpmsg-send-const-v3-3-4d7fd27f037f@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Bjorn Andersson
b8077b4d 90dacbf4

+46 -38
+2 -2
drivers/rpmsg/mtk_rpmsg.c
··· 135 135 kref_put(&ept->refcount, __mtk_ept_release); 136 136 } 137 137 138 - static int mtk_rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) 138 + static int mtk_rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len) 139 139 { 140 140 struct mtk_rpmsg_rproc_subdev *mtk_subdev = 141 141 to_mtk_rpmsg_endpoint(ept)->mtk_subdev; ··· 144 144 len, 0); 145 145 } 146 146 147 - static int mtk_rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) 147 + static int mtk_rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, int len) 148 148 { 149 149 struct mtk_rpmsg_rproc_subdev *mtk_subdev = 150 150 to_mtk_rpmsg_endpoint(ept)->mtk_subdev;
+6 -4
drivers/rpmsg/qcom_smd.c
··· 960 960 kref_put(&ept->refcount, __ept_release); 961 961 } 962 962 963 - static int qcom_smd_send(struct rpmsg_endpoint *ept, void *data, int len) 963 + static int qcom_smd_send(struct rpmsg_endpoint *ept, const void *data, int len) 964 964 { 965 965 struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); 966 966 967 967 return __qcom_smd_send(qsept->qsch, data, len, true); 968 968 } 969 969 970 - static int qcom_smd_trysend(struct rpmsg_endpoint *ept, void *data, int len) 970 + static int qcom_smd_trysend(struct rpmsg_endpoint *ept, const void *data, int len) 971 971 { 972 972 struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); 973 973 974 974 return __qcom_smd_send(qsept->qsch, data, len, false); 975 975 } 976 976 977 - static int qcom_smd_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) 977 + static int qcom_smd_sendto(struct rpmsg_endpoint *ept, const void *data, int len, 978 + u32 dst) 978 979 { 979 980 struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); 980 981 981 982 return __qcom_smd_send(qsept->qsch, data, len, true); 982 983 } 983 984 984 - static int qcom_smd_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) 985 + static int qcom_smd_trysendto(struct rpmsg_endpoint *ept, const void *data, 986 + int len, u32 dst) 985 987 { 986 988 struct qcom_smd_endpoint *qsept = to_smd_endpoint(ept); 987 989
+4 -4
drivers/rpmsg/rpmsg_core.c
··· 153 153 * 154 154 * Return: 0 on success and an appropriate error value on failure. 155 155 */ 156 - int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) 156 + int rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len) 157 157 { 158 158 if (WARN_ON(!ept)) 159 159 return -EINVAL; ··· 182 182 * 183 183 * Return: 0 on success and an appropriate error value on failure. 184 184 */ 185 - int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) 185 + int rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data, int len, u32 dst) 186 186 { 187 187 if (WARN_ON(!ept)) 188 188 return -EINVAL; ··· 210 210 * 211 211 * Return: 0 on success and an appropriate error value on failure. 212 212 */ 213 - int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) 213 + int rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, int len) 214 214 { 215 215 if (WARN_ON(!ept)) 216 216 return -EINVAL; ··· 238 238 * 239 239 * Return: 0 on success and an appropriate error value on failure. 240 240 */ 241 - int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst) 241 + int rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data, int len, u32 dst) 242 242 { 243 243 if (WARN_ON(!ept)) 244 244 return -EINVAL;
+4 -4
drivers/rpmsg/rpmsg_internal.h
··· 63 63 struct rpmsg_endpoint_ops { 64 64 void (*destroy_ept)(struct rpmsg_endpoint *ept); 65 65 66 - int (*send)(struct rpmsg_endpoint *ept, void *data, int len); 67 - int (*sendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); 66 + int (*send)(struct rpmsg_endpoint *ept, const void *data, int len); 67 + int (*sendto)(struct rpmsg_endpoint *ept, const void *data, int len, u32 dst); 68 68 69 - int (*trysend)(struct rpmsg_endpoint *ept, void *data, int len); 70 - int (*trysendto)(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); 69 + int (*trysend)(struct rpmsg_endpoint *ept, const void *data, int len); 70 + int (*trysendto)(struct rpmsg_endpoint *ept, const void *data, int len, u32 dst); 71 71 __poll_t (*poll)(struct rpmsg_endpoint *ept, struct file *filp, 72 72 poll_table *wait); 73 73 int (*set_flow_control)(struct rpmsg_endpoint *ept, bool pause, u32 dst);
+13 -11
drivers/rpmsg/virtio_rpmsg_bus.c
··· 136 136 #define RPMSG_RESERVED_ADDRESSES (1024) 137 137 138 138 static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept); 139 - static int virtio_rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); 140 - static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, 141 - u32 dst); 142 - static int virtio_rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len); 143 - static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, 139 + static int virtio_rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len); 140 + static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data, 141 + int len, u32 dst); 142 + static int virtio_rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, 143 + int len); 144 + static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data, 144 145 int len, u32 dst); 145 146 static __poll_t virtio_rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, 146 147 poll_table *wait); ··· 491 490 */ 492 491 static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, 493 492 u32 src, u32 dst, 494 - void *data, int len, bool wait) 493 + const void *data, int len, bool wait) 495 494 { 496 495 struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); 497 496 struct virtproc_info *vrp = vch->vrp; ··· 581 580 return err; 582 581 } 583 582 584 - static int virtio_rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) 583 + static int virtio_rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len) 585 584 { 586 585 struct rpmsg_device *rpdev = ept->rpdev; 587 586 u32 src = ept->addr, dst = rpdev->dst; ··· 589 588 return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); 590 589 } 591 590 592 - static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, 593 - u32 dst) 591 + static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data, 592 + int len, u32 dst) 594 593 { 595 594 struct rpmsg_device *rpdev = ept->rpdev; 596 595 u32 src = ept->addr; ··· 598 597 return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, true); 599 598 } 600 599 601 - static int virtio_rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) 600 + static int virtio_rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, 601 + int len) 602 602 { 603 603 struct rpmsg_device *rpdev = ept->rpdev; 604 604 u32 src = ept->addr, dst = rpdev->dst; ··· 607 605 return rpmsg_send_offchannel_raw(rpdev, src, dst, data, len, false); 608 606 } 609 607 610 - static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, 608 + static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data, 611 609 int len, u32 dst) 612 610 { 613 611 struct rpmsg_device *rpdev = ept->rpdev;
+9 -8
include/linux/rpmsg.h
··· 182 182 rpmsg_rx_cb_t cb, void *priv, 183 183 struct rpmsg_channel_info chinfo); 184 184 185 - int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); 186 - int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); 185 + int rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len); 186 + int rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data, int len, u32 dst); 187 187 188 - int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len); 189 - int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); 188 + int rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, int len); 189 + int rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data, int len, u32 dst); 190 190 191 191 __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp, 192 192 poll_table *wait); ··· 249 249 return NULL; 250 250 } 251 251 252 - static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len) 252 + static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len) 253 253 { 254 254 /* This shouldn't be possible */ 255 255 WARN_ON(1); ··· 257 257 return -ENXIO; 258 258 } 259 259 260 - static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, 260 + static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data, int len, 261 261 u32 dst) 262 262 { 263 263 /* This shouldn't be possible */ ··· 267 267 268 268 } 269 269 270 - static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len) 270 + static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, 271 + int len) 271 272 { 272 273 /* This shouldn't be possible */ 273 274 WARN_ON(1); ··· 276 275 return -ENXIO; 277 276 } 278 277 279 - static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, 278 + static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data, 280 279 int len, u32 dst) 281 280 { 282 281 /* This shouldn't be possible */