public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@kernel.org>
To: Riwen Lu <luriwen@hotmail.com>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	xiongxin@kylinos.cn, Riwen Lu <luriwen@kylinos.cn>
Subject: Re: [PATCH v1] i2c: i2c-core-base: Modify the maximum idr id for i2c adapter
Date: Mon, 9 Jan 2023 16:13:50 +0100	[thread overview]
Message-ID: <Y7wvLi2lA1bSH5By@ninjato> (raw)
In-Reply-To: <TYCP286MB26079F414019C8AC9303E412B1E69@TYCP286MB2607.JPNP286.PROD.OUTLOOK.COM>

[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]

On Fri, Dec 16, 2022 at 10:07:51AM +0800, Riwen Lu wrote:
> From: Riwen Lu <luriwen@kylinos.cn>
> 
> Change the maximum idr ID to INT_MAX for i2c adapter.
> This fix the following adding i2c adapter error while the idr with
> adap->nr has been allocated by other i2c driver, and find a proper ID

How did this happen that another i2c driver could get this? Were you
able to follow the code paths that lead to this situation?

> for it.
> [  357.620685][ 3] [ T3655] ------------[ cut here ]------------
> [  357.626544][ 3] [ T3655] couldn't get idr
> 
> Signed-off-by: Riwen Lu <luriwen@kylinos.cn>
> ---
>  drivers/i2c/i2c-core-base.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 7539b0740351..c2982861057a 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -1535,11 +1535,12 @@ static int __i2c_add_numbered_adapter(struct i2c_adapter *adap)
>  	int id;
>  
>  	mutex_lock(&core_lock);
> -	id = idr_alloc(&i2c_adapter_idr, adap, adap->nr, adap->nr + 1, GFP_KERNEL);
> +	id = idr_alloc(&i2c_adapter_idr, adap, adap->nr, 0, GFP_KERNEL);
>  	mutex_unlock(&core_lock);
>  	if (WARN(id < 0, "couldn't get idr"))
>  		return id == -ENOSPC ? -EBUSY : id;
>  
> +	adap->nr = id;
>  	return i2c_register_adapter(adap);
>  }
>  
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-01-09 15:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  2:07 [PATCH v1] i2c: i2c-core-base: Modify the maximum idr id for i2c adapter Riwen Lu
2023-01-09 15:13 ` Wolfram Sang [this message]
2023-01-10  8:39   ` Riwen Lu
2023-10-29 17:25     ` Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7wvLi2lA1bSH5By@ninjato \
    --to=wsa@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luriwen@hotmail.com \
    --cc=luriwen@kylinos.cn \
    --cc=xiongxin@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox