summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-07-05 13:50:05 +0000
committermav <mav@FreeBSD.org>2014-07-05 13:50:05 +0000
commitcd2bf77221bc5ca0b3bc700494ceb7267a9c276c (patch)
tree6322799d59230583999f6d5396226118408320d5
parentde8f7474ba1043a3a53977391c7d92d9a2debfa7 (diff)
downloadFreeBSD-src-cd2bf77221bc5ca0b3bc700494ceb7267a9c276c.zip
FreeBSD-src-cd2bf77221bc5ca0b3bc700494ceb7267a9c276c.tar.gz
Implement and use ctl_frontend_find().
-rw-r--r--sys/cam/ctl/ctl.c8
-rw-r--r--sys/cam/ctl/ctl_frontend.c17
-rw-r--r--sys/cam/ctl/ctl_frontend.h5
3 files changed, 23 insertions, 7 deletions
diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c
index a37dc73..126dbf2 100644
--- a/sys/cam/ctl/ctl.c
+++ b/sys/cam/ctl/ctl.c
@@ -3121,13 +3121,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
ci = (struct ctl_iscsi *)addr;
- mtx_lock(&softc->ctl_lock);
- STAILQ_FOREACH(fe, &softc->fe_list, links) {
- if (strcmp(fe->name, "iscsi") == 0)
- break;
- }
- mtx_unlock(&softc->ctl_lock);
-
+ fe = ctl_frontend_find("iscsi");
if (fe == NULL) {
ci->status = CTL_ISCSI_ERROR;
snprintf(ci->error_str, sizeof(ci->error_str),
diff --git a/sys/cam/ctl/ctl_frontend.c b/sys/cam/ctl/ctl_frontend.c
index ba57b68..a01ccf6 100644
--- a/sys/cam/ctl/ctl_frontend.c
+++ b/sys/cam/ctl/ctl_frontend.c
@@ -118,6 +118,23 @@ ctl_frontend_deregister(struct ctl_frontend *fe)
return (0);
}
+struct ctl_frontend *
+ctl_frontend_find(char *frontend_name)
+{
+ struct ctl_softc *ctl_softc = control_softc;
+ struct ctl_frontend *fe;
+
+ mtx_lock(&ctl_softc->ctl_lock);
+ STAILQ_FOREACH(fe, &ctl_softc->fe_list, links) {
+ if (strcmp(fe->name, frontend_name) == 0) {
+ mtx_unlock(&ctl_softc->ctl_lock);
+ return (fe);
+ }
+ }
+ mtx_unlock(&ctl_softc->ctl_lock);
+ return (NULL);
+}
+
int
ctl_port_register(struct ctl_port *port, int master_shelf)
{
diff --git a/sys/cam/ctl/ctl_frontend.h b/sys/cam/ctl/ctl_frontend.h
index 97fde88..3bd8fa8 100644
--- a/sys/cam/ctl/ctl_frontend.h
+++ b/sys/cam/ctl/ctl_frontend.h
@@ -259,6 +259,11 @@ int ctl_frontend_register(struct ctl_frontend *fe);
int ctl_frontend_deregister(struct ctl_frontend *fe);
/*
+ * Find the frontend by its name. Returns NULL if not found.
+ */
+struct ctl_frontend * ctl_frontend_find(char *frontend_name);
+
+/*
* This may block until resources are allocated. Called at FETD module load
* time. Returns 0 for success, non-zero for failure.
*/
OpenPOWER on IntegriCloud