From nobody Tue Apr 28 23:19:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F4B5C433EF for ; Fri, 27 May 2022 07:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345782AbiE0HXC (ORCPT ); Fri, 27 May 2022 03:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238720AbiE0HW6 (ORCPT ); Fri, 27 May 2022 03:22:58 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E45ED712; Fri, 27 May 2022 00:22:55 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4L8bm75SC8zRhQr; Fri, 27 May 2022 15:19:51 +0800 (CST) Received: from dggpemm500018.china.huawei.com (7.185.36.111) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 27 May 2022 15:22:53 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500018.china.huawei.com (7.185.36.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 27 May 2022 15:22:53 +0800 From: keliu To: , , , , , , , , , , Subject: [PATCH] drivers: char: Directly use ida_alloc()/free() Date: Fri, 27 May 2022 07:44:22 +0000 Message-ID: <20220527074422.2475104-1-liuke94@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500018.china.huawei.com (7.185.36.111) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use ida_alloc()/ida_free() instead of deprecated ida_simple_get()/ida_simple_remove() . Signed-off-by: keliu Acked-by: Michael S. Tsirkin --- drivers/char/hw_random/virtio-rng.c | 6 +++--- drivers/char/ipmi/ipmi_msghandler.c | 4 ++-- drivers/char/ppdev.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/v= irtio-rng.c index e856df7e285c..0ee602963c50 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -135,7 +135,7 @@ static int probe_common(struct virtio_device *vdev) if (!vi) return -ENOMEM; =20 - vi->index =3D index =3D ida_simple_get(&rng_index_ida, 0, 0, GFP_KERNEL); + vi->index =3D index =3D ida_alloc(&rng_index_ida, GFP_KERNEL); if (index < 0) { err =3D index; goto err_ida; @@ -165,7 +165,7 @@ static int probe_common(struct virtio_device *vdev) return 0; =20 err_find: - ida_simple_remove(&rng_index_ida, index); + ida_free(&rng_index_ida, index); err_ida: kfree(vi); return err; @@ -183,7 +183,7 @@ static void remove_common(struct virtio_device *vdev) hwrng_unregister(&vi->hwrng); virtio_reset_device(vdev); vdev->config->del_vqs(vdev); - ida_simple_remove(&rng_index_ida, vi->index); + ida_free(&rng_index_ida, vi->index); kfree(vi); } =20 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_m= sghandler.c index f1827257ef0e..c1584ed24a6b 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -3018,7 +3018,7 @@ static void cleanup_bmc_work(struct work_struct *work) int id =3D bmc->pdev.id; /* Unregister overwrites id */ =20 platform_device_unregister(&bmc->pdev); - ida_simple_remove(&ipmi_bmc_ida, id); + ida_free(&ipmi_bmc_ida, id); } =20 static void @@ -3134,7 +3134,7 @@ static int __ipmi_bmc_register(struct ipmi_smi *intf, =20 bmc->pdev.name =3D "ipmi_bmc"; =20 - rv =3D ida_simple_get(&ipmi_bmc_ida, 0, 0, GFP_KERNEL); + rv =3D ida_alloc(&ipmi_bmc_ida, GFP_KERNEL); if (rv < 0) { kfree(bmc); goto out; diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 38b46c7d1737..f6024d97fe70 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -299,7 +299,7 @@ static int register_device(int minor, struct pp_struct = *pp) goto err; } =20 - index =3D ida_simple_get(&ida_index, 0, 0, GFP_KERNEL); + index =3D ida_alloc(&ida_index, GFP_KERNEL); memset(&ppdev_cb, 0, sizeof(ppdev_cb)); ppdev_cb.irq_func =3D pp_irq; ppdev_cb.flags =3D (pp->flags & PP_EXCL) ? PARPORT_FLAG_EXCL : 0; @@ -310,7 +310,7 @@ static int register_device(int minor, struct pp_struct = *pp) if (!pdev) { pr_warn("%s: failed to register device!\n", name); rc =3D -ENXIO; - ida_simple_remove(&ida_index, index); + ida_free(&ida_index, index); goto err; } =20 @@ -750,7 +750,7 @@ static int pp_release(struct inode *inode, struct file = *file) =20 if (pp->pdev) { parport_unregister_device(pp->pdev); - ida_simple_remove(&ida_index, pp->index); + ida_free(&ida_index, pp->index); pp->pdev =3D NULL; pr_debug(CHRDEV "%x: unregistered pardevice\n", minor); } --=20 2.25.1