Re: [PATCH v2 02/15] spi: Drop duplicate IDR allocation code in spi_register_controller()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [PATCH v2 02/15] spi: Drop duplicate IDR allocation code in spi_register_controller()
- From: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
- Date: Tue, 11 Jul 2023 13:58:12 +0300
- Cc: Cristian Ciocaltea <cristian.ciocaltea@xxxxxxxxxxxxx>, Yang Yingliang <yangyingliang@xxxxxxxxxx>, Amit Kumar Mahapatra via Alsa-devel <alsa-devel@xxxxxxxxxxxxxxxx>, Neil Armstrong <neil.armstrong@xxxxxxxxxx>, Tharun Kumar P <tharunkumar.pasumarthi@xxxxxxxxxxxxx>, Vijaya Krishna Nivarthi <quic_vnivarth@xxxxxxxxxxx>, Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>, linux-spi@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-amlogic@xxxxxxxxxxxxxxxxxxx, linux-mediatek@xxxxxxxxxxxxxxxxxxx, linux-arm-msm@xxxxxxxxxxxxxxx, linux-rockchip@xxxxxxxxxxxxxxxxxxx, linux-riscv@xxxxxxxxxxxxxxxxxxx, linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx, linux-trace-kernel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, Sanjay R Mehta <sanju.mehta@xxxxxxx>, Radu Pirea <radu_nicolae.pirea@xxxxxx>, Nicolas Ferre <nicolas.ferre@xxxxxxxxxxxxx>, Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>, Claudiu Beznea <claudiu.beznea@xxxxxxxxxxxxx>, Tudor Ambarus <tudor.ambarus@xxxxxxxxxx>, Serge Semin <fancer.lancer@xxxxxxxxx>, Shawn Guo <shawnguo@xxxxxxxxxx>, Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>, Pengutronix Kernel Team <kernel@xxxxxxxxxxxxxx>, Fabio Estevam <festevam@xxxxxxxxx>, NXP Linux Team <linux-imx@xxxxxxx>, Kevin Hilman <khilman@xxxxxxxxxxxx>, Jerome Brunet <jbrunet@xxxxxxxxxxxx>, Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>, Matthias Brugger <matthias.bgg@xxxxxxxxx>, AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>, Andy Gross <agross@xxxxxxxxxx>, Bjorn Andersson <andersson@xxxxxxxxxx>, Konrad Dybcio <konrad.dybcio@xxxxxxxxxx>, Heiko Stuebner <heiko@xxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Paul Walmsley <paul.walmsley@xxxxxxxxxx>, Orson Zhai <orsonzhai@xxxxxxxxx>, Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>, Chunyan Zhang <zhang.lyra@xxxxxxxxx>, Alain Volmat <alain.volmat@xxxxxxxxxxx>, Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>, Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Masami Hiramatsu <mhiramat@xxxxxxxxxx>, Richard Cochran <richardcochran@xxxxxxxxx>
- In-reply-to: <97f3436a-78ca-4a94-a409-ef04bd3b593f@sirena.org.uk>
- Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo
- 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>
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
[Index of Archives]
[Linux Kernel]
[Linux ARM (vger)]
[Linux ARM MSM]
[Linux Omap]
[Linux Arm]
[Linux Tegra]
[Fedora ARM]
[Linux for Samsung SOC]
[eCos]
[Linux Fastboot]
[Gcc Help]
[Git]
[DCCP]
[IETF Announce]
[Security]
[Linux MIPS]
[Yosemite Campsites]
|