From patchwork Tue May 9 04:56:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9717033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C42C60364 for ; Tue, 9 May 2017 04:56:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D721204BA for ; Tue, 9 May 2017 04:56:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50548282E8; Tue, 9 May 2017 04:56:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 629B1204BA for ; Tue, 9 May 2017 04:56:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752866AbdEIE4L (ORCPT ); Tue, 9 May 2017 00:56:11 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:35619 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751837AbdEIE4L (ORCPT ); Tue, 9 May 2017 00:56:11 -0400 Received: by mail-pg0-f50.google.com with SMTP id o3so46470191pgn.2 for ; Mon, 08 May 2017 21:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=yBS9jt7iepBqaYe5MQSM0TmVIHMo6EskhSbS8ahrAA0=; b=Dpw1+bE+yReqK7/yYMCCHWgbMqFpAEmFNoyyAqAAsbKlfyJXnZCfQQM6BMnIhlp4Ib tQZiM399g2iWI3iYh8KZma+gCx5rJ37B5lL7N4hxKf8mURYuiH9ugCZtNOFGukTGv62Q lK8SBToU6PYFghheL98cdU1mv0nobxWqj4wLQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yBS9jt7iepBqaYe5MQSM0TmVIHMo6EskhSbS8ahrAA0=; b=C7xoyJV0ZQoPsYJAO4m3hPOy8w0NHbSs72ysyI7vG3ClWbf/eGIIZv68gnWwzoY4rl yz3RM0djDS/6a2ZMYiHP+d3XuU/3rWsx4/g6wUoU1dNvlb3WG8gJh3OGSI/NxfYQN6jb 31Uo7xWwasbyoz1tINdLK6A31YnMBluTPc3ilnt26XgO5vdJ8mxVp6jVVDyak12OEJDy O3027mI7R/YhX+ovQxUWEnMMiPtGhwQZWbGuc+mpRyx+wy/VLnsd0mys7rZgEp7HjKws pDdjY4uyjSdL21vfHBb7p6aCsKT4l2noHofm4AgKAZab5WXk7t2n/VkP8JMpjgD4IRLa l55w== X-Gm-Message-State: AN3rC/7bbRYJ2Pzn4q2isBskhuro8lFC2RI1V2xSuc9JohnfpVu8Awhu QyzkkNnMRqNAb58U X-Received: by 10.99.113.78 with SMTP id b14mr22143637pgn.223.1494305770361; Mon, 08 May 2017 21:56:10 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id j191sm619290pgc.53.2017.05.08.21.56.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 21:56:09 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rpmsg: Make rpmsg_create_ept() propagate error Date: Mon, 8 May 2017 21:56:06 -0700 Message-Id: <20170509045606.6064-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,