Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36686514rwd; Tue, 11 Jul 2023 04:32:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlHm6TnIWhL5Kr+iRi/ZR2KFyZ7dRtVc0uHEWHHwL0HNZttHbFD5RzwIRmSXqW+hkjvwXHFG X-Received: by 2002:a17:902:dac7:b0:1b8:a56b:989d with SMTP id q7-20020a170902dac700b001b8a56b989dmr19889013plx.6.1689075147103; Tue, 11 Jul 2023 04:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689075147; cv=none; d=google.com; s=arc-20160816; b=oqEPR0gpcC4QRtTb52ofg2QpoG+Pxk5s6uzCZGQP+AWaWEd/tXIKkbGyOvenvtVKMr SztHr80MCeCwVEP2xxWizu49CP7o/Q8FOGbRV4qMXO8en44wKnNB9UOI39BUNZt35RaZ TZmI7n8xC1FNCeMW54fLs/65eW/9/P8C/rPAheH4a8UoS+E3TZv1F1ZhvJ2SsMP6B0Iq UGziuyNwizcskNfQjJWtAg5Sdxdtpkl0b6w79fGZIYdAmWTdrXqsZOMxWC39IwsNm9y3 HedHmItoNdW0H5Zt1nx00EtnCQwzLubebKZ1m12jhuU/24rJK3swPAeqkbtjL/cmRRi6 d/7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iM7ohj/uxht+J8BsFBilm17CQG7Pe20OIBKUPjiQep8=; fh=JXvupZZ5lcvbsDIolDxAeX32LIi8hZDsulVXkS+a5o4=; b=En3drRjQY9M+pGMMFQASI69Z20djfglryHRYIZRGw5i9lvNEFRta8Es9sZgtTBlRK2 gg6NyDgwXrwWkEahuiRborTHrd2kNZ8sPRPIsnuoWBriwapSHYitUsHsQr7NkW6pZ6Dt WQz8E+SnTvEIff5zfSZbOMX+ve/r7K3OBCfgwBb3KKbVuBmdvOd3tLWTVFg2pKewb1gP rlnjhf6Ed0uiZkpr3AHptvg4it3Jzbx1QDG2iu0pXSSWFfNEGMcdtPWoHEPKWZQhhyBE ibDmtf8EzGhWh0l2l/ow8McU/AcqTkTDVPjVl7lAMIZ8cZ4HKNlEWKieYQo6Eg3U51Nn aNCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Fgb/nzHd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w21-20020a170902d71500b001b9e0d0a01fsi1415823ply.256.2023.07.11.04.32.14; Tue, 11 Jul 2023 04:32:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Fgb/nzHd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbjGKLGk (ORCPT + 99 others); Tue, 11 Jul 2023 07:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231416AbjGKLGj (ORCPT ); Tue, 11 Jul 2023 07:06:39 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8829B; Tue, 11 Jul 2023 04:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689073598; x=1720609598; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=RVFLgj8cxsWZyvySjgaprTvsCfpSOgqQ4kC3+s/s1Fk=; b=Fgb/nzHdhACg9g5her1kIIHPWeJMCqDylq1nS+bRcMWjiKxpA76/iRcO sTaAJTdEfkONty+4pL+OBY1upct2eZJaa4dveqrXbk3kmo5ZJOI1SR7RY 0j2QKeopsLJL046lR2p7P5OwtCgGchysPywz5Pn5OutUssKFMvY8YFclT n0hIv9eG7KDpQx3c8NmnCtn0Jb2aXBQQkjgMQ5RrDtFwWeKmlp8DCUnyI hRoX/Qni1jMapu+3UrmVLm17GxCFKi5L9dQLNfHca7upEJ/XelTOsOMvw Ah8UDbx6EyH4MprfWwiu8ZjGKMq5NdlSF/dewGDPmVUaN+1dmwFmU0erh Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="450950699" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="450950699" 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-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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