Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jan 2016 20:22:55 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r293350 - in head/sys/cam: ctl scsi
Message-ID:  <201601072022.u07KMtxs031973@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Jan  7 20:22:55 2016
New Revision: 293350
URL: https://svnweb.freebsd.org/changeset/base/293350

Log:
  Convert sys/cam to use make_dev_s().
  
  Reviewed by:	hps, jhb
  Sponsored by:	The FreeBSD Foundation
  MFC after:	3 weeks
  Differential revision:	https://reviews.freebsd.org/D4746

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/scsi/scsi_ch.c
  head/sys/cam/scsi/scsi_enc.c
  head/sys/cam/scsi/scsi_pass.c
  head/sys/cam/scsi/scsi_pt.c
  head/sys/cam/scsi/scsi_sa.c
  head/sys/cam/scsi/scsi_sg.c

Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/ctl/ctl.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -1778,6 +1778,7 @@ ctl_ha_role_sysctl(SYSCTL_HANDLER_ARGS)
 static int
 ctl_init(void)
 {
+	struct make_dev_args args;
 	struct ctl_softc *softc;
 	void *other_pool;
 	int i, error;
@@ -1785,9 +1786,17 @@ ctl_init(void)
 	softc = control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
 			       M_WAITOK | M_ZERO);
 
-	softc->dev = make_dev(&ctl_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600,
-			      "cam/ctl");
-	softc->dev->si_drv1 = softc;
+	make_dev_args_init(&args);
+	args.mda_devsw = &ctl_cdevsw;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0600;
+	args.mda_si_drv1 = softc;
+	error = make_dev_s(&args, &softc->dev, "cam/ctl");
+	if (error != 0) {
+		free(control_softc, M_DEVBUF);
+		return (error);
+	}
 
 	sysctl_ctx_init(&softc->sysctl_ctx);
 	softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx,

