[{"id":3687038,"web_url":"http://patchwork.ozlabs.org/comment/3687038/","msgid":"<afs1dhyUDr3SN1Mt@hovoldconsulting.com>","list_archive_url":null,"date":"2026-05-06T12:35:02","subject":"Re: [PATCH 7/8] i2c: core: clean up bus id allocation","submitter":{"id":64666,"url":"http://patchwork.ozlabs.org/api/people/64666/","name":"Johan Hovold","email":"johan@kernel.org"},"content":"On Tue, May 05, 2026 at 04:25:46PM +0200, Johan Hovold wrote:\n> Clean up bus id allocation by using a common helper and deferring it\n> until it is needed during adapter registration.\n> \n> Signed-off-by: Johan Hovold <johan@kernel.org>\n\n> @@ -1665,17 +1675,8 @@ int i2c_add_adapter(struct i2c_adapter *adapter)\n>  \tint id;\n>  \n>  \tid = of_alias_get_id(dev->of_node, \"i2c\");\n> -\tif (id >= 0) {\n> -\t\tadapter->nr = id;\n> -\t\treturn __i2c_add_numbered_adapter(adapter);\n> -\t}\n> -\n> -\tmutex_lock(&core_lock);\n> -\tid = idr_alloc(&i2c_adapter_idr, NULL,\n> -\t\t       __i2c_first_dynamic_bus_num, 0, GFP_KERNEL);\n> -\tmutex_unlock(&core_lock);\n> -\tif (WARN(id < 0, \"couldn't get idr\"))\n> -\t\treturn id;\n> +\tif (id < 0)\n> +\t\tid = -1;\n>  \n>  \tadapter->nr = id;\n>  \n> @@ -1708,10 +1709,7 @@ EXPORT_SYMBOL(i2c_add_adapter);\n>   */\n>  int i2c_add_numbered_adapter(struct i2c_adapter *adap)\n>  {\n> -\tif (adap->nr == -1) /* -1 means dynamically assign bus id */\n> -\t\treturn i2c_add_adapter(adap);\n\nSashiko also flagged this a potential issue -- needs to be kept for the\nalias lookup.\n\n> -\n> -\treturn __i2c_add_numbered_adapter(adap);\n> +\treturn i2c_register_adapter(adap);\n\nJohan","headers":{"Return-Path":"\n <linux-i2c+bounces-17272-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-i2c@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=vG0wuScy;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-i2c+bounces-17272-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"vG0wuScy\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g9ZhC5vpJz1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 22:39:23 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 07559306573C\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  6 May 2026 12:35:07 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 13FF044CAF9;\n\tWed,  6 May 2026 12:35:06 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9418744BCAE;\n\tWed,  6 May 2026 12:35:05 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 3DC2FC2BCB8;\n\tWed,  6 May 2026 12:35:05 +0000 (UTC)","from johan by xi.lan with local (Exim 4.98.2)\n\t(envelope-from <johan@kernel.org>)\n\tid 1wKbSw-00000000mPZ-36Ou;\n\tWed, 06 May 2026 14:35:02 +0200"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778070905; cv=none;\n b=VyiNZLnVNDMwvPRe1pMBrytSKJ08WWvA8O2ntSpa/RvJu3tnlTD0A6Fz4LqyLzxtAU74qO+Igz5bJvOC1dsdRg1JiQ2d6oBWpJPhRzKMKZqBoh3ELbLTf06eAAZ8CLyZgLBKpmiGZFt5Lws1mkVFrWZHz3iHy2LqFYhrkk83yoA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778070905; c=relaxed/simple;\n\tbh=3u09moz3KpKYdM9NuF13xoGw2kqPphVjKjaYLxVLOIQ=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=j4Ll18CnW5wSd/0LnZcxnNpEpH6bLoJZB/dCCNT3Gt5tmRok7lGhHOTwcWMKdTnkeziSWhTbJvo1c48Ejkxs079+dPWEDAf/BEWwjf8EdUX+1SRepMjhxhEGSRp5de/0rWS+eemnZGWUFSLPBHxwrDSpkMq9zaRu4FYLIdTiwX4=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=vG0wuScy; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778070905;\n\tbh=3u09moz3KpKYdM9NuF13xoGw2kqPphVjKjaYLxVLOIQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=vG0wuScyrhBUp6PyZb2rCvsEmNZqYnJTTdCFMdfh0AydDi+3XLEY/zjRtgU9Alqeh\n\t bal+cfDuKVssJzzjuaaCnl/uVUK3f3Bx8fSgbP1Px8E86PKS4GStUtNTToMx58abF1\n\t AYeX7CpEe+VtOjFPZnIbiYmiH1K96Kd/3ZoW5ev6sJA2PYL5CFvppiE6Moubnv2bJC\n\t ccl2MU19EyVmUdNLG2klK3ZPyt11pKkRWFZr2NGgUv8ix+u9Ggmlu8uTpELHCajfvv\n\t TwVkiW2AuE8GQobpykjphQrUl+ZfJHwzAlwiBwCcF/DDz4jtRtn7PhbG4+1aVLfIb6\n\t AjnzAZV8oR0wg==","Date":"Wed, 6 May 2026 14:35:02 +0200","From":"Johan Hovold <johan@kernel.org>","To":"Wolfram Sang <wsa+renesas@sang-engineering.com>","Cc":"Andi Shyti <andi.shyti@kernel.org>, linux-i2c@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org","Subject":"Re: [PATCH 7/8] i2c: core: clean up bus id allocation","Message-ID":"<afs1dhyUDr3SN1Mt@hovoldconsulting.com>","References":"<20260505142547.795054-1-johan@kernel.org>\n <20260505142547.795054-8-johan@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-i2c@vger.kernel.org","List-Id":"<linux-i2c.vger.kernel.org>","List-Subscribe":"<mailto:linux-i2c+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-i2c+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260505142547.795054-8-johan@kernel.org>"}}]