From patchwork Mon Feb 14 14:32:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 542736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE2D3C433EF for ; Mon, 14 Feb 2022 14:32:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234318AbiBNOcx (ORCPT ); Mon, 14 Feb 2022 09:32:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231570AbiBNOcw (ORCPT ); Mon, 14 Feb 2022 09:32:52 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B4F4AE2A; Mon, 14 Feb 2022 06:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644849164; x=1676385164; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VG/LXZ8qtbLnm0aGyCPiHCWpO4Syl62OgLqN5jIzZ8I=; b=etnRUoSARL/EeeJrmsYguzXpwI/BqO1f175DrJKN75QzDFbHMJGbVIVk nnU9t0eOxwLA+1cDhK8lx0otQ2mTZ7ZrEZwauGkmy98ZwK0Euad+JilSx 5dAJQ4Hzqc2WuHMl9FDwG/2jPySph6rxEpXtvLfEVT0wZadSP/j0roKuP 56fK26NfwNqv4KN1qh2QLZX9guY+mygKpHQu1plZhqkTAOiLWl4EM7zgr Vh8S4L3dMra/Lz9RmPLoYMh1DJ4ZnFF2to40flGC6BLRbriU6uYpDpM9i wCA+y1rgf9eQkh3MzHvLrk0cDTFZ/0ZxiKlgTDiPBKxY1Gk3Qh6Kly4rj w==; X-IronPort-AV: E=McAfee;i="6200,9189,10257"; a="237509741" X-IronPort-AV: E=Sophos;i="5.88,368,1635231600"; d="scan'208";a="237509741" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 06:32:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,368,1635231600"; d="scan'208";a="773072677" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 14 Feb 2022 06:32:41 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 585FD143; Mon, 14 Feb 2022 16:32:57 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Slaby , Javier Martinez Canillas , Geert Uytterhoeven , Andy Shevchenko Subject: [PATCH v1 1/2] driver core: add a wrapper to device probe log helper to return pointer Date: Mon, 14 Feb 2022 16:32:47 +0200 Message-Id: <20220214143248.502-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Sometimes the ->probe() function can be split to the core and actual probe parts. In such cases the core one may return a pointer to the allocated resource, or error pointer in unsuccessful scenario. Allow that kind of core function to use dev_err_probe_ptr(), so the following excerpt ret = bar(...); if (ret) { dev_err_probe(dev, ret, ...); return ERR_PTR(ret); } can be replaced with ret = bar(...); if (ret) return dev_err_probe_ptr(dev, ret, ...); Signed-off-by: Andy Shevchenko --- include/linux/device.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 93459724dcde..8650d3afbe7c 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -982,6 +983,13 @@ void device_links_supplier_sync_state_resume(void); extern __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); +/* As above, but returns error pointer */ +static inline __printf(3, 0) +void *dev_err_probe_ptr(const struct device *dev, int err, const char *fmt, va_list args) +{ + return ERR_PTR(dev_err_probe(dev, err, fmt, args)); +} + /* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV(major,minor) \ MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) From patchwork Mon Feb 14 14:32:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 543259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B002DC433F5 for ; Mon, 14 Feb 2022 14:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355167AbiBNOdJ (ORCPT ); Mon, 14 Feb 2022 09:33:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231570AbiBNOdJ (ORCPT ); Mon, 14 Feb 2022 09:33:09 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E54724A3FC; Mon, 14 Feb 2022 06:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644849182; x=1676385182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0YTJsF71vVRGR3IAd/kstHbIpM3JyQ8idpkTZUwJqpE=; b=M6ulQ1qlHyZ3Gdtb8960AOJzfQEutAnm6hPvk16zvRv5aZbZqKQo7HKV gnnvp4thh25nN41VzJD9jfnSy2GQ/nAm2HFkgT3h3VFkCsnjYbyaZpIOC W7NLYIB7JHkJH2VnFUeIGOO5OZjHPTj+BjgsXkCWrI4tdF3BS85BPHKEA mvLXVoSN7FDduHCLuUhI3FjKqSJR3dfiLY+igtCuDCbVjSqDQWbM5gNiu rFS+ugM3QLOfBE2OvR5qln7XLpV21JjftJrItObXwGuNHxi6RzgYauM8d J5SOJyHGaJ/bwzkRZQFkawjdZYA10uTRF4j/kX8GNrGWZil6z1rQ/bNLC A==; X-IronPort-AV: E=McAfee;i="6200,9189,10257"; a="247695190" X-IronPort-AV: E=Sophos;i="5.88,368,1635231600"; d="scan'208";a="247695190" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 06:32:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,368,1635231600"; d="scan'208";a="543629504" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 14 Feb 2022 06:32:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9F85A30B; Mon, 14 Feb 2022 16:32:58 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Slaby , Javier Martinez Canillas , Geert Uytterhoeven , Andy Shevchenko Subject: [PATCH v1 2/2] serial: sh-sci: Switch to use dev_err_probe_ptr() Date: Mon, 14 Feb 2022 16:32:48 +0200 Message-Id: <20220214143248.502-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214143248.502-1-andriy.shevchenko@linux.intel.com> References: <20220214143248.502-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Instead of return ERR_PTR(dev_err_probe(...)); call return dev_err_probe_ptr(...); Signed-off-by: Andy Shevchenko --- drivers/tty/serial/sh-sci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index b610b27893a8..0fce09c13847 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3199,8 +3199,7 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev, rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); if (IS_ERR(rstc)) - return ERR_PTR(dev_err_probe(&pdev->dev, PTR_ERR(rstc), - "failed to get reset ctrl\n")); + return dev_err_probe_ptr(&pdev->dev, PTR_ERR(rstc), "failed to get reset ctrl\n"); ret = reset_control_deassert(rstc); if (ret) {