summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/nouveau_util.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-03-08 08:39:43 +1000
committerBen Skeggs <bskeggs@redhat.com>2011-03-14 16:31:50 +1000
commitbb9b18a390db4a15cd46bbd7472510feb7d4c168 (patch)
treec1772c7007697097c55d7396b6a1c01ad9fea397 /drivers/gpu/drm/nouveau/nouveau_util.c
parent7fa0cba2b269fa498804a89a0a1d763ea1f65015 (diff)
downloadlwn-bb9b18a390db4a15cd46bbd7472510feb7d4c168.tar.gz
lwn-bb9b18a390db4a15cd46bbd7472510feb7d4c168.zip
drm/nouveau: add nouveau_enum_find() util function
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_util.c')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_util.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_util.c b/drivers/gpu/drm/nouveau/nouveau_util.c
index fbe0fb13bc1e..e51b51503baa 100644
--- a/drivers/gpu/drm/nouveau/nouveau_util.c
+++ b/drivers/gpu/drm/nouveau/nouveau_util.c
@@ -47,18 +47,27 @@ nouveau_bitfield_print(const struct nouveau_bitfield *bf, u32 value)
printk(" (unknown bits 0x%08x)", value);
}
-void
-nouveau_enum_print(const struct nouveau_enum *en, u32 value)
+const struct nouveau_enum *
+nouveau_enum_find(const struct nouveau_enum *en, u32 value)
{
while (en->name) {
- if (value == en->value) {
- printk("%s", en->name);
- return;
- }
-
+ if (en->value == value)
+ return en;
en++;
}
+ return NULL;
+}
+
+void
+nouveau_enum_print(const struct nouveau_enum *en, u32 value)
+{
+ en = nouveau_enum_find(en, value);
+ if (en) {
+ printk("%s", en->name);
+ return;
+ }
+
printk("(unknown enum 0x%08x)", value);
}