From patchwork Thu Apr 20 19:19:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13219130 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 0596AC77B73 for ; Thu, 20 Apr 2023 19:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbjDTTT0 (ORCPT ); Thu, 20 Apr 2023 15:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbjDTTTZ (ORCPT ); Thu, 20 Apr 2023 15:19:25 -0400 Received: from smtp.smtpout.orange.fr (smtp-11.smtpout.orange.fr [80.12.242.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20DAD4ECE for ; Thu, 20 Apr 2023 12:19:07 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id pZo7pjZIVLbpDpZo8pVyl8; Thu, 20 Apr 2023 21:19:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682018345; bh=xEO8CI9H9WDO+PWu0PIXBsB8fTZqe2/3Shi9OjFKgUE=; h=From:To:Cc:Subject:Date; b=d7DupFV1mk554xgT7ZmeBZ2PilYiuqaqFgfYq0DWlJN6USgDG1I1rM+fUGT1I363i O6Rw+b7pIRwd+G7hHsbBPvD9a0gZyfvMFh5utXc3AgnRd6snMLZXdBEl3SAZ9jH1N/ PTCrhMoNKF1fojEC6NgjF+l/Y+meLDIoemkomHDNCrAPIpYYnyV0SZFyHm7w4KDV/S ZBzejECVQ4bEAMlYRl6Yc5LKHSUvXbvYUiEzsKf+WSk8t8W8XPosEqA0iSLF9xAqn+ IkSAonHcDssNK8l5dglnOu4/0H6AJnvH7OyGZYElA122UtSW2eSe/CrrSE+rUgEbFB tb5Hu+LNwIv+w== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 20 Apr 2023 21:19:05 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-sh@vger.kernel.org Subject: [PATCH v2] sh: sq: Use the bitmap API when applicable Date: Thu, 20 Apr 2023 21:19:03 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Using the bitmap API is less verbose than hand writing it. It also improves the semantic. Signed-off-by: Christophe JAILLET Reviewed-by: Geert Uytterhoeven Reviewed-by: John Paul Adrian Glaubitz --- v2: - synch with latest linux-next because of 80f746e2bd0e which fixes a bug --- arch/sh/kernel/cpu/sh4/sq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index 27f2e3da5aa2..d289e99dc118 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -372,7 +372,6 @@ static struct subsys_interface sq_interface = { static int __init sq_api_init(void) { unsigned int nr_pages = 0x04000000 >> PAGE_SHIFT; - unsigned int size = (nr_pages + (BITS_PER_LONG - 1)) / BITS_PER_LONG; int ret = -ENOMEM; printk(KERN_NOTICE "sq: Registering store queue API.\n"); @@ -382,7 +381,7 @@ static int __init sq_api_init(void) if (unlikely(!sq_cache)) return ret; - sq_bitmap = kcalloc(size, sizeof(long), GFP_KERNEL); + sq_bitmap = bitmap_zalloc(nr_pages, GFP_KERNEL); if (unlikely(!sq_bitmap)) goto out; @@ -393,7 +392,7 @@ static int __init sq_api_init(void) return 0; out: - kfree(sq_bitmap); + bitmap_free(sq_bitmap); kmem_cache_destroy(sq_cache); return ret; @@ -402,7 +401,7 @@ static int __init sq_api_init(void) static void __exit sq_api_exit(void) { subsys_interface_unregister(&sq_interface); - kfree(sq_bitmap); + bitmap_free(sq_bitmap); kmem_cache_destroy(sq_cache); }