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: 98870 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1648500qge; Mon, 8 May 2017 21:56:24 -0700 (PDT) X-Received: by 10.99.36.199 with SMTP id k190mr21860144pgk.83.1494305784739; Mon, 08 May 2017 21:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494305784; cv=none; d=google.com; s=arc-20160816; b=QRi46c1lz/3Xzp7sc171veUHqHRgfHnCEeQ6sBsifIu426VsPfFF+ntN9onru1kC9t fXRiThNY7ESl3+Fo7m+K3C1CW/noWmuVGlU2kC7JDDeUvmeMcqQrEAps/lrZ7QkSfCKl yx4VC4EM0GSloB/e8j2ac4ETGhEKByd7X9lDiLrqdydHuhYZyDUSv+e5d5N9WH6F59DR ERe+Yuu+TTFR9RyNGmGRSeorTlO4fl3bbs/uQhlTUbJBRubjiFfT7QN+y2zwWw8JEoPg fbAvbxPc9qMjpEuXeCTL7uP/ezx0r5Hs5me+zvTcSVp5Lybt2xjE51St23ME4xrCLixE LXiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yBS9jt7iepBqaYe5MQSM0TmVIHMo6EskhSbS8ahrAA0=; b=j3t+nlQKgWFS9zdD7obrw9aOufXh044K6LJKMXu5eu4fd/bB+N0zrJk328vmv159I5 Pa+3GXzQiJCrFMA23dQ75AoTPCT9HdwA2BfBzGKqWeY/hifGlK04n2tfSrfBNbXdwpbs KlXwirq0oWR8+0fa8s3x58p0dAv/3PxwXM2AUROmGEjy3YY49UD/LoR1ApLojL9a0boz vZxdn9Tt+b3N8xboiCACqlfGz7qPw6BS2gQWK62LUy9HQ4p+d6snCpnpaIm44BHzBZWG 8UvxIbtKb/HYs1vVnxoKMIU1B3nA9zcV33DR5ajb3csVL5YvKTrSdn5R1ggs/nMxBadg yM3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p190si15391682pfb.151.2017.05.08.21.56.24; Mon, 08 May 2017 21:56:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753868AbdEIE4N (ORCPT + 25 others); Tue, 9 May 2017 00:56:13 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:34422 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752800AbdEIE4L (ORCPT ); Tue, 9 May 2017 00:56:11 -0400 Received: by mail-pg0-f54.google.com with SMTP id u28so34089530pgn.1 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=d+kdIkOyoykk+8WWTLpC2/TavaaPclGQxCpQWU3dCKBMBT9cI42qEuLR0bDy1eCOFx Dz8ddCpjWE8/EMc27xD0CjaKov6h0r4ZpicX7ZLxeOlaURYIlnL+xtbf/DEuqHeZWMHi bJ+pYJsuqSBiQOzLbIYXaPrU0HJ3dmwFkwBNJPw0vyYMFoe3hnb7Fela+u7YaqPuI4Fo gXRjCPgMNmt0UNTrdzKDIBP28gaJs6lq5NEsqnIz+4ScVev3PPpJiCp15+hp6/Zv9I13 RMogDQm0d9IY1+wJXaxxUz2IJbaA4NTFWwmRR5KkjJztdBTByxeP8bI9FcxSbtudAgHE mTUw== X-Gm-Message-State: AN3rC/618IGPunl5u3GC/wmrSGV0C+SJpZqzlGJN8VjUDLtaTlxmdnAz VHzjNEbtgpDXB1jorOjM9A== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.12.0 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,