Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36664526rwd; Tue, 11 Jul 2023 04:13:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlGpvX4sDFbUsiLmcssdjzIcImX8aaHZvWP4Pb2Gt5f+S2OZmDGbMTXVggnwuNntfEkv0E9u X-Received: by 2002:a17:906:d7b1:b0:98e:1b9b:aef7 with SMTP id pk17-20020a170906d7b100b0098e1b9baef7mr12911634ejb.64.1689074036113; Tue, 11 Jul 2023 04:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689074036; cv=none; d=google.com; s=arc-20160816; b=Uih1yQgTVKXH3eHX2lEBwmL6QhIuRraAWiAB+8/BlnQ+F5cwsWiAsWdGfxvCuPafYC +vTCKKRIRXwlaTXQn/w4XpZbE1wU5e7P9g1JL/GkF1+g8Fmo2ypeXKoi85WC+XYXBVdE E3117Gkg74r/P8kr0nfOIe4jG6qKoXRoAcAIsP3TRquroPui/tkz8pPWlW7YlB7AbjCr aNn47k5VFMDruKjfj2GYaB1BN7piSbYi9S1Wkxm905nhEjKJutTTDNz6YerNSv+vZu/4 Che7ZHnalHkBZaa/fmL+tcifN1Htf8MdE1B66smhcEFgd1tApLHzvSMMFU+8eNx4oSBE QrUg== 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=kBnsSNCEPCx0GSwj7QQVCkmswgJVRUZF4XbEV/sMmD8=; fh=xBut9vtegYDRcLjXNIseFeFa7BXxcdxb18VqmH8P67g=; b=TgXvy2mbDjf1l/8mZR5hhkzuUnMtHALaZC6AxAd71YWgUaA46y+v6C9M8mYuqc24C2 6+zXAyxWgwUntGTI++3fFRsWiXegiorluMHXhJYqPPpYDtZzmPepXIDDsrYvukXy/O/V KReaeLplviXaem1rhsChbrxMZ0ALM7bp8NBDwz6C/KZtJd6fjUZzG3kJ4HB33g59Z11z Xpee3Kd1dKABIZ2dp9jIdrIjzNwPIAYZbI0Hk81t6Wl7liUExPH6o+6Vnx54tiHD9LaA ceHko4cxBWyEFDrzta3WrgU3TqeGTzVnyQhPuKyvZA1vrBn9OLwf4srq6ubR9z8kLI0M mZXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aSDhIFMu; 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 lc5-20020a170906f90500b009931472bdb8si1767655ejb.965.2023.07.11.04.13.31; Tue, 11 Jul 2023 04:13:56 -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=aSDhIFMu; 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 S231189AbjGKK6b (ORCPT + 99 others); Tue, 11 Jul 2023 06:58:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjGKK6a (ORCPT ); Tue, 11 Jul 2023 06:58:30 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20DF19B; Tue, 11 Jul 2023 03:58:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689073109; x=1720609109; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=lIHyBeHEaNenp9Q/l2JAcaQuyI3ymSNUAckdiFell2M=; b=aSDhIFMueOPnwVS7Ho6a6OIntXPb4+TbR8av8tsm7N95ZF0HZvBNOrjE 6IYDKI8Noo4KEC9bjea4tOfDBZw7+Is1haF4dzE/Lhk/AH2xCsqUR7RhD rw9HxOXIUWPylC8POOQphS1jmQDGgYb/JL1I3v44IvjCMzks+Q/feoNi2 32RjOfZWWZ5qO9zM3XX0FbQGqD3n7QxD8Zwoh/76qRnViLx8ducan/skg gjgorJxdWER81EIUlIqRCqhk48WACRer5ZCZeCCnGT2JMwI370n4lDlCU O2aCNRtbAJDyaNdfxwQMN+cFvv4UzNPiDwnJiAY7sDzLgZ2y6CEOfedZU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="368087275" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="368087275" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 03:58:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10767"; a="724404293" X-IronPort-AV: E=Sophos;i="6.01,196,1684825200"; d="scan'208";a="724404293" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga007.fm.intel.com with ESMTP; 11 Jul 2023 03:58:16 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qJB4O-001p51-1q; Tue, 11 Jul 2023 13:58:12 +0300 Date: Tue, 11 Jul 2023 13:58:12 +0300 From: Andy Shevchenko To: Mark Brown 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 02/15] spi: Drop duplicate IDR allocation code in spi_register_controller() Message-ID: References: <20230710154932.68377-1-andriy.shevchenko@linux.intel.com> <20230710154932.68377-3-andriy.shevchenko@linux.intel.com> <97f3436a-78ca-4a94-a409-ef04bd3b593f@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <97f3436a-78ca-4a94-a409-ef04bd3b593f@sirena.org.uk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,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:09:00PM +0100, Mark Brown wrote: > On Mon, Jul 10, 2023 at 06:49:19PM +0300, Andy Shevchenko wrote: > > > Refactor spi_register_controller() to drop duplicate IDR allocation. > > Instead of if-else-if branching use two sequential if:s, which allows > > to re-use the logic of IDR allocation in all cases. > > For legibility this should have been split into a separate factoring out > of the shared code and rewriting of the logic, that'd make it trivial to > review. Should I do that for v3? > > - mutex_lock(&board_lock); > > - id = idr_alloc(&spi_master_idr, ctlr, first_dynamic, > > - 0, GFP_KERNEL); > > - mutex_unlock(&board_lock); > > - if (WARN(id < 0, "couldn't get idr")) > > - return id; > > - ctlr->bus_num = id; > > + status = spi_controller_id_alloc(ctlr, first_dynamic, 0); > > + if (status) > > + return status; > > The original does not do the remapping of return codes that the previous > two copies do... Yes, I had to mention this in the commit message that in my opinion this makes no difference. With the dynamically allocated aliases the absence of the slot has the same effect as in the other cases. -- With Best Regards, Andy Shevchenko