Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2238211ybv; Mon, 24 Feb 2020 01:42:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzGs3lGUxntLw3wttop3UaCFdMSHhGCWSIy9vMDucdqyKS+EmtUZGT/xSdDY56lwczfQ9kn X-Received: by 2002:a9d:638d:: with SMTP id w13mr38344788otk.220.1582537364789; Mon, 24 Feb 2020 01:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582537364; cv=none; d=google.com; s=arc-20160816; b=Ybf4wHMu9dYXUYkfFjWzBLF9snCwrdZMwr2Dm6uJDKcc2bvlV24f3j6xtqvedKhxOl nQiADvYJWPZGEmNd2rCKqt9+9/v7IPlYoDk07202kRjsRfgXbFs9xnJVsuwTiFABSZK6 4ZvEKLML6b+fVQwM1Qci+5ijOMDllbclXBtOyJ/rifbHQZHjHloTjVCgLwNYLaDTCxxV yQlTmzWy0ZTtqb46nehDn+TqdUBVF/V/iHbodljabumHW+eSEg9QNPNy9v5lxAYGC4aK KCDCPvHlGwVXJDK8/OpOmFJ/hMQX0PZUP8nwA7NoLxd/0zYSwJz7ViTtEJEIvwa66F8M imCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kc3RH6cl8PrURMVC2HcOMEqzVbKCqch6ndQPKF/V66A=; b=nrJjuipE6bMryLYDghgjpTSfIT7Hrg+wUZ7rRqSE36dJ9kRuOBuxQu3B1PK7KlbYhZ ZsSpxXmzD6QRodNaS1o/F+9IVnz65eMXLV2NXpwin5f7loGQZJNiFis+zzndFx+BX6n3 QInuoQl7ozZVKEPjOV5jfIbwm81bKL+8h82Eg4Ap5soN0ZGPvA7FimP36EIOV7mdgqzo KNO0BMMjRRzMK7YJDrggF9DU9M6TVs4rn1gXeeeT3CHwztG+eSuK12dkE5uzGPkHrX+/ nwEkkqyv8q1h96gie9pRFv2Qx7kbp7JAsuQfecbilRs3emY6TbppPmVnlo0Wqi24Wuec zpYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=0YBu5nh7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si4503590oic.188.2020.02.24.01.42.33; Mon, 24 Feb 2020 01:42:44 -0800 (PST) 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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=0YBu5nh7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727318AbgBXJmG (ORCPT + 99 others); Mon, 24 Feb 2020 04:42:06 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45489 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727314AbgBXJmF (ORCPT ); Mon, 24 Feb 2020 04:42:05 -0500 Received: by mail-wr1-f67.google.com with SMTP id g3so9497924wrs.12 for ; Mon, 24 Feb 2020 01:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kc3RH6cl8PrURMVC2HcOMEqzVbKCqch6ndQPKF/V66A=; b=0YBu5nh7EwE0owIXSnCrf8JvY5+QrQDh3tlr/FACK7Kk/A5xfIV2CCrb7w7qcZoBJe CGVCX7By6mMfAtyy6KB/llK3WxNoXh8q36XqRmC08YtCHQaEGoPHSFt3yMgETa618fFf hd3zZojj95yUICFQI/GuITP83ur8BC+R+LsOos9rqNTwuslJsZ4g2HvHBCUo/HQlIRdK 6AIDYJNEUIGU4o9IaB42XitaT93J3Tf9qtEHAfI48+HOcxl6gVyw+2QkeRh+vLMtGVVk lxdwKibT8n+BfAduR5BlRGAEzaQ76n+Az+2fKfX+VIg5Sf0tU5IeRtQ5ZfCqQExoxRX1 Msaw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kc3RH6cl8PrURMVC2HcOMEqzVbKCqch6ndQPKF/V66A=; b=PxSj7mADXSOxjCTvL5a+rOUbuPUJ/TOqtJZKgtCGgWXf46Qhccn5KBHZGn0Lbhi0t6 CknpTUii13ckM8piEEB/IxGoq1ufOfbARKD6H62p41PtX1cVqxo5a7qal99vzpz257PD F0s8w01CaeLWL1o3GnhVZwg7K5tMlxa2lLhtIXc6jiEtWCAV4U9Z6WKhL/TMDTBoLmZL 6ZN6H2RUiYJGwNPiShywO5I6NhK87nVG9F9JU0pXeBjj1hxcoOWIjJ6Mz1srTB4+vmiO crQykZin7Y5rICY3PrpuO+PwoMeIg+XPgGJI3DADqvgFy0yzyt/7yQd1SdnvVvS1XAzJ MMsA== X-Gm-Message-State: APjAAAV5zMonrZaDp7CyLphUO6X844o7r7LNWY56y/86Le/7hZd5MWFX G8xgCeM0hMkgIpTdmc4KCaWgDg== X-Received: by 2002:adf:facc:: with SMTP id a12mr37775788wrs.100.1582537323534; Mon, 24 Feb 2020 01:42:03 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id t10sm16920730wmi.40.2020.02.24.01.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 01:42:03 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/3] gpiolib: provide VALIDATE_DESC_PTR() macro Date: Mon, 24 Feb 2020 10:41:56 +0100 Message-Id: <20200224094158.28761-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200224094158.28761-1-brgl@bgdev.pl> References: <20200224094158.28761-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski We're about to add a public GPIO function that takes a descriptor as argument and returns a pointer. Add a corresponding macro wrapping the validate_desc() function that returns an ERR_PTR() on error. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4d0106ceeba7..da8ffd40aa97 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2864,6 +2864,14 @@ static int validate_desc(const struct gpio_desc *desc, const char *func) return; \ } while (0) +#define VALIDATE_DESC_PTR(desc) do { \ + int __valid = validate_desc(desc, __func__); \ + if (__valid < 0) \ + return ERR_PTR(__valid); \ + if (__valid == 0) \ + return NULL; \ + } while (0) + int gpiod_request(struct gpio_desc *desc, const char *label) { int ret = -EPROBE_DEFER; -- 2.25.0