svn commit: r268287 - head/sys/cam/ctl

Alexander Motin mav at FreeBSD.org
Sat Jul 5 13:50:06 UTC 2014


Author: mav
Date: Sat Jul  5 13:50:05 2014
New Revision: 268287
URL: http://svnweb.freebsd.org/changeset/base/268287

Log:
  Implement and use ctl_frontend_find().

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_frontend.c
  head/sys/cam/ctl/ctl_frontend.h

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c	Sat Jul  5 07:15:19 2014	(r268286)
+++ head/sys/cam/ctl/ctl.c	Sat Jul  5 13:50:05 2014	(r268287)
@@ -3121,13 +3121,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 
 		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),

Modified: head/sys/cam/ctl/ctl_frontend.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend.c	Sat Jul  5 07:15:19 2014	(r268286)
+++ head/sys/cam/ctl/ctl_frontend.c	Sat Jul  5 13:50:05 2014	(r268287)
@@ -118,6 +118,23 @@ ctl_frontend_deregister(struct ctl_front
 	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)
 {

Modified: head/sys/cam/ctl/ctl_frontend.h
==============================================================================
--- head/sys/cam/ctl/ctl_frontend.h	Sat Jul  5 07:15:19 2014	(r268286)
+++ head/sys/cam/ctl/ctl_frontend.h	Sat Jul  5 13:50:05 2014	(r268287)
@@ -259,6 +259,11 @@ int ctl_frontend_register(struct ctl_fro
 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.
  */


More information about the svn-src-head mailing list