Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3022835lqt; Tue, 23 Apr 2024 08:22:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWeg6xRyr4l7EszSVc0y4q4aOVMmY+yLJTv78Cr+a8sEv4omxZ0DlYh+ACc78UODCjc0yFtUykfObhHxrdmV2UW2HFi5rckQs7tJXaGw== X-Google-Smtp-Source: AGHT+IETmmpXhepwtLkl6QgQnR8Yin89rBinZ4uBHqJoB+vfAhn/NkD2Xw6yYrzz15n/7d2eK9xD X-Received: by 2002:a05:622a:6113:b0:439:df7e:3056 with SMTP id hg19-20020a05622a611300b00439df7e3056mr3648030qtb.39.1713885729909; Tue, 23 Apr 2024 08:22:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713885729; cv=pass; d=google.com; s=arc-20160816; b=iY2tirrA4+oO7dQB4ZsZFnQGTpSPt5VFfUfFp7klE8aYBy1mEfbpRXrGwyGlWxi8fp 1/8lrkzUKsyXH2/X78BSX8jWgGc0mU/GZTrPUjEpO6a5LvsdmcI4b3i26h975WSKIqvD T+WCH7GZjTAEEtuDhS/bXgVu3aLzsbj4ssjNRxMQmBoHX55O9kSqhE+TpexD/mNxlrii en8lA2GMGgX/oQbqxAfcWcma70FEee8D0a8LxE0GodG6I4jHFdEicPScIVufL+Khj6AV nFKjA/VypxBLJga8faI7fEHFf0Yir8ok7U7ueOrPUfhwhyFrQu/i1+b6KGaAlB1L3vA0 PArg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=3t58kPzp6Yk+avBVMyEmjzyKy1oSGCkMsvWTeDxdJvU=; fh=F82a/p37ip/RyyG/OvLoCn/VlIJp7zDJTCoc95ptkH8=; b=yOX4q+n4bksKu3Lk5vN+te/xM+M1T2mZLZQyMfz7CzdcaYhjgfeAzpXDTl8L3CdTV/ Uc0UK4w3jd/sfRxM9yvQmNbwV3lez440l+AnlcZvgSxtgJXwMB4wFmI9I+voS42n6FUc 403MJnRE9RDutxDw0Gm76Ep5kzgvKw6fMVJw34404ZQsNK0vv7JmGBHq+DBSbHWGZ7jE mAg6iNlsiXPMS/mmjoc4kGcZ0W0d08oWbVJuzcc1Ya9W/5r8aIOccKNaa+ufpfMnJVOZ 9uGunQ3scf5iO4Nxu1dpzClpwpB4VobUembOcQWYBncLIy70hw7HQ8a4YklwypU1EGxQ ebSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r67htizY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d10-20020ac85d8a000000b0043670f48cfesi12947570qtx.398.2024.04.23.08.22.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 08:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r67htizY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-155463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6E5C01C22331 for ; Tue, 23 Apr 2024 15:21:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92F6B13D2AD; Tue, 23 Apr 2024 15:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r67htizY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5B6A13C66C; Tue, 23 Apr 2024 15:20:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713885643; cv=none; b=Tb9/3V+v1xWEeyW8Ra1gtBIpYJoP9z/8vPGDoYIEe2hUZUQU4/U5hCm25Yv0ay6YZ0uNdQGrWMtrsWbaZvtTU8sTf7pSmtvq08Xf8voaKjQAGsRcxOoScA6E+A7PMlxs3sNULbry8WYmpi/e9hJXYxBeAn/xK3Mw7+UDSxYPvj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713885643; c=relaxed/simple; bh=apXmCZAAlTcv2d9FtqBi2n0toEmnnPvQSjQR+DLhq50=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L7eMw/zQhcMTqMlZttu8jBGGAYksryIymqK/39d8j0upwBcKPZ8kbXTS6Q4hX8m1ay2ZPbZIf04QoJ1jWtOubRgaCR8BpapL/iujR+AYTqKUcCk1/0vGLszonjV65vpqxjD4692kWtSjc+XcLtYhy+Y9VrYoVzCTHbyWRXBWt40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r67htizY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 40F41C2BD10; Tue, 23 Apr 2024 15:20:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713885643; bh=apXmCZAAlTcv2d9FtqBi2n0toEmnnPvQSjQR+DLhq50=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=r67htizYN/x7WAEHKNnhnuua7N+q/qXlye9hLVC+cItyv+pb6gU/aRy9I1GgtljvV Tnbm9umHVqqBel4x6M6kuwveJIO0GYthsb3vMKLiil80NuEALD/Npo9oaIZTC2JmxH Rgp+GKMS5ZI73KLDMw0a08/jsK/XLD2T0cbDPnC9pNQJUexgZ6UUTYBQmDRSNscPSM IQHzJg+wPCuvk+OgvuUk2noLVL4eU53zn/1q6y/kwCKbh10qzOLUBarXXSAfRjG96o sxEVZ1OwTtkrR6bR7XPi3qmC134bohzvz7jOZCQU+iE3n7E1awPsGY6a/5F8KSQhe/ fq9xl0JT1Dijw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F50FC19F4E; Tue, 23 Apr 2024 15:20:43 +0000 (UTC) From: Nuno Sa via B4 Relay Date: Tue, 23 Apr 2024 17:20:30 +0200 Subject: [PATCH v2 1/4] dev_printk: add new dev_err_probe() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240423-dev-add_dev_errp_probe-v2-1-12f43c5d8b0d@analog.com> References: <20240423-dev-add_dev_errp_probe-v2-0-12f43c5d8b0d@analog.com> In-Reply-To: <20240423-dev-add_dev_errp_probe-v2-0-12f43c5d8b0d@analog.com> To: Petr Mladek , Andy Shevchenko , Chris Down , John Ogness , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Olivier Moysan , Andi Shyti , Jyoti Bhayana Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Nuno Sa X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713885641; l=1170; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=9vRT1yB7cKMgARCNN9R6YoimX7EiL0EJICliqmirgVI=; b=/OQCs5rmT3dEQ4zj8HcAF6Mlps+bwWIA1WQPIkd72RdXPAjuUXauUJKqTqgJjsdsztQe/iaVU QYcWYv80Ea1BvQ0hoiG+TYe08uVVpiyrbj5RnudcUx5EiejSrl/viaE X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-Endpoint-Received: by B4 Relay for nuno.sa@analog.com/20231116 with auth_id=100 X-Original-From: Nuno Sa Reply-To: nuno.sa@analog.com From: Nuno Sa This is similar to dev_err_probe() but for cases where an ERR_PTR() or ERR_CAST() is to be returned simplifying patterns like: dev_err_probe(dev, ret, ...); return ERR_PTR(ret) or dev_err_probe(dev, PTR_ERR(ptr), ...); return ERR_CAST(ptr) Signed-off-by: Nuno Sa --- include/linux/dev_printk.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h index ae80a303c216..b9623ec22350 100644 --- a/include/linux/dev_printk.h +++ b/include/linux/dev_printk.h @@ -277,4 +277,13 @@ do { \ __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); +/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */ +#define dev_err_ptr_probe(dev, ___err, fmt, ...) ({ \ + ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__)); \ +}) + +/* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */ +#define dev_err_cast_probe(dev, ___err_ptr, fmt, ...) ({ \ + ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__)); \ +}) #endif /* _DEVICE_PRINTK_H_ */ -- 2.44.0