Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1582017imm; Fri, 6 Jul 2018 02:46:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdWRGqWmwOXlwGFD9pEFnIXmoBE90ogN7wOSR1ExrNP0R6Vx6uh7OWBP/FdkIkeQY43aLZq X-Received: by 2002:a17:902:a989:: with SMTP id bh9-v6mr9816548plb.245.1530870392385; Fri, 06 Jul 2018 02:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530870392; cv=none; d=google.com; s=arc-20160816; b=rIdgR8HQ9/17TaPYvT+A9TRq6IlgQnfEUR5cu3ecWFQEz2de7dLLWmAsmy1s9o3bMN cTLEa3UbAZt1ncm4XAnRwWgCiAF85XlhdFndzWfwbRNXKqG+GOs/BsADNIiajPX2Ciuw XbGvCBfXNuK/kbSApS3X8fDOK5tnaQKGz9jWYvqfOVS/0qkETWhNoZLOVA+cSVcNbbZW RARn2xN/Yc3hEnEXqpleKSszlzileFsfMEc6FLRHPVeZYBIlhfrhkwHnnXoDlaIgDGsi j3NrGrcQi8xqQrsbPVUP8GlKAZB9fGDun5WUJqtMaZatvydzRBuGxHtaKv/7hn6+Sn3q Mmug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UNlIfrxmFlAGDlIXou4zeYMlDJOEl2pLJVE7R2dNEaY=; b=EpGkt48ah8ShioykQZ5WAZx7PRQ7lg5k7pWf+7R09EMqbCYxcneK1SJI2QTo4QfED5 lrCy1X+xdj8VhY1V8oYwq+09Je8Z6InB8JoPYG6rueA0ZmCO1C38XrQFwFrh9yI0gIzT 2RVY2mqZJ7V274MdyrJe9KNhvXHN390xu8zSAPanwjwPlGFYLA4rU2gdeF4znXjcfitv 9CB4tUXDogxc3iTu63oiq78mKrrNnPk1iqlRyJpYEYQ01AelhZVO3ZNjwPneNs5h7PRL 6TvEn4qaexMIUZtT1JEDAeIHoxEktLgYbvVcaMYs9IFZppkPTxKetpk2xCqU5NqBOeQm 89zA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o25-v6si8736235pfi.279.2018.07.06.02.46.17; Fri, 06 Jul 2018 02:46:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754028AbeGFJph (ORCPT + 99 others); Fri, 6 Jul 2018 05:45:37 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:63986 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753575AbeGFJpg (ORCPT ); Fri, 6 Jul 2018 05:45:36 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 12270065-1500050 for multiple; Fri, 06 Jul 2018 10:44:56 +0100 From: Chris Wilson To: linux-kernel@vger.kernel.org Cc: Chris Wilson , Jani Nikula , Andy Gospodarek , "David S . Miller" , Thomas Gleixner , Andrew Morton , Ingo Molnar Subject: [PATCH] bitops: Introduce BITS_PER_TYPE Date: Fri, 6 Jul 2018 10:44:58 +0100 Message-Id: <20180706094458.14116-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org net_dim.h has a rather useful extension to BITS_PER_BYTE to compute the number of bits in a type (BITS_PER_BYTE * sizeof(T)), so promote the macro to bitops.h, alongside BITS_PER_BYTE, for wider usage. Signed-off-by: Chris Wilson Cc: Jani Nikula Cc: Andy Gospodarek Cc: David S. Miller Cc: Thomas Gleixner Cc: Andrew Morton Cc: Ingo Molnar --- include/linux/bitops.h | 3 ++- include/linux/net_dim.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 4cac4e1a72ff..091cb17d1a9b 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -11,7 +11,8 @@ #define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) #define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) #define BITS_PER_BYTE 8 -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long)) #endif /* diff --git a/include/linux/net_dim.h b/include/linux/net_dim.h index 29ed8fd6379a..14f1734e740a 100644 --- a/include/linux/net_dim.h +++ b/include/linux/net_dim.h @@ -326,7 +326,6 @@ static inline void net_dim_sample(u16 event_ctr, } #define NET_DIM_NEVENTS 64 -#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE) #define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1)) static inline void net_dim_calc_stats(struct net_dim_sample *start, -- 2.18.0