diff --git a/sys/dev/dkwedge/dk.c b/sys/dev/dkwedge/dk.c index 655329f93c3e..3c7312b74c98 100644 --- a/sys/dev/dkwedge/dk.c +++ b/sys/dev/dkwedge/dk.c @@ -1,4 +1,4 @@ -/* $NetBSD: dk.c,v 1.88 2016/01/15 07:48:22 mlelstv Exp $ */ +/* $NetBSD: dk.c,v 1.89 2016/04/27 02:19:12 christos Exp $ */ /*- * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.88 2016/01/15 07:48:22 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.89 2016/04/27 02:19:12 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_dkwedge.h" @@ -761,6 +761,23 @@ dkwedge_find_by_wname(const char *wname) return dv; } +device_t +dkwedge_find_by_parent(const char *name, size_t *i) +{ + rw_enter(&dkwedges_lock, RW_WRITER); + for (; *i < (size_t)ndkwedges; (*i)++) { + struct dkwedge_softc *sc; + if ((sc = dkwedges[*i]) == NULL) + continue; + if (strcmp(sc->sc_parent->dk_name, name) != 0) + continue; + rw_exit(&dkwedges_lock); + return sc->sc_dev; + } + rw_exit(&dkwedges_lock); + return NULL; +} + void dkwedge_print_wnames(void) { diff --git a/sys/sys/disk.h b/sys/sys/disk.h index 0f314a2ff040..5690d1b2c5bc 100644 --- a/sys/sys/disk.h +++ b/sys/sys/disk.h @@ -1,4 +1,4 @@ -/* $NetBSD: disk.h,v 1.66 2015/11/12 15:25:22 christos Exp $ */ +/* $NetBSD: disk.h,v 1.67 2016/04/27 02:19:12 christos Exp $ */ /*- * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc. @@ -547,9 +547,11 @@ int dkwedge_list(struct disk *, struct dkwedge_list *, struct lwp *); void dkwedge_discover(struct disk *); int dkwedge_read(struct disk *, struct vnode *, daddr_t, void *, size_t); device_t dkwedge_find_by_wname(const char *); +device_t dkwedge_find_by_parent(const char *, size_t *); const char *dkwedge_get_parent_name(dev_t); void dkwedge_print_wnames(void); device_t dkwedge_find_partition(device_t, daddr_t, uint64_t); + #endif #endif /* _SYS_DISK_H_ */