From nobody Tue Apr 7 19:55:53 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB0F82D2488 for ; Wed, 11 Mar 2026 19:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773258147; cv=none; b=gqmzZ/L6gjqqzxzGB1sdsFV4GtpwQErqgCXos7jwmFvW9ArBUPuf3EeNP3+PuqALU+45JzQfv7ijo2cfCYFOgCG6TOj7cOUzLM6UpE5sBFFAwvJ0BQ+5H0Habd0RO1n7U5QSJrkiTe8phRRB3XsC6FJLVrYNdwBxUVgo2g3eX30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773258147; c=relaxed/simple; bh=oZhls62WECpH5MCJqF5x1CqtMXJP+dTn5pvyw5oC/N8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=S5MsagKWdEvtrk0ca3BMhYbNekKg3gpnK+gQVxmz4cnDUqkb1ICERsvWY14XINmD/7o2XAukckh9hQ/00FqjSbI33FIyrjysHBEGTPYIX9AH3KGOithI1OuHSZ8WkfDz+qKcR3jwXUCXa5/A/gLdtaU7Aax9gCJ7wX6MlrWRQ6I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=A0Jtyzi2; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A0Jtyzi2" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-35a09e0dd63so190116a91.3 for ; Wed, 11 Mar 2026 12:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773258145; x=1773862945; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MIt/lxrkvODN0l6RiEURES04wifHtipdKzjIGMWChwE=; b=A0Jtyzi2pkoIc7+vpKB7lpPOhUVM09JiVnoEKncohBIekuhg1l+9vqL88qufXOgFrW wU2cfc4FjbgM9+xRttWUOdusLtgceX3gbabOnSZcAmd0sUD/zAy0XEPnoeiLLSkSiDNe EkubF5Mcqkwnw89U5m82Jnqenty0MvUFpBIwtLsPyYoYO/StRfRQadTO1Gyj0kf2MJDL tlZ8PDFY/LN6kQNSrNMrF68eO3MyM8e4QI/8M0fgQiMeggnRrYUUsXqQRaHuyNTxfj3g LtkhQTmbFgj2kYgxpSFZb6/N01c1DXfI8qfMlD/EkZFghCSYzAN+baevkOxVp3VuupuC seAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773258145; x=1773862945; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MIt/lxrkvODN0l6RiEURES04wifHtipdKzjIGMWChwE=; b=FX/xO10nuxIoJjUoCAy7Qj+/WeKLmf7ID4XAkljbXLj9fNURYx20nR3TgZ2xbyZAIg Qm0hixBMySxilJSluIcpui/28ssztbpmNz6EN5to6fLJKsKGRbyv7TQlShDdY2+gJAcc BeRqX1sDIvqM7OyI+pGiWxTssGDverrVgyxp4P4ppA6IHRGPjhvApqeX63ovFP77avZl scO935H1ADSHOPjpcPy0nbsAf6iksNZYUz+ItfpFwSpolEO/KmucJ9F53+sXTeeHD4vE UWnS+ykcP+7Ch1Z8iIYWlKFuJHFkOojebrG7ktlNLiTKHyMpMNXxGyI9ykPcc/caifYy ZKpw== X-Forwarded-Encrypted: i=1; AJvYcCUdUDoUp3dWTO1dVVh+XfLb5GGPjn4SgNgQ3PGl6e0jJdGTN+erA5mA6yL3lftsTIpk8aLNqQUhE6aDVik=@vger.kernel.org X-Gm-Message-State: AOJu0YzdL5VWv1HJZB+OA1thdYQRycUZrC20xdDhW1NBFVdpOsXeGqKU SX3QsfiA58pSs4pNIzEjGgHA5bohV1JgLoFVwXAhCLQ6+POSf6rPyWzJ X-Gm-Gg: ATEYQzysR6cdRH+DVN6+JV3p00ckaXebgCmNsaStAF9K3HBuCVbj9Xwb39uBCS2i9zn Ff6XiCYAaX+hNShNYWYZkqrp/pjT/svMZNYI4iypOdHSN9QWSzOPJ4c6Ytap8WFicro5CGwhAiP eoGPKhxK0ehQ7I4u61kUOo2+isLcG1hyXb1LhUdlUvFK5ua45M+2OJEOkcu3v4VeNidoJ4IM0lX rtUWODPNNrhCOZWKkpHEHIkH6PHG72Trk2Z29+lx4uiMZjo81WWaqXQbks/H3GD45VtdyHuQvlz laLz/0gHn1UcO0pVTQwhdcAT+C995mm+zZ5BpqkVzohEDHb1moH4vTjOo0nZxHaF3SZlkIuxs3I v0rATWn1ndrQf8cE9yaGfcb8mgi8WglF08/9L7DUj3Nz+kl4o13iPd1CvdUi3jhMCENkN134oTE UwLH7bTHMswVVvnMla0Ubarz5S7af/+DXP2MaWhp0iGNDV X-Received: by 2002:a17:90b:28c4:b0:359:409:49bf with SMTP id 98e67ed59e1d1-35a0129e642mr3487580a91.21.1773258145140; Wed, 11 Mar 2026 12:42:25 -0700 (PDT) Received: from hyd-e160-a08-1-06.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35a02ba23adsm2965131a91.0.2026.03.11.12.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 12:42:24 -0700 (PDT) From: Rahul Joshi To: dtwlin@gmail.com, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org Cc: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Rahul Joshi Subject: [PATCH] staging: greybus: uart: replace DEFINE_IDR with DEFINE_XARRAY_ALLOC Date: Thu, 12 Mar 2026 01:12:00 +0530 Message-Id: <20260311194200.542783-1-rj5547884@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" DEFINE_IDR is deprecated in favour of DEFINE_XARRAY_ALLOC. Replace the tty_minors IDR with an XArray and update all call sites: idr_alloc() -> xa_alloc() idr_find() -> xa_load() idr_remove() -> xa_erase() idr_destroy() -> xa_destroy() Also remove the now-unused include and add . Signed-off-by: Rahul Joshi --- drivers/staging/greybus/uart.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c index 7d060b4cd33d..bed3f35a6ec2 100644 --- a/drivers/staging/greybus/uart.c +++ b/drivers/staging/greybus/uart.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ struct gb_tty { }; =20 static struct tty_driver *gb_tty_driver; -static DEFINE_IDR(tty_minors); +static DEFINE_XARRAY_ALLOC(tty_minors); static DEFINE_MUTEX(table_lock); =20 static int gb_uart_receive_data_handler(struct gb_operation *op) @@ -342,7 +342,7 @@ static struct gb_tty *get_gb_by_minor(unsigned int mino= r) struct gb_tty *gb_tty; =20 mutex_lock(&table_lock); - gb_tty =3D idr_find(&tty_minors, minor); + gb_tty =3D xa_load(&tty_minors, minor); if (gb_tty) { mutex_lock(&gb_tty->mutex); if (gb_tty->disconnected) { @@ -359,14 +359,18 @@ static struct gb_tty *get_gb_by_minor(unsigned int mi= nor) =20 static int alloc_minor(struct gb_tty *gb_tty) { - int minor; + int retval; + u32 index; =20 mutex_lock(&table_lock); - minor =3D idr_alloc(&tty_minors, gb_tty, 0, GB_NUM_MINORS, GFP_KERNEL); + retval =3D xa_alloc(&tty_minors, &index, gb_tty, + XA_LIMIT(0, GB_NUM_MINORS - 1), GFP_KERNEL); mutex_unlock(&table_lock); - if (minor >=3D 0) - gb_tty->minor =3D minor; - return minor; + if (retval < 0) + return retval; + + gb_tty->minor =3D index; + return index; } =20 static void release_minor(struct gb_tty *gb_tty) @@ -375,7 +379,7 @@ static void release_minor(struct gb_tty *gb_tty) =20 gb_tty->minor =3D 0; /* Maybe should use an invalid value instead */ mutex_lock(&table_lock); - idr_remove(&tty_minors, minor); + xa_erase(&tty_minors, minor); mutex_unlock(&table_lock); } =20 @@ -984,7 +988,7 @@ static void gb_tty_exit(void) { tty_unregister_driver(gb_tty_driver); tty_driver_kref_put(gb_tty_driver); - idr_destroy(&tty_minors); + xa_destroy(&tty_minors); } =20 static const struct gbphy_device_id gb_uart_id_table[] =3D { --=20 2.34.1