Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35651565rwd; Mon, 10 Jul 2023 10:23:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHbkHzmGHtFxePxK2xyZUqVlR5XXoZ5EGoRcV8fVbwX+32lxz9u94JOnZb1fGeZxP6dUOds X-Received: by 2002:a17:906:ce39:b0:977:ceab:3996 with SMTP id sd25-20020a170906ce3900b00977ceab3996mr12217852ejb.76.1689009803804; Mon, 10 Jul 2023 10:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689009803; cv=none; d=google.com; s=arc-20160816; b=a0pBOlmpznCLt0x73QqJ6UcTAYeO3bbYYdPbAaHWxa1Ok1B5IcTzc5+kKClAuX4aPj uaCbnXbT3dTI4DtWu1D3T7/RvMdqKHct3WurknbWUz6uugeAZRtP7OliGcIEKcIbA3Gm vVe2V7rLCCoV9OxxiLufV8HjrGYb8EwWDcvWM4b+2+gcXVnEEN33iPNRBIj6+tbwpzgN AULHpjzAskNHTih91ssPQXBPJv+pkOY7vvHurMbnHgXhkSv9HbWfkwB4dDwVbev1bslv 2dBYeWye5g5biHrqERYX1G4KoDugfm2CHZNO/SzXHM5Aqna45JbZAbnF2faM6TZ7sTou 99Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FYbWqyzGQEO+WdN3CM73ojIgVjKro3KEZf/aupBU4qk=; fh=FR1TuMeeSkO8NrfcwD6Pn+GCDkn3IwyNRlohVX/xlRU=; b=Vl08b3er1LiWQj5KfxByUUivtEzHziL/yP9l2zgEKUW2pKk6GwZwxRWC6VQ3hoWJOM JQOOlCpjEfVhYFmTczu8y71nFvQWZFQ6R7KuKdp3UXEiXW9xacR1t5jBI8HfmduNNr20 eMKjfCuNYb3NIkltgocbAqODuKBNE5kj/09JMsT95kFHXP2GPsQar+WhiAt1EeUSsH13 Ty6Kku45Iw4mYVKrSQAzIm4zo7Ml+0Pbe5dgczSQz8PDZ/2kQAYP5WKz1dY6NwPrZTRx DLnNHbHSC80iTG+LfesQdV1Jrk313C/y/WRoEd6orsCE5E/siCpeRhljl+0OFVfG/E4d rBXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ks7RL3h4; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw26-20020a170906c79a00b0099248468c50si25855ejb.296.2023.07.10.10.22.59; Mon, 10 Jul 2023 10:23:23 -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=@kernel.org header.s=k20201202 header.b=Ks7RL3h4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbjGJRJU (ORCPT + 99 others); Mon, 10 Jul 2023 13:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjGJRJS (ORCPT ); Mon, 10 Jul 2023 13:09:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E80C0; Mon, 10 Jul 2023 10:09:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BFEFB61127; Mon, 10 Jul 2023 17:09:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 822D8C433C9; Mon, 10 Jul 2023 17:09:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689008956; bh=nKZycr1bbDIhX+7r/umilV/wuLHcsLLg8WWLjNqfVGw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ks7RL3h40J9Gsg6+T5tGMhXUPebOkMtv2HYbINZYkE0HBcDFe3InO0uHvSLO6Ywfd z9dbScYbXDyBfN0KKzvhwsevIOZI2Wa4nTPSPcqSdIk9dVy3t4CwrMIhESNVB8EcTq DHcqHiLwexT4fjkOSD7WRFfWxwr4oLox+CN38zoYAqwcwq7DLt0YYhvaSCGjOeZdC6 /OMp7mPT/0W9iS9bRuPwjhjEgn3ZN4a3GPUVex+MO83a5hpzqpvTmLwha1tCaAJG7B IOQDzu3lMvKgzC08AKXIF8wSz30WvJ3WDseHtgBrUd0ZFYjZe2rdpVVbiRnkMjF1jV sbYhTW/HyF8mg== Date: Mon, 10 Jul 2023 18:09:00 +0100 From: Mark Brown To: Andy Shevchenko 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: <97f3436a-78ca-4a94-a409-ef04bd3b593f@sirena.org.uk> References: <20230710154932.68377-1-andriy.shevchenko@linux.intel.com> <20230710154932.68377-3-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ugTz/0iIbXaMesMQ" Content-Disposition: inline In-Reply-To: <20230710154932.68377-3-andriy.shevchenko@linux.intel.com> X-Cookie: Do you have lysdexia? X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 --ugTz/0iIbXaMesMQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. > - 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... --ugTz/0iIbXaMesMQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmSsOysACgkQJNaLcl1U h9Bj2wf/eujSGQes7B4PBTQ3n1oBhkcL7Y24XQnkT5q6FXhb+PNy2gOUL7X4u8/s jewRdgc+ViUGaokkDON2TN26dLdi/+KEGq7rPGhgLMeyGSqKJx5uRaCQSSdKa2Y2 w1zSdEXhWd9SZsgsLa18k9bVMBbmyuylLjQYrLlHktiuD4/baW1HQ5SqKICkb1Bg /ZdcRGqcKDfgJWnVfK4loF7rFNMRBY0rXsSdOVE3yOKeZE2uS46s2BPPN+xc7UaA KTSUu8JjCacwP+V70yrm4VGRb5/c0NJ++iO44yiykKNRvcJWCDemwAYhj9zV1ja/ 5l/fUqxd3+5Kv3hbc1rSnyAywM7/4g== =1GBL -----END PGP SIGNATURE----- --ugTz/0iIbXaMesMQ--