diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-05-10 18:35:01 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2019-05-10 18:35:01 +0000 |
commit | b58508444861ebc07852b1b0d9944a055f559c26 (patch) | |
tree | 636d62c410eea01b546905df65ed12afd710a384 /sys/dev/pci/drm | |
parent | 42e496696dfadd6a97a9195ccc347411152aa4e0 (diff) |
Fix idr_get_next() such that idr_for_each_entry() actually works.
ok jsg@
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r-- | sys/dev/pci/drm/drm_linux.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index f64e3dd4a64..88e4b9265b0 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.34 2019/04/23 11:38:55 jsg Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.35 2019/05/10 18:35:00 kettenis Exp $ */ /* * Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org> * Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org> @@ -571,15 +571,14 @@ idr_get_next(struct idr *idr, int *id) { struct idr_entry *res; - res = idr_find(idr, *id); - if (res == NULL) - res = SPLAY_MIN(idr_tree, &idr->tree); - else - res = SPLAY_NEXT(idr_tree, &idr->tree, res); - if (res == NULL) - return NULL; - *id = res->id; - return res->ptr; + SPLAY_FOREACH(res, idr_tree, &idr->tree) { + if (res->id >= *id) { + *id = res->id; + return res->ptr; + } + } + + return NULL; } int |