* [PATCH] rpmsg: Make rpmsg_create_ept() propagate error
@ 2017-05-09 4:56 Bjorn Andersson
2017-05-09 8:47 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Andersson @ 2017-05-09 4:56 UTC (permalink / raw)
To: Ohad Ben-Cohen, Bjorn Andersson; +Cc: linux-remoteproc, linux-kernel
Make the rpmsg_create_ept() return an ERR_PTR() rather than NULL, as
this is common practice throughout the kernel and I got the first two
clients of this API wrong.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
drivers/rpmsg/qcom_smd.c | 8 ++++----
drivers/rpmsg/rpmsg_char.c | 4 ++--
drivers/rpmsg/rpmsg_core.c | 6 +++---
drivers/rpmsg/virtio_rpmsg_bus.c | 4 ++--
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
index a0a39a8821a3..cbc20ebba0a3 100644
--- a/drivers/rpmsg/qcom_smd.c
+++ b/drivers/rpmsg/qcom_smd.c
@@ -860,16 +860,16 @@ static struct rpmsg_endpoint *qcom_smd_create_ept(struct rpmsg_device *rpdev,
(channel = qcom_smd_find_channel(edge, name)) != NULL,
HZ);
if (!ret)
- return NULL;
+ return ERR_PTR(-ETIMEDOUT);
if (channel->state != SMD_CHANNEL_CLOSED) {
dev_err(&rpdev->dev, "channel %s is busy\n", channel->name);
- return NULL;
+ return ERR_PTR(-EBUSY);
}
qsept = kzalloc(sizeof(*qsept), GFP_KERNEL);
if (!qsept)
- return NULL;
+ return ERR_PTR(-ENOMEM);
ept = &qsept->ept;
@@ -892,7 +892,7 @@ static struct rpmsg_endpoint *qcom_smd_create_ept(struct rpmsg_device *rpdev,
free_ept:
channel->qsept = NULL;
kref_put(&ept->refcount, __ept_release);
- return NULL;
+ return ERR_PTR(ret);
}
static void qcom_smd_destroy_ept(struct rpmsg_endpoint *ept)
diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index 0ca2ccc09ca6..35918866d3fa 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -138,10 +138,10 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)
get_device(dev);
ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo);
- if (!ept) {
+ if (IS_ERR(ept)) {
dev_err(dev, "failed to open %s\n", eptdev->chinfo.name);
put_device(dev);
- return -EINVAL;
+ return PTR_ERR(ept);
}
eptdev->ept = ept;
diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index 600f5f9f7431..91dc76f250fa 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -65,7 +65,7 @@
* dynamically assign them an available rpmsg address (drivers should have
* a very good reason why not to always use RPMSG_ADDR_ANY here).
*
- * Returns a pointer to the endpoint on success, or NULL on error.
+ * Returns a pointer to the endpoint on success, or ERR_PTR() on error.
*/
struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev,
rpmsg_rx_cb_t cb, void *priv,
@@ -411,9 +411,9 @@ static int rpmsg_dev_probe(struct device *dev)
chinfo.dst = RPMSG_ADDR_ANY;
ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo);
- if (!ept) {
+ if (IS_ERR(ept)) {
dev_err(dev, "failed to create endpoint\n");
- err = -ENOMEM;
+ err = PTR_ERR(ept);
goto out;
}
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 4848da89431f..7fd49ed4847a 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -224,7 +224,7 @@ static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,
ept = kzalloc(sizeof(*ept), GFP_KERNEL);
if (!ept)
- return NULL;
+ return PTR_ERR(-ENOMEM);
kref_init(&ept->refcount);
mutex_init(&ept->cb_lock);
@@ -260,7 +260,7 @@ static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,
free_ept:
mutex_unlock(&vrp->endpoints_lock);
kref_put(&ept->refcount, __ept_release);
- return NULL;
+ return ERR_PTR(id);
}
static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev,
--
2.12.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rpmsg: Make rpmsg_create_ept() propagate error
2017-05-09 4:56 [PATCH] rpmsg: Make rpmsg_create_ept() propagate error Bjorn Andersson
@ 2017-05-09 8:47 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2017-05-09 8:47 UTC (permalink / raw)
To: Bjorn Andersson
Cc: kbuild-all, Ohad Ben-Cohen, Bjorn Andersson, linux-remoteproc,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3076 bytes --]
Hi Bjorn,
[auto build test WARNING on next-20170505]
[also build test WARNING on v4.11]
[cannot apply to v4.9-rc8 v4.9-rc7 v4.9-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Bjorn-Andersson/rpmsg-Make-rpmsg_create_ept-propagate-error/20170509-135640
config: arm-multi_v7_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All warnings (new ones prefixed by >>):
drivers/rpmsg/virtio_rpmsg_bus.c:227:31: sparse: incorrect type in return expression (different base types)
drivers/rpmsg/virtio_rpmsg_bus.c:227:31: expected struct rpmsg_endpoint *
drivers/rpmsg/virtio_rpmsg_bus.c:227:31: got long
drivers/rpmsg/virtio_rpmsg_bus.c: In function '__rpmsg_create_ept':
>> drivers/rpmsg/virtio_rpmsg_bus.c:227:18: warning: passing argument 1 of 'PTR_ERR' makes pointer from integer without a cast [-Wint-conversion]
return PTR_ERR(-ENOMEM);
^
In file included from include/linux/rwsem.h:17:0,
from include/linux/notifier.h:14,
from include/linux/memory_hotplug.h:6,
from include/linux/mmzone.h:757,
from include/linux/gfp.h:5,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from drivers/rpmsg/virtio_rpmsg_bus.c:23:
include/linux/err.h:28:33: note: expected 'const void *' but argument is of type 'int'
static inline long __must_check PTR_ERR(__force const void *ptr)
^~~~~~~
>> drivers/rpmsg/virtio_rpmsg_bus.c:227:10: warning: return makes pointer from integer without a cast [-Wint-conversion]
return PTR_ERR(-ENOMEM);
^~~~~~~~~~~~~~~~
vim +/PTR_ERR +227 drivers/rpmsg/virtio_rpmsg_bus.c
211 */
212 kfree(ept);
213 }
214
215 /* for more info, see below documentation of rpmsg_create_ept() */
216 static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp,
217 struct rpmsg_device *rpdev,
218 rpmsg_rx_cb_t cb,
219 void *priv, u32 addr)
220 {
221 int id_min, id_max, id;
222 struct rpmsg_endpoint *ept;
223 struct device *dev = rpdev ? &rpdev->dev : &vrp->vdev->dev;
224
225 ept = kzalloc(sizeof(*ept), GFP_KERNEL);
226 if (!ept)
> 227 return PTR_ERR(-ENOMEM);
228
229 kref_init(&ept->refcount);
230 mutex_init(&ept->cb_lock);
231
232 ept->rpdev = rpdev;
233 ept->cb = cb;
234 ept->priv = priv;
235 ept->ops = &virtio_endpoint_ops;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41290 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-09 8:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 4:56 [PATCH] rpmsg: Make rpmsg_create_ept() propagate error Bjorn Andersson
2017-05-09 8:47 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).