Message ID | 20240208070529.28562-2-raag.jadav@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-57545-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp20998dyd; Thu, 8 Feb 2024 00:25:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXgiledE4PbQGUsbLfZSeROdYls8e5SfebadBwfGW2GmSjs1dpwI+v5bwL5RBjNH5pyONBiVNK7dgmRieipIQ4Ncdl2xA== X-Google-Smtp-Source: AGHT+IFCdxqlcTTdk93S95YZzKAj3+ZS9NviCFBPDBVd6uTTvrTIZMfItEvHajFVYXvyP9Sz34m9 X-Received: by 2002:a0c:dc14:0:b0:68c:9023:6319 with SMTP id s20-20020a0cdc14000000b0068c90236319mr7518164qvk.22.1707380714832; Thu, 08 Feb 2024 00:25:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707380714; cv=pass; d=google.com; s=arc-20160816; b=Mm4tZ/ndBqwd3/aEz8qbbpHrz5JupKq0KDEL/vBn6RRuE4xbKJT51F3z5Yxq9qUU8a 7fpLiUJyNPbGf+AEiA0sZToZ4GVKuUFgpjZ0i/5NxQDsVkUKPgjUNm+rRKg2P3vOk9wz j2KHqU1EEMFmFsc0xqK5lHDmBH3ZJP8NkhdZqDxPK68NstWt14yyl5YTBqsmohNwMyaf GLeUF6nkMSkkVcezG/JmqSCEzVHe2boEQ8eYFQ+nxz5gQpGzic8Fx4tel3YVY7RJ7I1P KTGP5zPwd1pXS4zs4GZFO/U6WUi2/e6nnQVm+Ctn62QcC1fa8UQlw8z9jsuTpPvlhX7y b38A== 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=M64jCRUSpSUkDmHuB3hCKu28JM276TK0qEswvufKzOI=; fh=jge5rShHg8YqOhb3XT+KSLl5pRl1eGG0uiBeIk0osQE=; b=KtoGlsIbeMeqA0mU3PyjPMtHkHykEx7BTMMgvdc57j1hV12Z7uUj742gXGdPzTcgM7 d9BlLqsqjRLaHzsMmbKqnyNKdZ246mL7D5QSHgrAFMFjMHuXvu7oG4gLJ12H1XqQZ/na gDSUiDEQ1y1vRu1MyNEMtb9FHAirRHyjy+I01aO0XkIzolofWmtOv6LlFU+PnpM/jGSF +poDQpGXR8mgjIqTZd7qerwiUdns0k5hnKcyzo55BwJP6jLDfyXpDsEgT5uPy/ok6Pjy Qx6N31fHYTzSsjOPz+kUN5aNKPrwYeb0CjjPOE1qpcgKEtSQx1gFLgrqv1L7kOClNlH2 t3hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SxjZ4aN+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57545-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57545-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXt1MoUfybq9o1Qin4Jz2YJWYVUXVGuuO3vg3LOAgdfHC79lSbYigHwayF1/oe+CMcwrHWg8bc+3PH71KtOtd8P2aKC5Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u2-20020ad45aa2000000b0068cb7c033d6si3017131qvg.24.2024.02.08.00.25.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 00:25:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57545-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SxjZ4aN+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-57545-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57545-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AC13B1C24DA7 for <ouuuleilei@gmail.com>; Thu, 8 Feb 2024 07:07:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C170D6A8B4; Thu, 8 Feb 2024 07:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SxjZ4aN+" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 BA04869964; Thu, 8 Feb 2024 07:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707375949; cv=none; b=lthHGhk275qum1ymrjGBZT7wwcAuF8C9dIkJ3Vsh8WLcBULBGpxVfJr64ZUFZUgtSSa5K9PhEoN175icvKFxUy+GB9H2j1kPN9nVYFJB/Hvpkkk43SKaFQgFV8sKuyoZlVhcxmT5n0Y5Uf79+IOSBtcyh+AA2LP+9bC0+TCl3uM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707375949; c=relaxed/simple; bh=SLcziUGV3wn1pdz6JlsUPS3h94i8kBpVxgL2aMtWd88=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mxEEiXObbavEq7uL05ltwupftHbV5NPa+RzjhKhZjQ6z/Mq7SByn59GU+zVYyOSOmRWGfcKQ1h/QLTvI24j33Lx8YVk+ShiVPVe2k35OtSKqYwN/D/e7XxRKDv6VwhScOHs+ynZ+J7osIZwuppQ2jwsXG0Rleq9Op0gsVoTACkM= 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=SxjZ4aN+; arc=none smtp.client-ip=198.175.65.12 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=1707375948; x=1738911948; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SLcziUGV3wn1pdz6JlsUPS3h94i8kBpVxgL2aMtWd88=; b=SxjZ4aN+vAVuTrJuTlArZV7DBQaEJwoCymTNU/jQQGya7w9z3UPVnd8I 6A2m1QgLh9NsTxJEAM3quEh0HNCELEG8zCYvZR2hRinVi1Bs00VMKul5s OSzPRkd0OZQywGyZITcF/RDl01PZbpDed7sOrWJJ/1p/NJqK0VJqy5e5g X27ySGCbXyWZPZCH6s765QIdOmKty4fdZksnCIHfkIO/zQsB6UWxQDJhR 1lR/lx0ZaPqG+E7EloRPmdXahuSjkDkMVI0HbbfEyMZ9BawjPRBpXrGxT jRKjJDZOiTn4oW3OZszbPGnUhaOJ8b5XfDPJfTcgc70PVoTaGI7yA6E1L g==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="12525872" X-IronPort-AV: E=Sophos;i="6.05,252,1701158400"; d="scan'208";a="12525872" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2024 23:05:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,252,1701158400"; d="scan'208";a="1573966" Received: from inesxmail01.iind.intel.com ([10.223.57.40]) by fmviesa007.fm.intel.com with ESMTP; 07 Feb 2024 23:05:36 -0800 Received: from inlubt0316.iind.intel.com (inlubt0316.iind.intel.com [10.191.20.213]) by inesxmail01.iind.intel.com (Postfix) with ESMTP id 4E9CB14320; Thu, 8 Feb 2024 12:35:35 +0530 (IST) Received: by inlubt0316.iind.intel.com (Postfix, from userid 12101951) id 4C6131600101; Thu, 8 Feb 2024 12:35:35 +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 v2 1/5] pwm: dwc: drop redundant error check Date: Thu, 8 Feb 2024 12:35:25 +0530 Message-Id: <20240208070529.28562-2-raag.jadav@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240208070529.28562-1-raag.jadav@intel.com> References: <20240208070529.28562-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: 1790316054277920142 X-GMAIL-MSGID: 1790318440095027955 |
Series | DesignWare PWM improvements | |
Commit Message
Raag Jadav
Feb. 8, 2024, 7:05 a.m. UTC
pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to
check for failure if the latter is already successful.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/pwm/pwm-dwc.c | 4 ----
1 file changed, 4 deletions(-)
Comments
On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote: > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote: > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to > > check for failure if the latter is already successful. > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which > might fail if the allocation fails. (Yes, I know > https://lwn.net/Articles/627419/, but the rule is still to check for > errors, right?) We do not add a dead code to the kernel, right? > What am I missing? Mysterious ways of the twisted PCI devres code. Read the above commit message again :-) For your convenience I can elaborate. pcim_iomap_table() calls _first_ devres_find() which _will_ succeed if the pcim_iomap_regions() previously succeeded. Does it help to understand how it designed?
On Thu, Feb 08, 2024 at 07:04:34PM +0200, Andy Shevchenko wrote: > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote: > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote: .. > > (Yes, I know https://lwn.net/Articles/627419/, Btw, it has nothing to do with this case.
Hello Andy, On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote: > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote: > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote: > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to > > > check for failure if the latter is already successful. > > > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which > > might fail if the allocation fails. (Yes, I know > > https://lwn.net/Articles/627419/, but the rule is still to check for > > errors, right?) > > We do not add a dead code to the kernel, right? > > > What am I missing? > > Mysterious ways of the twisted PCI devres code. > Read the above commit message again :-) > > For your convenience I can elaborate. pcim_iomap_table() calls _first_ > devres_find() which _will_ succeed if the pcim_iomap_regions() previously > succeeded. Does it help to understand how it designed? I assume you're saying that after pcim_iomap_regions() succeeded it's already known that pcim_iomap_table() succeeds (because the former already called the latter). I'm still concerned here. I agree that error checking might be skipped if it's clear that no error can happen (the device cannot disappear between these two calls, can it?), but for me as an uninitiated pci code reader, I wonder about dwc->base = pcim_iomap_table(pci)[0]; without error checking. (OTOH, if pcim_iomap_table() returned NULL, the "[0]" part is already problematic.) I'd like to have a code comment here saying that pcim_iomap_table() won't return NULL. Best regards Uwe
On Wed, Feb 14, 2024 at 06:45:48PM +0100, Uwe Kleine-König wrote: > On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote: > > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote: > > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote: > > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to > > > > check for failure if the latter is already successful. > > > > > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which > > > might fail if the allocation fails. (Yes, I know > > > https://lwn.net/Articles/627419/, but the rule is still to check for > > > errors, right?) > > > > We do not add a dead code to the kernel, right? > > > > > What am I missing? > > > > Mysterious ways of the twisted PCI devres code. > > Read the above commit message again :-) > > > > For your convenience I can elaborate. pcim_iomap_table() calls _first_ > > devres_find() which _will_ succeed if the pcim_iomap_regions() previously > > succeeded. Does it help to understand how it designed? > > I assume you're saying that after pcim_iomap_regions() succeeded it's > already known that pcim_iomap_table() succeeds (because the former > already called the latter). > > I'm still concerned here. I agree that error checking might be skipped > if it's clear that no error can happen (the device cannot disappear > between these two calls, can it?), It depends. If you call it in some asynchronous callbacks which may be run after PCI device disappears, then indeed, it's problematic. But you probably will have much bigger issue at that point already. In ->probe() it's guaranteed to work as I suggested (assuming properly working hardware). > but for me as an uninitiated pci code > reader, I wonder about > > dwc->base = pcim_iomap_table(pci)[0]; > > without error checking. (OTOH, if pcim_iomap_table() returned NULL, the > "[0]" part is already problematic.) Seems it's your problem, many drivers use the way I suggested. > I'd like to have a code comment here saying that pcim_iomap_table() > won't return NULL. Why? It's redundant. If you use it, you should know this API. So, the bottom line, does this API needs better documentation?
On Wed, Feb 14, 2024 at 07:54:58PM +0200, Andy Shevchenko wrote: > On Wed, Feb 14, 2024 at 06:45:48PM +0100, Uwe Kleine-König wrote: > > On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote: > > > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote: > > > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote: > > > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to > > > > > check for failure if the latter is already successful. > > > > > > > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which > > > > might fail if the allocation fails. (Yes, I know > > > > https://lwn.net/Articles/627419/, but the rule is still to check for > > > > errors, right?) > > > > > > We do not add a dead code to the kernel, right? > > > > > > > What am I missing? > > > > > > Mysterious ways of the twisted PCI devres code. > > > Read the above commit message again :-) > > > > > > For your convenience I can elaborate. pcim_iomap_table() calls _first_ > > > devres_find() which _will_ succeed if the pcim_iomap_regions() previously > > > succeeded. Does it help to understand how it designed? > > > > I assume you're saying that after pcim_iomap_regions() succeeded it's > > already known that pcim_iomap_table() succeeds (because the former > > already called the latter). > > > > I'm still concerned here. I agree that error checking might be skipped > > if it's clear that no error can happen (the device cannot disappear > > between these two calls, can it?), > > It depends. If you call it in some asynchronous callbacks which may be run > after PCI device disappears, then indeed, it's problematic. But you probably > will have much bigger issue at that point already. > > In ->probe() it's guaranteed to work as I suggested (assuming properly working > hardware). Assuming properly working hardware allows to drop many error checks :-) > > but for me as an uninitiated pci code > > reader, I wonder about > > > > dwc->base = pcim_iomap_table(pci)[0]; > > > > without error checking. (OTOH, if pcim_iomap_table() returned NULL, the > > "[0]" part is already problematic.) > > Seems it's your problem, many drivers use the way I suggested. > > > I'd like to have a code comment here saying that pcim_iomap_table() > > won't return NULL. > > Why? It's redundant. If you use it, you should know this API. > So, the bottom line, does this API needs better documentation? If a driver author knows it while writing the code, it's obvious. But if the driver author looks again in 2 years or someone else (e.g. me with the PWM maintainer hat on and with little pci experience) that knowledge might be faded. Best regards Uwe
On Thu, Feb 15, 2024 at 10:22:57AM +0100, Uwe Kleine-König wrote: > On Wed, Feb 14, 2024 at 07:54:58PM +0200, Andy Shevchenko wrote: > > On Wed, Feb 14, 2024 at 06:45:48PM +0100, Uwe Kleine-König wrote: > > > On Thu, Feb 08, 2024 at 07:04:33PM +0200, Andy Shevchenko wrote: > > > > On Thu, Feb 08, 2024 at 08:46:44AM +0100, Uwe Kleine-König wrote: > > > > > On Thu, Feb 08, 2024 at 12:35:25PM +0530, Raag Jadav wrote: > > > > > > pcim_iomap_table() fails only if pcim_iomap_regions() fails. No need to > > > > > > check for failure if the latter is already successful. > > > > > > > > > > Is this really true? pcim_iomap_table() calls devres_alloc_node() which > > > > > might fail if the allocation fails. (Yes, I know > > > > > https://lwn.net/Articles/627419/, but the rule is still to check for > > > > > errors, right?) > > > > > > > > We do not add a dead code to the kernel, right? > > > > > > > > > What am I missing? > > > > > > > > Mysterious ways of the twisted PCI devres code. > > > > Read the above commit message again :-) > > > > > > > > For your convenience I can elaborate. pcim_iomap_table() calls _first_ > > > > devres_find() which _will_ succeed if the pcim_iomap_regions() previously > > > > succeeded. Does it help to understand how it designed? > > > > > > I assume you're saying that after pcim_iomap_regions() succeeded it's > > > already known that pcim_iomap_table() succeeds (because the former > > > already called the latter). > > > > > > I'm still concerned here. I agree that error checking might be skipped > > > if it's clear that no error can happen (the device cannot disappear > > > between these two calls, can it?), > > > > It depends. If you call it in some asynchronous callbacks which may be run > > after PCI device disappears, then indeed, it's problematic. But you probably > > will have much bigger issue at that point already. > > > > In ->probe() it's guaranteed to work as I suggested (assuming properly working > > hardware). > > Assuming properly working hardware allows to drop many error checks :-) Yes, and we have some checks are being not implemented ("dropped"), but here is the thing: this is a PCI device and surprise removal (while it's not possible for the on-die devices) should be handled differently, not related to this code anyway. Malicious hardware is out of scope either. > > > but for me as an uninitiated pci code > > > reader, I wonder about > > > > > > dwc->base = pcim_iomap_table(pci)[0]; > > > > > > without error checking. (OTOH, if pcim_iomap_table() returned NULL, the > > > "[0]" part is already problematic.) > > > > Seems it's your problem, many drivers use the way I suggested. > > > > > I'd like to have a code comment here saying that pcim_iomap_table() > > > won't return NULL. > > > > Why? It's redundant. If you use it, you should know this API. > > So, the bottom line, does this API needs better documentation? > > If a driver author knows it while writing the code, it's obvious. But if > the driver author looks again in 2 years or someone else (e.g. me with > the PWM maintainer hat on and with little pci experience) that knowledge > might be faded. This is widely used pattern. Anybody who works with Git should know how to use `git grep` tool. If in doubts, always can ask in the mailing lists. I still consider it redundant. P.S. That's what you call "bikeshedding" (done by yourself here)?
Hello Andy, On Thu, Feb 15, 2024 at 03:36:12PM +0200, Andy Shevchenko wrote: > On Thu, Feb 15, 2024 at 10:22:57AM +0100, Uwe Kleine-König wrote: > > If a driver author knows it while writing the code, it's obvious. But if > > the driver author looks again in 2 years or someone else (e.g. me with > > the PWM maintainer hat on and with little pci experience) that knowledge > > might be faded. > > This is widely used pattern. Anybody who works with Git should know how > to use `git grep` tool. If in doubts, always can ask in the mailing lists. IMHO you're assuming to much. If someone sees this pattern and quickly looks at the implementation of pcim_iomap_table() they might (as I did) conclude that this call should be error checked. If they send a patch in say 2 years I think I won't remember this discussion/patch and happily accept this patch. And I probably won't get enough doubts to start grepping around. > I still consider it redundant. > > P.S. That's what you call "bikeshedding" (done by yourself here)? I can understand that you consider that bikeshedding given that for you it's obvious that the second function cannot fail. For me it's not and I take this as a hint that it's not obvious for everyone. Best regards Uwe
On Thu, Feb 15, 2024 at 06:20:15PM +0100, Uwe Kleine-König wrote: > On Thu, Feb 15, 2024 at 03:36:12PM +0200, Andy Shevchenko wrote: > > On Thu, Feb 15, 2024 at 10:22:57AM +0100, Uwe Kleine-König wrote: > > > If a driver author knows it while writing the code, it's obvious. But if > > > the driver author looks again in 2 years or someone else (e.g. me with > > > the PWM maintainer hat on and with little pci experience) that knowledge > > > might be faded. > > > > This is widely used pattern. Anybody who works with Git should know how > > to use `git grep` tool. If in doubts, always can ask in the mailing lists. > > IMHO you're assuming to much. If someone sees this pattern and quickly > looks at the implementation of pcim_iomap_table() they might (as I did) > conclude that this call should be error checked. If they send a patch in > say 2 years I think I won't remember this discussion/patch and happily > accept this patch. And I probably won't get enough doubts to start > grepping around. > > > I still consider it redundant. > > > > P.S. That's what you call "bikeshedding" (done by yourself here)? > > I can understand that you consider that bikeshedding given that for you > it's obvious that the second function cannot fail. For me it's not and I > take this as a hint that it's not obvious for everyone. The bottom line that PCI devres code should be refactored. And IIRC somebody is doing that job, not sure at which stage it is now.
diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c index 4929354f8cd9..596a0bb35c40 100644 --- a/drivers/pwm/pwm-dwc.c +++ b/drivers/pwm/pwm-dwc.c @@ -50,10 +50,6 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id) } dwc->base = pcim_iomap_table(pci)[0]; - if (!dwc->base) { - dev_err(dev, "Base address missing\n"); - return -ENOMEM; - } ret = devm_pwmchip_add(dev, &dwc->chip); if (ret)