rpmsg updates for v4.10
Argument validation in public functions, function stubs for COMPILE_TEST-ing clients, preparation for exposing rpmsg endponts to user space and minor Qualcomm SMD fixes. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJYTz1VAAoJEAsfOT8Nma3FhPEP/RtU0W3x/rkjLzEECJBTyEDF DUXnl8et2mi9mGaRN4FZ/1lgUXl2P0D/MlS6hnH/ScZEH6NNioS1t5lit0SSpcHq oqM9i6gUYYRJbW6m3a4OECpX+hZ1R/en1B5AAJ9Hu+jNr8ZB2/pcafCfaH651v32 0tUng7rNa0icdm1lc7FGDHw/P0NYFmPkQmG8L/eExOafSLL/P2G+SyMMamBNlKZc iZzZ6Vww7Le4mMst61hM9GSRlxslm/AeP8dPQYhV+7pLCXztKAAsUQJX74GynBLe /pewePo+ZNlip//Okyodjz2iPkn3Yt6WFIHhVLuhlxDRZr/TOmqXsk2jBlS4oChh mBkHk42OybywJp+wWWIPplfZQ5sJYBd1kNOGLX7f6aC9ngSK3u3PfKVFqFxB1Wrn 2Nuis2or+5fv84fIZcAAuyvm72BUrikLUjiKu0d7dCnR3B2/2voPAu8Lhb4AgVH6 qchqfX7LH5fdnBGkFIpIujQ2SjOGT+5zT+72IlPdqkCEHUy4eukUAC7WqMzCiDwO i0IPREkddYX+6yhWrIRIX08u/sQ/r/VldpatSuuTlLsMWdBVRhZH4K8e2KBgtimB 0JkJPb/1sde1NH31k4V+WsJ4vp0FEj0MUbeHkyhWiC6DwH1GaG/KETX5oy9zhj6n gTb8+gZvk1IaJPaDvUqe =yDjM -----END PGP SIGNATURE----- Merge tag 'rpmsg-v4.10' of git://github.com/andersson/remoteproc Pull rpmsg updates from Bjorn Andersson: "Argument validation in public functions, function stubs for COMPILE_TEST-ing clients, preparation for exposing rpmsg endponts to user space and minor Qualcomm SMD fixes" * tag 'rpmsg-v4.10' of git://github.com/andersson/remoteproc: dt-binding: soc: qcom: smd: Add label property rpmsg: qcom_smd: Correct return value for O_NONBLOCK rpmsg: Provide function stubs for API rpmsg: Handle invalid parameters in public API rpmsg: Support drivers without primary endpoint rpmsg: Introduce a driver override mechanism rpmsg: smd: Reduce restrictions when finding channel
This commit is contained in:
commit
961288108e
3 changed files with 178 additions and 38 deletions
|
@ -740,7 +740,7 @@ static int __qcom_smd_send(struct qcom_smd_channel *channel, const void *data,
|
|||
|
||||
while (qcom_smd_get_tx_avail(channel) < tlen) {
|
||||
if (!wait) {
|
||||
ret = -ENOMEM;
|
||||
ret = -EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -821,20 +821,13 @@ qcom_smd_find_channel(struct qcom_smd_edge *edge, const char *name)
|
|||
struct qcom_smd_channel *channel;
|
||||
struct qcom_smd_channel *ret = NULL;
|
||||
unsigned long flags;
|
||||
unsigned state;
|
||||
|
||||
spin_lock_irqsave(&edge->channels_lock, flags);
|
||||
list_for_each_entry(channel, &edge->channels, list) {
|
||||
if (strcmp(channel->name, name))
|
||||
continue;
|
||||
|
||||
state = GET_RX_CHANNEL_INFO(channel, state);
|
||||
if (state != SMD_CHANNEL_OPENING &&
|
||||
state != SMD_CHANNEL_OPENED)
|
||||
continue;
|
||||
|
||||
ret = channel;
|
||||
break;
|
||||
if (!strcmp(channel->name, name)) {
|
||||
ret = channel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&edge->channels_lock, flags);
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev,
|
|||
rpmsg_rx_cb_t cb, void *priv,
|
||||
struct rpmsg_channel_info chinfo)
|
||||
{
|
||||
if (WARN_ON(!rpdev))
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
return rpdev->ops->create_ept(rpdev, cb, priv, chinfo);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_create_ept);
|
||||
|
@ -80,11 +83,13 @@ EXPORT_SYMBOL(rpmsg_create_ept);
|
|||
* @ept: endpoing to destroy
|
||||
*
|
||||
* Should be used by drivers to destroy an rpmsg endpoint previously
|
||||
* created with rpmsg_create_ept().
|
||||
* created with rpmsg_create_ept(). As with other types of "free" NULL
|
||||
* is a valid parameter.
|
||||
*/
|
||||
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
ept->ops->destroy_ept(ept);
|
||||
if (ept)
|
||||
ept->ops->destroy_ept(ept);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_destroy_ept);
|
||||
|
||||
|
@ -108,6 +113,11 @@ EXPORT_SYMBOL(rpmsg_destroy_ept);
|
|||
*/
|
||||
int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
|
||||
{
|
||||
if (WARN_ON(!ept))
|
||||
return -EINVAL;
|
||||
if (!ept->ops->send)
|
||||
return -ENXIO;
|
||||
|
||||
return ept->ops->send(ept, data, len);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_send);
|
||||
|
@ -132,6 +142,11 @@ EXPORT_SYMBOL(rpmsg_send);
|
|||
*/
|
||||
int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst)
|
||||
{
|
||||
if (WARN_ON(!ept))
|
||||
return -EINVAL;
|
||||
if (!ept->ops->sendto)
|
||||
return -ENXIO;
|
||||
|
||||
return ept->ops->sendto(ept, data, len, dst);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_sendto);
|
||||
|
@ -159,6 +174,11 @@ EXPORT_SYMBOL(rpmsg_sendto);
|
|||
int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
|
||||
void *data, int len)
|
||||
{
|
||||
if (WARN_ON(!ept))
|
||||
return -EINVAL;
|
||||
if (!ept->ops->send_offchannel)
|
||||
return -ENXIO;
|
||||
|
||||
return ept->ops->send_offchannel(ept, src, dst, data, len);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_send_offchannel);
|
||||
|
@ -182,6 +202,11 @@ EXPORT_SYMBOL(rpmsg_send_offchannel);
|
|||
*/
|
||||
int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len)
|
||||
{
|
||||
if (WARN_ON(!ept))
|
||||
return -EINVAL;
|
||||
if (!ept->ops->trysend)
|
||||
return -ENXIO;
|
||||
|
||||
return ept->ops->trysend(ept, data, len);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_trysend);
|
||||
|
@ -205,6 +230,11 @@ EXPORT_SYMBOL(rpmsg_trysend);
|
|||
*/
|
||||
int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst)
|
||||
{
|
||||
if (WARN_ON(!ept))
|
||||
return -EINVAL;
|
||||
if (!ept->ops->trysendto)
|
||||
return -ENXIO;
|
||||
|
||||
return ept->ops->trysendto(ept, data, len, dst);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_trysendto);
|
||||
|
@ -231,6 +261,11 @@ EXPORT_SYMBOL(rpmsg_trysendto);
|
|||
int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
|
||||
void *data, int len)
|
||||
{
|
||||
if (WARN_ON(!ept))
|
||||
return -EINVAL;
|
||||
if (!ept->ops->trysend_offchannel)
|
||||
return -ENXIO;
|
||||
|
||||
return ept->ops->trysend_offchannel(ept, src, dst, data, len);
|
||||
}
|
||||
EXPORT_SYMBOL(rpmsg_trysend_offchannel);
|
||||
|
@ -315,6 +350,9 @@ static int rpmsg_dev_match(struct device *dev, struct device_driver *drv)
|
|||
const struct rpmsg_device_id *ids = rpdrv->id_table;
|
||||
unsigned int i;
|
||||
|
||||
if (rpdev->driver_override)
|
||||
return !strcmp(rpdev->driver_override, drv->name);
|
||||
|
||||
if (ids)
|
||||
for (i = 0; ids[i].name[0]; i++)
|
||||
if (rpmsg_id_match(rpdev, &ids[i]))
|
||||
|
@ -344,27 +382,30 @@ static int rpmsg_dev_probe(struct device *dev)
|
|||
struct rpmsg_device *rpdev = to_rpmsg_device(dev);
|
||||
struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver);
|
||||
struct rpmsg_channel_info chinfo = {};
|
||||
struct rpmsg_endpoint *ept;
|
||||
struct rpmsg_endpoint *ept = NULL;
|
||||
int err;
|
||||
|
||||
strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE);
|
||||
chinfo.src = rpdev->src;
|
||||
chinfo.dst = RPMSG_ADDR_ANY;
|
||||
if (rpdrv->callback) {
|
||||
strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE);
|
||||
chinfo.src = rpdev->src;
|
||||
chinfo.dst = RPMSG_ADDR_ANY;
|
||||
|
||||
ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo);
|
||||
if (!ept) {
|
||||
dev_err(dev, "failed to create endpoint\n");
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo);
|
||||
if (!ept) {
|
||||
dev_err(dev, "failed to create endpoint\n");
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rpdev->ept = ept;
|
||||
rpdev->src = ept->addr;
|
||||
}
|
||||
|
||||
rpdev->ept = ept;
|
||||
rpdev->src = ept->addr;
|
||||
|
||||
err = rpdrv->probe(rpdev);
|
||||
if (err) {
|
||||
dev_err(dev, "%s: failed: %d\n", __func__, err);
|
||||
rpmsg_destroy_ept(ept);
|
||||
if (ept)
|
||||
rpmsg_destroy_ept(ept);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -385,7 +426,8 @@ static int rpmsg_dev_remove(struct device *dev)
|
|||
|
||||
rpdrv->remove(rpdev);
|
||||
|
||||
rpmsg_destroy_ept(rpdev->ept);
|
||||
if (rpdev->ept)
|
||||
rpmsg_destroy_ept(rpdev->ept);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <linux/types.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/mutex.h>
|
||||
|
@ -64,6 +65,7 @@ struct rpmsg_channel_info {
|
|||
* rpmsg_device - device that belong to the rpmsg bus
|
||||
* @dev: the device struct
|
||||
* @id: device id (used to match between rpmsg drivers and devices)
|
||||
* @driver_override: driver name to force a match
|
||||
* @src: local address
|
||||
* @dst: destination address
|
||||
* @ept: the rpmsg endpoint of this channel
|
||||
|
@ -72,6 +74,7 @@ struct rpmsg_channel_info {
|
|||
struct rpmsg_device {
|
||||
struct device dev;
|
||||
struct rpmsg_device_id id;
|
||||
char *driver_override;
|
||||
u32 src;
|
||||
u32 dst;
|
||||
struct rpmsg_endpoint *ept;
|
||||
|
@ -132,6 +135,8 @@ struct rpmsg_driver {
|
|||
int (*callback)(struct rpmsg_device *, void *, int, void *, u32);
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_RPMSG)
|
||||
|
||||
int register_rpmsg_device(struct rpmsg_device *dev);
|
||||
void unregister_rpmsg_device(struct rpmsg_device *dev);
|
||||
int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner);
|
||||
|
@ -141,6 +146,116 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *,
|
|||
rpmsg_rx_cb_t cb, void *priv,
|
||||
struct rpmsg_channel_info chinfo);
|
||||
|
||||
int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len);
|
||||
int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
|
||||
int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
|
||||
void *data, int len);
|
||||
|
||||
int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len);
|
||||
int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
|
||||
int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
|
||||
void *data, int len);
|
||||
|
||||
#else
|
||||
|
||||
static inline int register_rpmsg_device(struct rpmsg_device *dev)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline void unregister_rpmsg_device(struct rpmsg_device *dev)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
}
|
||||
|
||||
static inline int __register_rpmsg_driver(struct rpmsg_driver *drv,
|
||||
struct module *owner)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline void unregister_rpmsg_driver(struct rpmsg_driver *drv)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
}
|
||||
|
||||
static inline void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
}
|
||||
|
||||
static inline struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev,
|
||||
rpmsg_rx_cb_t cb,
|
||||
void *priv,
|
||||
struct rpmsg_channel_info chinfo)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return ERR_PTR(-ENXIO);
|
||||
}
|
||||
|
||||
static inline int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len,
|
||||
u32 dst)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
|
||||
}
|
||||
|
||||
static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src,
|
||||
u32 dst, void *data, int len)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,
|
||||
int len, u32 dst)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src,
|
||||
u32 dst, void *data, int len)
|
||||
{
|
||||
/* This shouldn't be possible */
|
||||
WARN_ON(1);
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#endif /* IS_ENABLED(CONFIG_RPMSG) */
|
||||
|
||||
/* use a macro to avoid include chaining to get THIS_MODULE */
|
||||
#define register_rpmsg_driver(drv) \
|
||||
__register_rpmsg_driver(drv, THIS_MODULE)
|
||||
|
@ -157,14 +272,4 @@ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *,
|
|||
module_driver(__rpmsg_driver, register_rpmsg_driver, \
|
||||
unregister_rpmsg_driver)
|
||||
|
||||
int rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len);
|
||||
int rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
|
||||
int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
|
||||
void *data, int len);
|
||||
|
||||
int rpmsg_trysend(struct rpmsg_endpoint *ept, void *data, int len);
|
||||
int rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst);
|
||||
int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
|
||||
void *data, int len);
|
||||
|
||||
#endif /* _LINUX_RPMSG_H */
|
||||
|
|
Loading…
Reference in a new issue