]> mj.ucw.cz Git - pciutils.git/commitdiff
Added helper macros BITS and TABLE
authorMartin Mares <mj@ucw.cz>
Sat, 23 Jan 2010 21:06:19 +0000 (22:06 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 23 Jan 2010 21:06:19 +0000 (22:06 +0100)
lspci.h

diff --git a/lspci.h b/lspci.h
index c498b7c970e64e8eb409056112877f2b88445581..e31805ab0dbe7d280385b2eb94039389757088ff 100644 (file)
--- a/lspci.h
+++ b/lspci.h
@@ -52,7 +52,11 @@ byte get_conf_byte(struct device *d, unsigned int pos);
 
 void get_subid(struct device *d, word *subvp, word *subdp);
 
 
 void get_subid(struct device *d, word *subvp, word *subdp);
 
+/* Useful macros for decoding of bits and bit fields */
+
 #define FLAG(x,y) ((x & y) ? '+' : '-')
 #define FLAG(x,y) ((x & y) ? '+' : '-')
+#define BITS(x,at,width) (((x) >> (at)) & ((1 << (width)) - 1))
+#define TABLE(tab,x,buf) ((x) < sizeof(tab)/sizeof((tab)[0]) ? (tab)[x] : (sprintf((buf), "??%d", (x)), (buf)))
 
 /* ls-vpd.c */
 
 
 /* ls-vpd.c */