Modified: head/sys/cam/scsi/scsi_ch.c
==============================================================================
--- head/sys/cam/scsi/scsi_ch.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/scsi/scsi_ch.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -372,6 +372,8 @@ chregister(struct cam_periph *periph, vo
 	struct ch_softc *softc;
 	struct ccb_getdev *cgd;
 	struct ccb_pathinq cpi;
+	struct make_dev_args args;
+	int error;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
@@ -431,11 +433,20 @@ chregister(struct cam_periph *periph, vo
 
 
 	/* Register the device */
-	softc->dev = make_dev(&ch_cdevsw, periph->unit_number, UID_ROOT,
-			      GID_OPERATOR, 0600, "%s%d", periph->periph_name,
-			      periph->unit_number);
+	make_dev_args_init(&args);
+	args.mda_devsw = &ch_cdevsw;
+	args.mda_unit = periph->unit_number;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0600;
+	args.mda_si_drv1 = periph;
+	error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name,
+	    periph->unit_number);
 	cam_periph_lock(periph);
-	softc->dev->si_drv1 = periph;
+	if (error != 0) {
+		cam_periph_release_locked(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 
 	/*
 	 * Add an async callback so that we get
@@ -507,8 +518,6 @@ chclose(struct cdev *dev, int flag, int 
 	struct mtx *mtx;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return(ENXIO);
 	mtx = cam_periph_mtx(periph);
 	mtx_lock(mtx);
 
@@ -754,9 +763,6 @@ chioctl(struct cdev *dev, u_long cmd, ca
 	int error;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return(ENXIO);
-
 	cam_periph_lock(periph);
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering chioctl\n"));
 

Modified: head/sys/cam/scsi/scsi_enc.c
==============================================================================
--- head/sys/cam/scsi/scsi_enc.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/scsi/scsi_enc.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -264,10 +264,6 @@ enc_open(struct cdev *dev, int flags, in
 	int error = 0;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL) {
-		return (ENXIO);
-	}
-
 	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
 		return (ENXIO);
 
@@ -302,8 +298,6 @@ enc_close(struct cdev *dev, int flag, in
 	struct mtx *mtx;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
 	mtx = cam_periph_mtx(periph);
 	mtx_lock(mtx);
 
@@ -364,9 +358,6 @@ enc_ioctl(struct cdev *dev, u_long cmd, 
 		addr = NULL;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
-
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering encioctl\n"));
 
 	cam_periph_lock(periph);
@@ -905,6 +896,7 @@ enc_ctor(struct cam_periph *periph, void
 	enc_softc_t *enc;
 	struct ccb_getdev *cgd;
 	char *tname;
+	struct make_dev_args args;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
@@ -987,12 +979,20 @@ enc_ctor(struct cam_periph *periph, void
 		return (CAM_REQ_CMP_ERR);
 	}
 
-	enc->enc_dev = make_dev(&enc_cdevsw, periph->unit_number,
-	    UID_ROOT, GID_OPERATOR, 0600, "%s%d",
-	    periph->periph_name, periph->unit_number);
-
+	make_dev_args_init(&args);
+	args.mda_devsw = &enc_cdevsw;
+	args.mda_unit = periph->unit_number;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0600;
+	args.mda_si_drv1 = periph;
+	err = make_dev_s(&args, &enc->enc_dev, "%s%d", periph->periph_name,
+	    periph->unit_number);
 	cam_periph_lock(periph);
-	enc->enc_dev->si_drv1 = periph;
+	if (err != 0) {
+		cam_periph_release_locked(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 
 	enc->enc_flags |= ENC_FLAG_INITIALIZED;
 

Modified: head/sys/cam/scsi/scsi_pass.c
==============================================================================
--- head/sys/cam/scsi/scsi_pass.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/scsi/scsi_pass.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -548,7 +548,8 @@ passregister(struct cam_periph *periph, 
 	struct pass_softc *softc;
 	struct ccb_getdev *cgd;
 	struct ccb_pathinq cpi;
-	int    no_tags;
+	struct make_dev_args args;
+	int error, no_tags;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
@@ -648,9 +649,20 @@ passregister(struct cam_periph *periph, 
 	}
 
 	/* Register the device */
-	softc->dev = make_dev(&pass_cdevsw, periph->unit_number,
-			      UID_ROOT, GID_OPERATOR, 0600, "%s%d",
-			      periph->periph_name, periph->unit_number);
+	make_dev_args_init(&args);
+	args.mda_devsw = &pass_cdevsw;
+	args.mda_unit = periph->unit_number;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0600;
+	args.mda_si_drv1 = periph;
+	error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name,
+	    periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		cam_periph_release_locked(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 
 	/*
 	 * Hold a reference to the periph before we create the physical
@@ -664,7 +676,6 @@ passregister(struct cam_periph *periph, 
 	}
 
 	cam_periph_lock(periph);
-	softc->dev->si_drv1 = periph;
 
 	TASK_INIT(&softc->add_physpath_task, /*priority*/0,
 		  pass_add_physpath, periph);
@@ -754,8 +765,6 @@ passclose(struct cdev *dev, int flag, in
 	struct mtx *mtx;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);	
 	mtx = cam_periph_mtx(periph);
 	mtx_lock(mtx);
 
@@ -1759,9 +1768,6 @@ passdoioctl(struct cdev *dev, u_long cmd
 	uint32_t priority;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return(ENXIO);
-
 	cam_periph_lock(periph);
 	softc = (struct pass_softc *)periph->softc;
 
@@ -2068,9 +2074,6 @@ passpoll(struct cdev *dev, int poll_even
 	int revents;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
-
 	softc = (struct pass_softc *)periph->softc;
 
 	revents = poll_events & (POLLOUT | POLLWRNORM);
@@ -2095,9 +2098,6 @@ passkqfilter(struct cdev *dev, struct kn
 	struct pass_softc *softc;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
-
 	softc = (struct pass_softc *)periph->softc;
 
 	kn->kn_hook = (caddr_t)periph;

Modified: head/sys/cam/scsi/scsi_pt.c
==============================================================================
--- head/sys/cam/scsi/scsi_pt.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/scsi/scsi_pt.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -173,9 +173,6 @@ ptclose(struct cdev *dev, int flag, int 
 	struct	pt_softc *softc;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);	
-
 	softc = (struct pt_softc *)periph->softc;
 
 	cam_periph_lock(periph);
@@ -252,6 +249,8 @@ ptctor(struct cam_periph *periph, void *
 	struct pt_softc *softc;
 	struct ccb_getdev *cgd;
 	struct ccb_pathinq cpi;
+	struct make_dev_args args;
+	int error;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
@@ -282,6 +281,21 @@ ptctor(struct cam_periph *periph, void *
 	xpt_action((union ccb *)&cpi);
 
 	cam_periph_unlock(periph);
+
+	make_dev_args_init(&args);
+	args.mda_devsw = &pt_cdevsw;
+	args.mda_unit = periph->unit_number;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0600;
+	args.mda_si_drv1 = periph;
+	error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name,
+	    periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
+
 	softc->device_stats = devstat_new_entry("pt",
 			  periph->unit_number, 0,
 			  DEVSTAT_NO_BLOCKSIZE,
@@ -289,11 +303,7 @@ ptctor(struct cam_periph *periph, void *
 			  XPORT_DEVSTAT_TYPE(cpi.transport),
 			  DEVSTAT_PRIORITY_OTHER);
 
-	softc->dev = make_dev(&pt_cdevsw, periph->unit_number, UID_ROOT,
-			      GID_OPERATOR, 0600, "%s%d", periph->periph_name,
-			      periph->unit_number);
 	cam_periph_lock(periph);
-	softc->dev->si_drv1 = periph;
 
 	/*
 	 * Add async callbacks for bus reset and
@@ -571,9 +581,6 @@ ptioctl(struct cdev *dev, u_long cmd, ca
 	int error = 0;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return(ENXIO);
-
 	softc = (struct pt_softc *)periph->softc;
 
 	cam_periph_lock(periph);

Modified: head/sys/cam/scsi/scsi_sa.c
==============================================================================
--- head/sys/cam/scsi/scsi_sa.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/scsi/scsi_sa.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -731,9 +731,6 @@ saclose(struct cdev *dev, int flag, int 
 
 	mode = SAMODE(dev);
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);	
-
 	cam_periph_lock(periph);
 
 	softc = (struct sa_softc *)periph->softc;
@@ -906,10 +903,6 @@ sastrategy(struct bio *bp)
 		return;
 	}
 	periph = (struct cam_periph *)bp->bio_dev->si_drv1;
-	if (periph == NULL) {
-		biofinish(bp, NULL, ENXIO);
-		return;
-	}
 	cam_periph_lock(periph);
 
 	softc = (struct sa_softc *)periph->softc;
@@ -1517,9 +1510,6 @@ saioctl(struct cdev *dev, u_long cmd, ca
 	spaceop = 0;		/* shut up gcc */
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);	
-
 	cam_periph_lock(periph);
 	softc = (struct sa_softc *)periph->softc;
 
@@ -2285,7 +2275,7 @@ saasync(void *callback_arg, u_int32_t co
 static void
 sasetupdev(struct sa_softc *softc, struct cdev *dev)
 {
-	dev->si_drv1 = softc->periph;
+
 	dev->si_iosize_max = softc->maxio;
 	dev->si_flags |= softc->si_flags;
 	/*
@@ -2347,8 +2337,10 @@ saregister(struct cam_periph *periph, vo
 	struct sa_softc *softc;
 	struct ccb_getdev *cgd;
 	struct ccb_pathinq cpi;
+	struct make_dev_args args;
 	caddr_t match;
 	char tmpstr[80];
+	int error;
 	
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
@@ -2506,25 +2498,48 @@ saregister(struct cam_periph *periph, vo
 		return (CAM_REQ_CMP_ERR);
 	}
 
-	softc->devs.ctl_dev = make_dev(&sa_cdevsw, SAMINOR(SA_CTLDEV,
-	    SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
-	    0660, "%s%d.ctl", periph->periph_name, periph->unit_number);
+	make_dev_args_init(&args);
+	args.mda_devsw = &sa_cdevsw;
+	args.mda_si_drv1 = softc->periph;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0660;
+
+	args.mda_unit = SAMINOR(SA_CTLDEV, SA_ATYPE_R);
+	error = make_dev_s(&args, &softc->devs.ctl_dev, "%s%d.ctl",
+	    periph->periph_name, periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 	sasetupdev(softc, softc->devs.ctl_dev);
 
-	softc->devs.r_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV,
-	    SA_ATYPE_R), UID_ROOT, GID_OPERATOR,
-	    0660, "%s%d", periph->periph_name, periph->unit_number);
+	args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_R);
+	error = make_dev_s(&args, &softc->devs.r_dev, "%s%d",
+	    periph->periph_name, periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 	sasetupdev(softc, softc->devs.r_dev);
 
-	softc->devs.nr_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV,
-	    SA_ATYPE_NR), UID_ROOT, GID_OPERATOR,
-	    0660, "n%s%d", periph->periph_name, periph->unit_number);
+	args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_NR);
+	error = make_dev_s(&args, &softc->devs.nr_dev, "n%s%d",
+	    periph->periph_name, periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 	sasetupdev(softc, softc->devs.nr_dev);
 
-	softc->devs.er_dev = make_dev(&sa_cdevsw, SAMINOR(SA_NOT_CTLDEV,
-	    SA_ATYPE_ER), UID_ROOT, GID_OPERATOR,
-	    0660, "e%s%d", periph->periph_name, periph->unit_number);
-	sasetupdev(softc,  softc->devs.er_dev);
+	args.mda_unit = SAMINOR(SA_NOT_CTLDEV, SA_ATYPE_ER);
+	error = make_dev_s(&args, &softc->devs.er_dev, "e%s%d",
+	    periph->periph_name, periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
+	sasetupdev(softc, softc->devs.er_dev);
 
 	cam_periph_lock(periph);
 

Modified: head/sys/cam/scsi/scsi_sg.c
==============================================================================
--- head/sys/cam/scsi/scsi_sg.c	Thu Jan  7 20:15:09 2016	(r293349)
+++ head/sys/cam/scsi/scsi_sg.c	Thu Jan  7 20:22:55 2016	(r293350)
@@ -300,7 +300,8 @@ sgregister(struct cam_periph *periph, vo
 	struct sg_softc *softc;
 	struct ccb_getdev *cgd;
 	struct ccb_pathinq cpi;
-	int no_tags;
+	struct make_dev_args args;
+	int no_tags, error;
 
 	cgd = (struct ccb_getdev *)arg;
 	if (cgd == NULL) {
@@ -361,9 +362,20 @@ sgregister(struct cam_periph *periph, vo
 	}
 
 	/* Register the device */
-	softc->dev = make_dev(&sg_cdevsw, periph->unit_number,
-			      UID_ROOT, GID_OPERATOR, 0600, "%s%d",
-			      periph->periph_name, periph->unit_number);
+	make_dev_args_init(&args);
+	args.mda_devsw = &sg_cdevsw;
+	args.mda_unit = periph->unit_number;
+	args.mda_uid = UID_ROOT;
+	args.mda_gid = GID_OPERATOR;
+	args.mda_mode = 0600;
+	args.mda_si_drv1 = periph;
+	error = make_dev_s(&args, &softc->dev, "%s%d",
+	    periph->periph_name, periph->unit_number);
+	if (error != 0) {
+		cam_periph_lock(periph);
+		cam_periph_release_locked(periph);
+		return (CAM_REQ_CMP_ERR);
+	}
 	if (periph->unit_number < 26) {
 		(void)make_dev_alias(softc->dev, "sg%c",
 		    periph->unit_number + 'a');
@@ -373,7 +385,6 @@ sgregister(struct cam_periph *periph, vo
 		    (periph->unit_number % 26) + 'a');
 	}
 	cam_periph_lock(periph);
-	softc->dev->si_drv1 = periph;
 
 	/*
 	 * Add as async callback so that we get
@@ -429,9 +440,6 @@ sgopen(struct cdev *dev, int flags, int 
 	int error = 0;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
-
 	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
 		return (ENXIO);
 
@@ -468,8 +476,6 @@ sgclose(struct cdev *dev, int flag, int 
 	struct mtx *mtx;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
 	mtx = cam_periph_mtx(periph);
 	mtx_lock(mtx);
 
@@ -506,9 +512,6 @@ sgioctl(struct cdev *dev, u_long cmd, ca
 	int dir, error;
 
 	periph = (struct cam_periph *)dev->si_drv1;
-	if (periph == NULL)
-		return (ENXIO);
-
 	cam_periph_lock(periph);
 
 	softc = (struct sg_softc *)periph->softc;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601072022.u07KMtxs031973>