Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3906814imm; Mon, 18 Jun 2018 06:11:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLDtCKwLG9PX56Ujl7zbIyaw83KHyfTV5FfO4+vI3x51fnEgxJQMNnZG9M78jLsTsSfwbib X-Received: by 2002:a62:b201:: with SMTP id x1-v6mr13539061pfe.189.1529327485767; Mon, 18 Jun 2018 06:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529327485; cv=none; d=google.com; s=arc-20160816; b=lkMJw3etAAJLKFQoICsQEu+ZWW2Mkd1KB0QxSQtApaPHP10lbx2KUCQE32D0xDXD8j UT4r3K6zUKwCBvfcbGN1fHUcT3iMMoTv+AYur3REhYVKMxSXjXC9Ug0Bb3IFr7QJUbUB YI4GVfCkepnunufVT8cs71iPEyrreu8ORGDtXo63DcxogClDFUWfnK5GDtvmx+dRQULA b8d+zuP7nRWpzx2PM8Z2dp2mJ8cyR7Yt7lHcIL8/7h2Ha3HoZSgzlnk6QWxqM4Tr2v7m RxLivwyOIk39MG9cZyqqTJ3BdnIy498e5f2nDunq1jk/K3u764jzvWQcCR1CvaVvsxN2 vu9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7TxeMxGraWY7TIkx9VfUEaeA7vEo29pbhg0UcyjjlU4=; b=sKngg/j3+Xt5OM60MCd6V6eSn2x6fYwdxjt90nd825cSRnbpyRarrnYGg8apmOf36n U7YIOsJJzo9f20Cmuey5G+QMJP011ZpkiaEK41SzbUIP50cn7L5zkqvQ8iE9yePnOV4t bQ1VILdRLhnleNvEH9v5eLujFfR5/I03EUEe+Txjth27+CRtBWO5rmSISgbv9o/SDDL2 GHM6cBBnbY44jQ5ARedI3O2qvo9lS+8HCQ03MXCbazhGeTwpUrViAs27wmnWh7Y7BPt/ ONbUF1vOcC6cDePj7C1Ing2XsFjK3lm/q2h4KKUfewjZdSAszcKakLhcsC3lBdFQb8uK 0FCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24-v6si12027468pgn.194.2018.06.18.06.11.11; Mon, 18 Jun 2018 06:11:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934109AbeFRNKO (ORCPT + 99 others); Mon, 18 Jun 2018 09:10:14 -0400 Received: from mga18.intel.com ([134.134.136.126]:32956 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933929AbeFRNKL (ORCPT ); Mon, 18 Jun 2018 09:10:11 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jun 2018 06:10:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,239,1526367600"; d="scan'208";a="49862980" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 18 Jun 2018 06:10:07 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A0769553; Mon, 18 Jun 2018 16:10:04 +0300 (EEST) From: Andy Shevchenko To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li , linux-raid@vger.kernel.org, Dmitry Torokhov , linux-input@vger.kernel.org, Andrew Morton , Yury Norov , linux-kernel@vger.kernel.org, mika.westerberg@linux.intel.com, Joe Perches Cc: Andy Shevchenko Subject: [PATCH v3 5/5] Input: evdev - Switch to bitmap API Date: Mon, 18 Jun 2018 16:10:03 +0300 Message-Id: <20180618131003.88110-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618131003.88110-1-andriy.shevchenko@linux.intel.com> References: <20180618131003.88110-1-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switch to bitmap API, i.e. bitmap_alloc(), bitmap_zalloc(), to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *. While here, replace memcpy() with bitmap_copy() for sake of consistency. Acked-by: Dmitry Torokhov Signed-off-by: Andy Shevchenko --- drivers/input/evdev.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index c81c79d01d93..370206f987f9 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -481,7 +481,7 @@ static int evdev_release(struct inode *inode, struct file *file) evdev_detach_client(evdev, client); for (i = 0; i < EV_CNT; ++i) - kfree(client->evmasks[i]); + bitmap_free(client->evmasks[i]); kvfree(client); @@ -925,17 +925,15 @@ static int evdev_handle_get_val(struct evdev_client *client, { int ret; unsigned long *mem; - size_t len; - len = BITS_TO_LONGS(maxbit) * sizeof(unsigned long); - mem = kmalloc(len, GFP_KERNEL); + mem = bitmap_alloc(maxbit, GFP_KERNEL); if (!mem) return -ENOMEM; spin_lock_irq(&dev->event_lock); spin_lock(&client->buffer_lock); - memcpy(mem, bits, len); + bitmap_copy(mem, bits, maxbit); spin_unlock(&dev->event_lock); @@ -947,7 +945,7 @@ static int evdev_handle_get_val(struct evdev_client *client, if (ret < 0) evdev_queue_syn_dropped(client); - kfree(mem); + bitmap_free(mem); return ret; } @@ -1003,13 +1001,13 @@ static int evdev_set_mask(struct evdev_client *client, if (!cnt) return 0; - mask = kcalloc(sizeof(unsigned long), BITS_TO_LONGS(cnt), GFP_KERNEL); + mask = bitmap_zalloc(cnt, GFP_KERNEL); if (!mask) return -ENOMEM; error = bits_from_user(mask, cnt - 1, codes_size, codes, compat); if (error < 0) { - kfree(mask); + bitmap_free(mask); return error; } @@ -1018,7 +1016,7 @@ static int evdev_set_mask(struct evdev_client *client, client->evmasks[type] = mask; spin_unlock_irqrestore(&client->buffer_lock, flags); - kfree(oldmask); + bitmap_free(oldmask); return 0; } -- 2.17.1