linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: linux-mm@kvack.org
Subject: [PATCH] zone configration check function [1/2]
Date: Tue, 20 Feb 2007 14:30:10 +0900	[thread overview]
Message-ID: <20070220143010.6caf8cd9.kamezawa.hiroyu@jp.fujitsu.com> (raw)

An idea for remove #ifdefs...

This defines not configured zones ids as ids bigger than MAX_NR_ZONES.
We can use is_cofigured_zone(zone_id) for accessing specific zones
instead of inserting #ifdefs in the middle of funcs.

(*)MAX_NR_ZONES means as it does now.

This patch is against 2.6.20.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezaw.hiroyu@jp.fujitsu.com>


Index: linux-2.6.20-devel/include/linux/mmzone.h
===================================================================
--- linux-2.6.20-devel.orig/include/linux/mmzone.h
+++ linux-2.6.20-devel/include/linux/mmzone.h
@@ -136,9 +136,23 @@ enum zone_type {
 	 */
 	ZONE_HIGHMEM,
 #endif
-	MAX_NR_ZONES
+	MAX_NR_ZONES,
+	/* Below is invalid zone ids depends on config */
+#ifndef CONFIG_ZONE_DMA32
+	ZONE_DMA32,
+#endif
+#ifndef CONFIG_ZONE_HIGHMEM
+	ZONE_HIGHMEM,
+#endif
+	ALL_POSSIBLE_ZONES
+#
 };
 
+static inline int is_configured_zone(enum zone_type id)
+{
+	return (id < MAX_NR_ZONES);
+}
+
 /*
  * When a memory allocation must conform to specific limitations (such
  * as being suitable for DMA) the caller will pass in hints to the
@@ -480,11 +494,9 @@ static inline int populated_zone(struct 
 
 static inline int is_highmem_idx(enum zone_type idx)
 {
-#ifdef CONFIG_HIGHMEM
+	if (!is_configured_zone(ZONE_HIGHMEM))
+		return 0;
 	return (idx == ZONE_HIGHMEM);
-#else
-	return 0;
-#endif
 }
 
 static inline int is_normal_idx(enum zone_type idx)
@@ -500,11 +512,9 @@ static inline int is_normal_idx(enum zon
  */
 static inline int is_highmem(struct zone *zone)
 {
-#ifdef CONFIG_HIGHMEM
+	if (!is_configured_zone(ZONE_HIGHMEM))
+		return 0;
 	return zone == zone->zone_pgdat->node_zones + ZONE_HIGHMEM;
-#else
-	return 0;
-#endif
 }
 
 static inline int is_normal(struct zone *zone)
@@ -514,11 +524,9 @@ static inline int is_normal(struct zone 
 
 static inline int is_dma32(struct zone *zone)
 {
-#ifdef CONFIG_ZONE_DMA32
+	if (!is_configured_zone(ZONE_DMA32))
+		return 0;
 	return zone == zone->zone_pgdat->node_zones + ZONE_DMA32;
-#else
-	return 0;
-#endif
 }
 
 static inline int is_dma(struct zone *zone)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2007-02-20  5:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-20  5:30 KAMEZAWA Hiroyuki [this message]
2007-02-20  5:34 ` [PATCH] remove zone ifdefs under mm/ [2/2] KAMEZAWA Hiroyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070220143010.6caf8cd9.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox