Message ID | 20240122030238.29437-3-raag.jadav@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2358773dyb; Sun, 21 Jan 2024 20:14:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IETDb1vfBkrpH86S0NElqIayLnuOtCHqg/iSx7tH31NcA55dnmoQg5yO/sPdB0oFSTJNGzL X-Received: by 2002:a05:6359:494a:b0:176:2f9d:e83 with SMTP id mu10-20020a056359494a00b001762f9d0e83mr2575898rwb.35.1705896874989; Sun, 21 Jan 2024 20:14:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705896874; cv=pass; d=google.com; s=arc-20160816; b=LSNJ8epp2ClkOmNPDqfpbk1Z3NWHHrHjp8Nyz4opD+buRiEmhkGN9lbUElufVz3pZ/ A6BVTWBNStDwM26l5yLF4gKbfzkaEm8JayKVdunfk4hMayqfn7+F8PiJl7oHYxbsqHeQ /8cZDd8YEmowQqw2XLwq06iNh9cU5V6SDGZeRn8nuGlw6PgZLFHU7gzlhJAng98pHQh4 1y2Jq2DhS7kXpBcSggRfiGIBDP+JGv48oNB7O2gkpLKf3qQXHl63Um+k9wOBeT3unJ2j EowuXaWY3/AH0d5OAOlfeMcSyuWAd9IfGD6u9JD97KokbXqPQ05CeLBaTu1KlXBDaClw nInQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xMRbx4FQ9FPFNKS4y33cNbWCtnLHGscbGYm9cp/6uP4=; fh=y/RjPbXBoPouJTPaYxwEImQW6x8GRiLpamQFwed/jf0=; b=XRpwmHIvkIUhtQULcx2dhrdyzT1g5Elvm5o5bDbNGzWqQT7FdF+I++xArstV9WDKyX qD9JOKXVaM0teYeqq4e+4cY4VhBoNXvOOeGBh3uKo2F0fIBHB6icjekwnPCPTVsPSV24 6DnvYd4ZGKoza0m/VWOqwEPq4CqG6bO3takXiWIfxe57oAHCww5V38WEj3sdXROAkTZw 0rKikWtcgVoASyYLZXfVlzsuSDLBmnNrGu2LBijsHkLGTT5gKqfOghrKOoelezxCPPqo Q+ftXhNik9CbH6IWQ/H8zP07pAnNHcFgwOLSQnyCa3llSPirwrUwwUjZyQVMHf0no3Yt yG2g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l3n6ufZI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m20-20020a17090a7f9400b0028e7e0ea35asi7535864pjl.109.2024.01.21.20.14.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 20:14:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l3n6ufZI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32290-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BAD7BB2290B for <ouuuleilei@gmail.com>; Mon, 22 Jan 2024 03:03:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B1D75677; Mon, 22 Jan 2024 03:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l3n6ufZI" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 49867139B; Mon, 22 Jan 2024 03:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892575; cv=none; b=SUxoWODzqaCm8StZOLHU7O4f1XKXExj7PzNuUAMOoOUxF/zFoclYY9CrrYCAelsnI8iw05EtUcaPMDcxl2awE4QtefIa5alhykLn//9TSITqxb9emzN4nlEOiR0Rye1feRGa6khnxS+klQ3ac3TJs0SSyKVvWxeZ/+EwMMVdlso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705892575; c=relaxed/simple; bh=xXgc14YVJHCCXERS4eQXjRO7DnYkSw+VIjrQ5G10S6o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B6aIGh8y3BRuE9qIQJottR8RuW4y2HfnHiy1qGthxEEI4xUpPOSZ8VY+G9DxmYF+AnmSz+BG5vsGOM1XYH0dwl2UifD22Q/+Tn14depvgmQZkpY3pIONA3uX8HKVvnNsCoDY7TtmeYUG8K5BzW6Dja6z50CLXJyMxlYHuFAL67o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=none smtp.mailfrom=ecsmtp.iind.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=l3n6ufZI; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ecsmtp.iind.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705892575; x=1737428575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xXgc14YVJHCCXERS4eQXjRO7DnYkSw+VIjrQ5G10S6o=; b=l3n6ufZIdeWo6updMVGtFHJhY8qibh7qlaUyv+wmdOZmsLewhLIwh4AR fMjTXDm5b9gkNdq5zR8qQvG4hVFqnY69BO7x8vM/0PcyjZL9QvrhqcSD8 yBuvqZmodR0cybDY/iwFMR3auM1qs2tHI51CDIAfM6ChqaiqDL0nHEoSu NBIOjR62P4ALaeBpAW/oMAjosp+WcUutGUownejUVub0bnjjnSEQwgRQB d0QeRtyx+nvMKwco2FsTJLnLmfVGdIrbUms9YspfmWYETx492Eme0XxxE UhKKPeJzDx2iCl0Pga06WuCB1xfalJ6XXRjpUrwo57tNUbwSH5lHIo+Ch Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10960"; a="14607323" X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="14607323" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2024 19:02:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="1085521" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by orviesa003.jf.intel.com with ESMTP; 21 Jan 2024 19:02:42 -0800 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 218854851; Mon, 22 Jan 2024 08:32:41 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 1C4E11600102; Mon, 22 Jan 2024 08:32:41 +0530 (IST) From: Raag Jadav <raag.jadav@intel.com> To: u.kleine-koenig@pengutronix.de, jarkko.nikula@linux.intel.com, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, lakshmi.sowjanya.d@intel.com Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav <raag.jadav@intel.com> Subject: [PATCH v1 2/3] pwm: dwc: simplify error handling Date: Mon, 22 Jan 2024 08:32:37 +0530 Message-Id: <20240122030238.29437-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240122030238.29437-1-raag.jadav@intel.com> References: <20240122030238.29437-1-raag.jadav@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788762521371741744 X-GMAIL-MSGID: 1788762521371741744 |
Series |
DesignWare PWM improvements
|
|
Commit Message
Raag Jadav
Jan. 22, 2024, 3:02 a.m. UTC
Simplify error handling in ->probe() function using dev_err_probe() helper.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/pwm/pwm-dwc.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
Comments
On Mon, Jan 22, 2024 at 08:32:37AM +0530, Raag Jadav wrote: > Simplify error handling in ->probe() function using dev_err_probe() helper. .. > ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); > - if (ret) { > - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > - return ret; > - } > + if (ret) > + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > base = pcim_iomap_table(pci)[0]; > - if (!base) { > - dev_err(dev, "Base address missing\n"); > - return -ENOMEM; > - } > + if (!base) > + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); This check is bogus. Just remove it completely. The pcim_iomap_table() fails IFF pcim_iomap_regions() fails. You have checked the latter already.
Hello, On Sun, Jan 28, 2024 at 04:48:16PM +0200, Andy Shevchenko wrote: > On Mon, Jan 22, 2024 at 08:32:37AM +0530, Raag Jadav wrote: > > Simplify error handling in ->probe() function using dev_err_probe() helper. > > ... > > > ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); > > - if (ret) { > > - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > - return ret; > > - } > > + if (ret) > > + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > > > base = pcim_iomap_table(pci)[0]; > > > - if (!base) { > > - dev_err(dev, "Base address missing\n"); > > - return -ENOMEM; > > - } > > + if (!base) > > + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); > > This check is bogus. Just remove it completely. This would be a separate patch though. IMHO mechanically converting to dev_err_probe() is fine. Best regards Uwe
On Sun, Jan 28, 2024 at 04:48:16PM +0200, Andy Shevchenko wrote: > On Mon, Jan 22, 2024 at 08:32:37AM +0530, Raag Jadav wrote: > > Simplify error handling in ->probe() function using dev_err_probe() helper. > > ... > > > ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); > > - if (ret) { > > - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > - return ret; > > - } > > + if (ret) > > + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > > > base = pcim_iomap_table(pci)[0]; > > > - if (!base) { > > - dev_err(dev, "Base address missing\n"); > > - return -ENOMEM; > > - } > > + if (!base) > > + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); > > This check is bogus. Just remove it completely. > > The pcim_iomap_table() fails IFF pcim_iomap_regions() fails. > You have checked the latter already. I'm no expert on devres but I found a few NULL returns in alloc_dr() call path. In the interest of learning more about iomap, wouldn't we need to handle them (just in some odd case)? Raag
On Sun, Jan 28, 2024 at 05:58:38PM +0100, Uwe Kleine-König wrote: > On Sun, Jan 28, 2024 at 04:48:16PM +0200, Andy Shevchenko wrote: > > On Mon, Jan 22, 2024 at 08:32:37AM +0530, Raag Jadav wrote: > > > Simplify error handling in ->probe() function using dev_err_probe() helper. .. > > > ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); > > > - if (ret) { > > > - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > > - return ret; > > > - } > > > + if (ret) > > > + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > > > > > base = pcim_iomap_table(pci)[0]; > > > > > - if (!base) { > > > - dev_err(dev, "Base address missing\n"); > > > - return -ENOMEM; > > > - } > > > + if (!base) > > > + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); > > > > This check is bogus. Just remove it completely. > > This would be a separate patch though. IMHO mechanically converting to > dev_err_probe() is fine. Sure, that's what I meant. First patch to remove, followed by dev_err_probe() conversion.
On Tue, Jan 30, 2024 at 10:31:02AM +0200, Raag Jadav wrote: > On Sun, Jan 28, 2024 at 04:48:16PM +0200, Andy Shevchenko wrote: > > On Mon, Jan 22, 2024 at 08:32:37AM +0530, Raag Jadav wrote: > > > Simplify error handling in ->probe() function using dev_err_probe() helper. .. > > > ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); > > > - if (ret) { > > > - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > > - return ret; > > > - } > > > + if (ret) > > > + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); > > > > > > base = pcim_iomap_table(pci)[0]; > > > > > - if (!base) { > > > - dev_err(dev, "Base address missing\n"); > > > - return -ENOMEM; > > > - } > > > + if (!base) > > > + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); > > > > This check is bogus. Just remove it completely. > > > > The pcim_iomap_table() fails IFF pcim_iomap_regions() fails. > > You have checked the latter already. > > I'm no expert on devres but I found a few NULL returns in alloc_dr() > call path. In the interest of learning more about iomap, wouldn't we > need to handle them (just in some odd case)? It has nothing to do with devres. The logic is implemented in PCI core.
diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index fd64313cb38d..8f8035b047c1 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -68,24 +68,18 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) int ret; ret = pcim_enable_device(pci); - if (ret) { - dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret)); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret)); pci_set_master(pci); ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci)); - if (ret) { - dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret)); base = pcim_iomap_table(pci)[0]; - if (!base) { - dev_err(dev, "Base address missing\n"); - return -ENOMEM; - } + if (!base) + return dev_err_probe(dev, -ENOMEM, "Base address missing\n"); info = (const struct dwc_pwm_info *)id->driver_data; ret = dwc_pwm_init(dev, info, base);