diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-04-06 19:02:58 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-04-06 19:02:58 +0000 |
commit | 7ab74dac5aaddf9bb143dd1a6dab9f4d4da1c693 (patch) | |
tree | ec71a6c4b9ac1c76924dc554513658bbd73bed68 /sys/arch | |
parent | 91faea4bdcfebfac2bc59105e115b638164ddbf8 (diff) |
Provide WIDGET_ID_FOO() macros to extract parts of the ID register value,
instead of duplicating tedious mask and shift constructs MAXINT times.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sgi/sgi/ip30_machdep.c | 8 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/impact.c | 6 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/odyssey.c | 6 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/widget.h | 8 | ||||
-rw-r--r-- | sys/arch/sgi/xbow/xbow.c | 17 |
5 files changed, 23 insertions, 22 deletions
diff --git a/sys/arch/sgi/sgi/ip30_machdep.c b/sys/arch/sgi/sgi/ip30_machdep.c index 7aa438eb7a7..8a8f161a47e 100644 --- a/sys/arch/sgi/sgi/ip30_machdep.c +++ b/sys/arch/sgi/sgi/ip30_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip30_machdep.c,v 1.38 2010/03/13 21:55:30 miod Exp $ */ +/* $OpenBSD: ip30_machdep.c,v 1.39 2010/04/06 19:02:47 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -369,10 +369,8 @@ ip30_find_video() if (ip30_widget_id(0, widid, &id) != 0) continue; - vendor = (id & WIDGET_ID_VENDOR_MASK) >> - WIDGET_ID_VENDOR_SHIFT; - product = (id & WIDGET_ID_PRODUCT_MASK) >> - WIDGET_ID_PRODUCT_SHIFT; + vendor = WIDGET_ID_VENDOR(id); + product = WIDGET_ID_PRODUCT(id); if ((vendor == XBOW_VENDOR_SGI2 && product == XBOW_PRODUCT_SGI2_ODYSSEY) || diff --git a/sys/arch/sgi/xbow/impact.c b/sys/arch/sgi/xbow/impact.c index f53caede575..6976d21dc8f 100644 --- a/sys/arch/sgi/xbow/impact.c +++ b/sys/arch/sgi/xbow/impact.c @@ -1,4 +1,4 @@ -/* $OpenBSD: impact.c,v 1.4 2010/03/21 17:05:01 deraadt Exp $ */ +/* $OpenBSD: impact.c,v 1.5 2010/04/06 19:02:57 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -791,8 +791,8 @@ impact_cnprobe(int16_t nasid, int widget) if (xbow_widget_id(nasid, widget, &wid) != 0) return 0; - vendor = (wid & WIDGET_ID_VENDOR_MASK) >> WIDGET_ID_VENDOR_SHIFT; - product = (wid & WIDGET_ID_PRODUCT_MASK) >> WIDGET_ID_PRODUCT_SHIFT; + vendor = WIDGET_ID_VENDOR(wid); + product = WIDGET_ID_PRODUCT(wid); if (vendor != XBOW_VENDOR_SGI5 || product != XBOW_PRODUCT_SGI5_IMPACT) return 0; diff --git a/sys/arch/sgi/xbow/odyssey.c b/sys/arch/sgi/xbow/odyssey.c index 6c69f1ec420..f94fc104e5d 100644 --- a/sys/arch/sgi/xbow/odyssey.c +++ b/sys/arch/sgi/xbow/odyssey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: odyssey.c,v 1.3 2010/03/08 20:54:45 miod Exp $ */ +/* $OpenBSD: odyssey.c,v 1.4 2010/04/06 19:02:57 miod Exp $ */ /* * Copyright (c) 2009, 2010 Joel Sing <jsing@openbsd.org> * @@ -1082,8 +1082,8 @@ odyssey_cnprobe(int16_t nasid, int widget) if (xbow_widget_id(nasid, widget, &wid) != 0) return 0; - vendor = (wid & WIDGET_ID_VENDOR_MASK) >> WIDGET_ID_VENDOR_SHIFT; - product = (wid & WIDGET_ID_PRODUCT_MASK) >> WIDGET_ID_PRODUCT_SHIFT; + vendor = WIDGET_ID_VENDOR(wid); + product = WIDGET_ID_PRODUCT(wid); if (vendor != XBOW_VENDOR_SGI2 || product != XBOW_PRODUCT_SGI2_ODYSSEY) return 0; diff --git a/sys/arch/sgi/xbow/widget.h b/sys/arch/sgi/xbow/widget.h index fbde457d77e..c88666066e0 100644 --- a/sys/arch/sgi/xbow/widget.h +++ b/sys/arch/sgi/xbow/widget.h @@ -1,4 +1,4 @@ -/* $OpenBSD: widget.h,v 1.1 2009/11/18 19:05:53 miod Exp $ */ +/* $OpenBSD: widget.h,v 1.2 2010/04/06 19:02:57 miod Exp $ */ /* * Copyright (c) 2008 Miodrag Vallat. @@ -31,10 +31,16 @@ #define WIDGET_ID 0x0000 #define WIDGET_ID_REV_MASK 0xf0000000 #define WIDGET_ID_REV_SHIFT 28 +#define WIDGET_ID_REV(wid) \ + (((wid) & WIDGET_ID_REV_MASK) >> WIDGET_ID_REV_SHIFT) #define WIDGET_ID_PRODUCT_MASK 0x0ffff000 #define WIDGET_ID_PRODUCT_SHIFT 12 +#define WIDGET_ID_PRODUCT(wid) \ + (((wid) & WIDGET_ID_PRODUCT_MASK) >> WIDGET_ID_PRODUCT_SHIFT) #define WIDGET_ID_VENDOR_MASK 0x00000ffe #define WIDGET_ID_VENDOR_SHIFT 1 +#define WIDGET_ID_VENDOR(wid) \ + (((wid) & WIDGET_ID_VENDOR_MASK) >> WIDGET_ID_VENDOR_SHIFT) #define WIDGET_STATUS 0x0008 #define WIDGET_ERR_ADDR_UPPER 0x0010 #define WIDGET_ERR_ADDR_LOWER 0x0018 diff --git a/sys/arch/sgi/xbow/xbow.c b/sys/arch/sgi/xbow/xbow.c index 0da2196406b..61746ecd4b0 100644 --- a/sys/arch/sgi/xbow/xbow.c +++ b/sys/arch/sgi/xbow/xbow.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xbow.c,v 1.28 2010/03/21 13:50:59 miod Exp $ */ +/* $OpenBSD: xbow.c,v 1.29 2010/04/06 19:02:57 miod Exp $ */ /* * Copyright (c) 2008, 2009 Miodrag Vallat. @@ -284,16 +284,15 @@ xbowattach(struct device *parent, struct device *self, void *aux) */ if (xbow_widget_id(nasid, 0, &wid) != 0) panic("no xbow"); - vendor = (wid & WIDGET_ID_VENDOR_MASK) >> WIDGET_ID_VENDOR_SHIFT; - product = (wid & WIDGET_ID_PRODUCT_MASK) >> WIDGET_ID_PRODUCT_SHIFT; + vendor = WIDGET_ID_VENDOR(wid); + product = WIDGET_ID_PRODUCT(wid); p = xbow_identify(vendor, product); if (p == NULL) printf(": unknown xbow (vendor %x product %x)", vendor, product); else printf(": %s", p->productname); - printf(" revision %d\n", - (wid & WIDGET_ID_REV_MASK) >> WIDGET_ID_REV_SHIFT); + printf(" revision %d\n", WIDGET_ID_REV(wid)); memset(&cfg, 0, sizeof cfg); switch (sys_config.system_type) { @@ -383,11 +382,9 @@ xbow_attach_widget(struct device *self, int16_t nasid, int widget, xaa.xaa_nasid = nasid; xaa.xaa_widget = widget; - xaa.xaa_vendor = (wid & WIDGET_ID_VENDOR_MASK) >> - WIDGET_ID_VENDOR_SHIFT; - xaa.xaa_product = (wid & WIDGET_ID_PRODUCT_MASK) >> - WIDGET_ID_PRODUCT_SHIFT; - xaa.xaa_revision = (wid & WIDGET_ID_REV_MASK) >> WIDGET_ID_REV_SHIFT; + xaa.xaa_vendor = WIDGET_ID_VENDOR(wid); + xaa.xaa_product = WIDGET_ID_PRODUCT(wid); + xaa.xaa_revision = WIDGET_ID_REV(wid); xaa.xaa_iot = &bs; if (config_found_sm(self, &xaa, print, sm) == NULL) |