Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932115AbdC2KY0 (ORCPT ); Wed, 29 Mar 2017 06:24:26 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:30159 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755282AbdC2KYY (ORCPT ); Wed, 29 Mar 2017 06:24:24 -0400 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v2TAMQTW009564 X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Andrew Morton Cc: Masahiro Yamada , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Jessica Yu , Johannes Berg , Petr Mladek , Larry Finger , linux-kernel@vger.kernel.org, Gustavo Padovan , Rasmus Villemoes , Peter Zijlstra , Luis de Bethencourt , Josh Triplett Subject: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro Date: Wed, 29 Mar 2017 19:22:10 +0900 Message-Id: <1490782930-30429-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 870 Lines: 26 We often check if a pointer has a specific alignment. Because the '&' (bitwise AND) operator cannot take a pointer for the operand, so we need a cast like, IS_ALIGNED((unsigned long)p, a). IS_PTR_ALIGNED will be useful as a shorthand. Signed-off-by: Masahiro Yamada --- include/linux/kernel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index e5edd55..a810e4b 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -50,6 +50,7 @@ #define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) +#define IS_PTR_ALIGNED(p, a) (IS_ALIGNED((unsigned long)p, a)) /* generic data direction definitions */ #define READ 0 -- 2.7.4