Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933252AbdC2VhB (ORCPT ); Wed, 29 Mar 2017 17:37:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59232 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932686AbdC2Vg7 (ORCPT ); Wed, 29 Mar 2017 17:36:59 -0400 Date: Wed, 29 Mar 2017 14:36:56 -0700 From: Andrew Morton To: Masahiro Yamada Cc: Niklas =?ISO-8859-1?Q?S=F6derlund?= , 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: Re: [PATCH] kernel.h: add IS_PTR_ALIGNED() macro Message-Id: <20170329143656.d89a2f139316df3f39a91db9@linux-foundation.org> In-Reply-To: <1490782930-30429-1-git-send-email-yamada.masahiro@socionext.com> References: <1490782930-30429-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 846 Lines: 23 On Wed, 29 Mar 2017 19:22:10 +0900 Masahiro Yamada wrote: > 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. > > ... > > --- 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 It would be nice to see some conversions which actually use this new macro.