Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp741804rdh; Wed, 14 Feb 2024 09:57:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6pKBiUpaMDGGwgPjrRUPN7S+NFslgQWQJU+YgsZmQKkwKcHiVZCpb4p+MC9TmL8ZK30tFOfkmCQ8ql7G+OZxjFTjk/zbKZ1jV//0IIw== X-Google-Smtp-Source: AGHT+IEo92nzGjR38GQq2IRdiGMG5jdBVxOUR/Hkbc5hmr9iIFshmBCqQB+CHWmNY8VXJHiCtkK3 X-Received: by 2002:a05:6808:16ac:b0:3be:494e:9379 with SMTP id bb44-20020a05680816ac00b003be494e9379mr3611258oib.16.1707933455826; Wed, 14 Feb 2024 09:57:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707933455; cv=pass; d=google.com; s=arc-20160816; b=f6vWnxExPRXEAp3+XG2awkQUuGhnPnKAlfs6oFjx+ndG0liRlSgL8I4AeAEHP6weS9 C5SQmJ41iZY2ycTHBISIIl8YZRg48TEwGTO3cK5hsUB4+U2owjFkD6E6lFsNdcCwke9z Cyo535tXP4V+20I/4qHwsIWMzY3IwALvI3IAp7yJ+eua5d6f5hG9Iah5TlAltZNIT/ZX kSUOB4NDsBgcu32zx6iAQBt+MSyVQCRZhOynFlIKXjCYOp8JoqUwq7hCbnjEU54U3jIN dyFVlzC0Nuze99o4e1q+hZOZU3IPFlmzcngTQY3liwDIb2pQ3eaxUf1Y2bEpJS1mBUrn KDdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=organization:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nqGLIyZGgo8Ztj/HfBi1ex2Xjgz+BPqqs1jHLa+F+7c=; fh=fYn06OClJZrP9sJB6On+XRg19MFMv8U9XxuAyxFHseg=; b=m6pNkM6gfrP62Mi47dVQpDehM+GGBq5DGIfyOHnuzvcVYr+ub8V08lPKgx+Y2I8W0W zQX+HYR94idkn4toomW3Xu/QXCJghkee9ZEyUe8JuG209TqaaY9HUVg4gQILHC9RzQjK v7jK0PXoCIH/YMtan6A75OiO1CgnrD96t6mNldAiOEoJJN+67516C4iY8dgC8j6UGcLu 5t526IejTjLWRVfd3Q+e3+Fs8sGOgqtJP5u6EHmncMAoVE69iYEMH9OtW23LlVfFPiYm NbyxW9WMhemIgbj8+sO7nCkkBzkqTKJsP66BIHNLw8ic+RfodNHjujGsyeGPfsKgExPG B02w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="H40AzB/7"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-65727-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65727-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXhfsYqypvdcJ8bpjCHAqjQYDANONejCdtNW/+5cBUp4PdnF/WXS83Q2JMrJD6p8CKyMgMveh4eT9OgmDmzR0bQ09s5n56Uh5m3leFahg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l24-20020ae9f018000000b00785ab75cfd1si11141059qkg.449.2024.02.14.09.57.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 09:57:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65727-linux.lists.archive=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="H40AzB/7"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-65727-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65727-linux.lists.archive=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 BE90D1C27E57 for ; Wed, 14 Feb 2024 17:55:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C72471272D3; Wed, 14 Feb 2024 17:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H40AzB/7" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 4F3F6126F3E; Wed, 14 Feb 2024 17:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707933306; cv=none; b=gYnDIr9Ajqg6kegHPVURH/eqInwPa7GZu75yDKvNspqR76KTEFXRQbq5rIzQ6bG49723fb4jpaEbflCa25DkoeE83xMA9qFwfx/QUOJBMhqzKHbl1wvOORA7CGI601iq1Hytyu4QHuA9z5su2oDSK40Y9Pr/qd0ucXNtHbFkYTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707933306; c=relaxed/simple; bh=aj7CoZ0NAdOuL6mZfwN+KVUUcS2JZ6cq6z7lzJwvVU0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DSRxQJhf05Le2x3hsX0I9895YQkjO21YGRZGCFEES3L9Im/bxcrWtF/58GiQghruDvEncnz7JyX3CMcGg7fkfj0x/uL/xne6vadHn8MLk7cGEyhNtTD5ZZAUIPnBK2ZSPfSwn7QZRY8HfhQswMvLaOIv6jufgmsogkAw0qvJdi8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=H40AzB/7; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707933305; x=1739469305; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=aj7CoZ0NAdOuL6mZfwN+KVUUcS2JZ6cq6z7lzJwvVU0=; b=H40AzB/7EEFdEsObd8B10FD6Wbnbyq96FR5lpwnPMaw7Fjp0uqKivCQB PtCi+NEC/YDWgxfX9yEHUGII2hoTtBqUC9CTIzhY56R9NpVt7uxdqJnAQ 5l6VZCaYrg+JyoL0ogfJ2D4K5XVrvqrnYo+oRkru8P9A7aZ4DmqGDjA/G w/jYAxJ/AUZ1KKGJRIg1JJrTJmzyXDmHUTAPnYWqJNju5Pz+1a6UE7dlH Lhvz7j6YVO1hcOdApdJc8kp8spMXnNq6AIAhoNFe5c06aGc7OdniXp59a dBXoDHAZvetAhrqpFzGSeeOAoqvX5ss6FbniEXuPW/Ue3nc8kDhjdEKg4 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="13381417" X-IronPort-AV: E=Sophos;i="6.06,160,1705392000"; d="scan'208";a="13381417" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 09:55:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="912092863" X-IronPort-AV: E=Sophos;i="6.06,160,1705392000"; d="scan'208";a="912092863" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 09:55:00 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1raJTG-00000004Yld-3fku; Wed, 14 Feb 2024 19:54:58 +0200 Date: Wed, 14 Feb 2024 19:54:58 +0200 From: Andy Shevchenko To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Raag Jadav , jarkko.nikula@linux.intel.com, mika.westerberg@linux.intel.com, lakshmi.sowjanya.d@intel.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/5] pwm: dwc: drop redundant error check Message-ID: References: <20240208070529.28562-1-raag.jadav@intel.com> <20240208070529.28562-2-raag.jadav@intel.com> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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? -- With Best Regards, Andy Shevchenko