mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
cdevpriv(9): add iterator
Reviewed by: christos Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44469
This commit is contained in:
parent
15bfd7cf27
commit
d3efbe0132
2 changed files with 22 additions and 0 deletions
|
@ -177,6 +177,26 @@ devfs_set_cdevpriv(void *priv, d_priv_dtor_t *priv_dtr)
|
|||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
devfs_foreach_cdevpriv(struct cdev *dev, int (*cb)(void *data, void *arg),
|
||||
void *arg)
|
||||
{
|
||||
struct cdev_priv *cdp;
|
||||
struct cdev_privdata *p;
|
||||
int error;
|
||||
|
||||
cdp = cdev2priv(dev);
|
||||
error = 0;
|
||||
mtx_lock(&cdevpriv_mtx);
|
||||
LIST_FOREACH(p, &cdp->cdp_fdpriv, cdpd_list) {
|
||||
error = cb(p->cdpd_data, arg);
|
||||
if (error != 0)
|
||||
break;
|
||||
}
|
||||
mtx_unlock(&cdevpriv_mtx);
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
devfs_destroy_cdevpriv(struct cdev_privdata *p)
|
||||
{
|
||||
|
|
|
@ -319,6 +319,8 @@ typedef void d_priv_dtor_t(void *data);
|
|||
int devfs_get_cdevpriv(void **datap);
|
||||
int devfs_set_cdevpriv(void *priv, d_priv_dtor_t *dtr);
|
||||
void devfs_clear_cdevpriv(void);
|
||||
int devfs_foreach_cdevpriv(struct cdev *dev,
|
||||
int (*cb)(void *data, void *arg), void *arg);
|
||||
|
||||
ino_t devfs_alloc_cdp_inode(void);
|
||||
void devfs_free_cdp_inode(ino_t ino);
|
||||
|
|
Loading…
Reference in a new issue