From patchwork Wed Jan 27 14:47:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 8134681 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 04CADBEEE5 for ; Wed, 27 Jan 2016 14:48:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1DF720274 for ; Wed, 27 Jan 2016 14:48:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8AD462037C for ; Wed, 27 Jan 2016 14:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933155AbcA0OsP (ORCPT ); Wed, 27 Jan 2016 09:48:15 -0500 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:57426 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932913AbcA0OsO (ORCPT ); Wed, 27 Jan 2016 09:48:14 -0500 Received: from lanttu.localdomain (unknown [192.168.15.166]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id D1D98600AB for ; Wed, 27 Jan 2016 16:48:11 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [PATCH v2 1/5] media: Use all bits of an enumeration Date: Wed, 27 Jan 2016 16:47:54 +0200 Message-Id: <1453906078-29087-2-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453906078-29087-1-git-send-email-sakari.ailus@iki.fi> References: <1453906078-29087-1-git-send-email-sakari.ailus@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The allocation takes place in longs. Assign the size of the enum accordingly. Signed-off-by: Sakari Ailus --- drivers/media/media-entity.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index e89d85a..2c579f4 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -73,8 +73,9 @@ static inline const char *intf_type(struct media_interface *intf) __must_check int __media_entity_enum_init(struct media_entity_enum *ent_enum, int idx_max) { - ent_enum->bmap = kcalloc(DIV_ROUND_UP(idx_max, BITS_PER_LONG), - sizeof(long), GFP_KERNEL); + idx_max = ALIGN(idx_max, BITS_PER_LONG); + ent_enum->bmap = kcalloc(idx_max / BITS_PER_LONG, sizeof(long), + GFP_KERNEL); if (!ent_enum->bmap) return -ENOMEM;