From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756827AbbJ2IeA (ORCPT ); Thu, 29 Oct 2015 04:34:00 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:37832 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756650AbbJ2IbY (ORCPT ); Thu, 29 Oct 2015 04:31:24 -0400 X-Greylist: delayed 313 seconds by postgrey-1.27 at vger.kernel.org; Thu, 29 Oct 2015 04:31:23 EDT From: Thierry Reding To: Arnd Bergmann , Andrew Morton Cc: Greg Kroah-Hartman , Joe Perches , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] asm/sections: Add helpers to check for section data Date: Thu, 29 Oct 2015 09:26:06 +0100 Message-Id: <1446107167-7001-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thierry Reding Add a helper to check if an object (given an address and a size) is part of a section (given beginning and end addresses). For convenience, also provide a helper that performs this check for __init data using the __init_begin and __init_end limits. Signed-off-by: Thierry Reding --- include/asm-generic/sections.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index b58fd667f87b..529909090cd6 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -63,4 +63,15 @@ static inline int arch_is_kernel_data(unsigned long addr) } #endif +static inline bool section_contains(void *virt, size_t size, void *begin, + void *end) +{ + return virt >= begin && virt + size <= end; +} + +static inline bool init_section_contains(void *virt, size_t size) +{ + return section_contains(virt, size, __init_begin, __init_end); +} + #endif /* _ASM_GENERIC_SECTIONS_H_ */ -- 2.5.0