From mboxrd@z Thu Jan 1 00:00:00 1970 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 614ACEB64DC for ; Tue, 11 Jul 2023 14:25:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B86D2FC2; Tue, 11 Jul 2023 16:24:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B86D2FC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689085546; bh=RVFLgj8cxsWZyvySjgaprTvsCfpSOgqQ4kC3+s/s1Fk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HHgOOVXH+Kc3jmEhg7IHriPm5opvU00/8eUP8SAJP4QeqDvxrlD5R1sWkOEn9UpHT tKr8mRkaJyCIljH2CKjvkz1EbtTQnya3kynwwjmD7tqunROhu5VU6DpZ07ZwsQZqTD 0gdYhSCIlmnAHHQ0fQWtaazc8zfi3FeF14DyQvUE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 50AB2F80607; Tue, 11 Jul 2023 16:21:58 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 5288DF805F9; Tue, 11 Jul 2023 16:21:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3D50F80236; Tue, 11 Jul 2023 13:06:44 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7EDF3F800E4 for ; Tue, 11 Jul 2023 13:06:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7EDF3F800E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=FsRgayC2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689073601; x=1720609601; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=RVFLgj8cxsWZyvySjgaprTvsCfpSOgqQ4kC3+s/s1Fk=; b=FsRgayC2WX2Mg0PRtIac6LfuLCQaoBMxNSC6BWYQYyD78/g8IAGMWFz8 I4qSLnHZTs3UbrN22OwDj69WUCMZBrj029U76dYsfQmDh2681pq6CNz62 Lsk2/qC4Ey7sjIrsbXjRiNmlrNb3IxJoGVvE49nQhZu4fUD4ohBorrHZq P12mJgwnfa5DEyxcZu243VGnass+idYbz/JJjJYOoOkoRJVK4tsE2VO0v TyFG3DuPCWjTn+D3pz9/LbnOEYZgx5Af/VxtS7VY869ZWsFpF+8i0t3m3 vQUXhv0Xc0ev5jihV/3KwMPDP7smgo+id6o5kaSlznt6W8e99rBuRy8Sy A==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="450950709" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="450950709" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 04:06:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="721057401" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="721057401" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 11 Jul 2023 04:06:24 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qJBCG-001pDs-2n; Tue, 11 Jul 2023 14:06:20 +0300 Date: Tue, 11 Jul 2023 14:06:20 +0300 From: Andy Shevchenko To: Mark Brown , Sebastian Reichel Cc: Cristian Ciocaltea , Yang Yingliang , Amit Kumar Mahapatra via Alsa-devel , Neil Armstrong , Tharun Kumar P , Vijaya Krishna Nivarthi , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org, Sanjay R Mehta , Radu Pirea , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Tudor Ambarus , Serge Semin , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Matthias Brugger , AngeloGioacchino Del Regno , Andy Gross , Bjorn Andersson , Konrad Dybcio , Heiko Stuebner , Palmer Dabbelt , Paul Walmsley , Orson Zhai , Baolin Wang , Chunyan Zhang , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Max Filippov , Steven Rostedt , Masami Hiramatsu , Richard Cochran Subject: Re: [PATCH v2 05/15] spi: Remove code duplication in spi_add_device_locked() Message-ID: References: <20230710154932.68377-1-andriy.shevchenko@linux.intel.com> <20230710154932.68377-6-andriy.shevchenko@linux.intel.com> <7557bada-3076-4d6e-a5c5-d368433706e2@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7557bada-3076-4d6e-a5c5-d368433706e2@sirena.org.uk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-MailFrom: andriy.shevchenko@linux.intel.com X-Mailman-Rule-Hits: max-recipients X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-size; news-moderation; no-subject; digests; suspicious-header Message-ID-Hash: EFAGZ3FPS5VKH2RFVCJ3NBCCZUP24IYG X-Message-ID-Hash: EFAGZ3FPS5VKH2RFVCJ3NBCCZUP24IYG X-Mailman-Approved-At: Tue, 11 Jul 2023 14:21:48 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Mon, Jul 10, 2023 at 06:16:22PM +0100, Mark Brown wrote: > On Mon, Jul 10, 2023 at 06:49:22PM +0300, Andy Shevchenko wrote: > > Seems by unknown reason, probably some kind of mis-rebase, > > the commit 0c79378c0199 ("spi: add ancillary device support") > > adds a dozen of duplicating lines of code. Drop them. > > > > Signed-off-by: Andy Shevchenko > > --- > > drivers/spi/spi.c | 11 ----------- > > 1 file changed, 11 deletions(-) > > > > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > > index c99ee4164f11..46cbda383228 100644 > > --- a/drivers/spi/spi.c > > +++ b/drivers/spi/spi.c > > @@ -712,17 +712,6 @@ EXPORT_SYMBOL_GPL(spi_add_device); > > static int spi_add_device_locked(struct spi_device *spi) > > { > > struct spi_controller *ctlr = spi->controller; > > - struct device *dev = ctlr->dev.parent; > > - > > - /* Chipselects are numbered 0..max; validate. */ > > - if (spi_get_chipselect(spi, 0) >= ctlr->num_chipselect) { > > - dev_err(dev, "cs%d >= max %d\n", spi_get_chipselect(spi, 0), > > - ctlr->num_chipselect); > > - return -EINVAL; > > - } > > - > > - /* Set the bus ID string */ > > - spi_dev_set_name(spi); > > I see that this is duplicating spi_add_device() (and we really could do > better with code sharing there I think) but I can't immediately see > where the duplication that's intended to be elimiated is here - where > else in the one call path that spi_add_device_locked() has would we do > the above? Based on the changelog I was expecting to see some > duplicated code in the function itself. Oh, by some reason Sebastian wasn't in this rather long Cc list. Added him. Reading again I don't see any useful explanation why that piece of code has to be duplicated among these two functions. It's 100% a copy. Sebastian, can you shed some light here? -- With Best Regards, Andy Shevchenko