scsi_pt.c (287289) | scsi_pt.c (293350) |
---|---|
1/*- 2 * Implementation of SCSI Processor Target Peripheral driver for CAM. 3 * 4 * Copyright (c) 1998 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Implementation of SCSI Processor Target Peripheral driver for CAM. 3 * 4 * Copyright (c) 1998 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 13 unchanged lines hidden (view full) --- 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_pt.c 287289 2015-08-29 11:21:20Z mav $"); | 30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_pt.c 293350 2016-01-07 20:22:55Z kib $"); |
31 32#include <sys/param.h> 33#include <sys/queue.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/types.h> 37#include <sys/bio.h> 38#include <sys/devicestat.h> --- 129 unchanged lines hidden (view full) --- 168 169static int 170ptclose(struct cdev *dev, int flag, int fmt, struct thread *td) 171{ 172 struct cam_periph *periph; 173 struct pt_softc *softc; 174 175 periph = (struct cam_periph *)dev->si_drv1; | 31 32#include <sys/param.h> 33#include <sys/queue.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/types.h> 37#include <sys/bio.h> 38#include <sys/devicestat.h> --- 129 unchanged lines hidden (view full) --- 168 169static int 170ptclose(struct cdev *dev, int flag, int fmt, struct thread *td) 171{ 172 struct cam_periph *periph; 173 struct pt_softc *softc; 174 175 periph = (struct cam_periph *)dev->si_drv1; |
176 if (periph == NULL) 177 return (ENXIO); 178 | |
179 softc = (struct pt_softc *)periph->softc; 180 181 cam_periph_lock(periph); 182 183 softc->flags &= ~PT_FLAG_OPEN; 184 cam_periph_release_locked(periph); 185 cam_periph_unlock(periph); 186 return (0); --- 60 unchanged lines hidden (view full) --- 247} 248 249static cam_status 250ptctor(struct cam_periph *periph, void *arg) 251{ 252 struct pt_softc *softc; 253 struct ccb_getdev *cgd; 254 struct ccb_pathinq cpi; | 176 softc = (struct pt_softc *)periph->softc; 177 178 cam_periph_lock(periph); 179 180 softc->flags &= ~PT_FLAG_OPEN; 181 cam_periph_release_locked(periph); 182 cam_periph_unlock(periph); 183 return (0); --- 60 unchanged lines hidden (view full) --- 244} 245 246static cam_status 247ptctor(struct cam_periph *periph, void *arg) 248{ 249 struct pt_softc *softc; 250 struct ccb_getdev *cgd; 251 struct ccb_pathinq cpi; |
252 struct make_dev_args args; 253 int error; |
|
255 256 cgd = (struct ccb_getdev *)arg; 257 if (cgd == NULL) { 258 printf("ptregister: no getdev CCB, can't register device\n"); 259 return(CAM_REQ_CMP_ERR); 260 } 261 262 softc = (struct pt_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT); --- 14 unchanged lines hidden (view full) --- 277 periph->softc = softc; 278 279 bzero(&cpi, sizeof(cpi)); 280 xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); 281 cpi.ccb_h.func_code = XPT_PATH_INQ; 282 xpt_action((union ccb *)&cpi); 283 284 cam_periph_unlock(periph); | 254 255 cgd = (struct ccb_getdev *)arg; 256 if (cgd == NULL) { 257 printf("ptregister: no getdev CCB, can't register device\n"); 258 return(CAM_REQ_CMP_ERR); 259 } 260 261 softc = (struct pt_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT); --- 14 unchanged lines hidden (view full) --- 276 periph->softc = softc; 277 278 bzero(&cpi, sizeof(cpi)); 279 xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NORMAL); 280 cpi.ccb_h.func_code = XPT_PATH_INQ; 281 xpt_action((union ccb *)&cpi); 282 283 cam_periph_unlock(periph); |
284 285 make_dev_args_init(&args); 286 args.mda_devsw = &pt_cdevsw; 287 args.mda_unit = periph->unit_number; 288 args.mda_uid = UID_ROOT; 289 args.mda_gid = GID_OPERATOR; 290 args.mda_mode = 0600; 291 args.mda_si_drv1 = periph; 292 error = make_dev_s(&args, &softc->dev, "%s%d", periph->periph_name, 293 periph->unit_number); 294 if (error != 0) { 295 cam_periph_lock(periph); 296 return (CAM_REQ_CMP_ERR); 297 } 298 |
|
285 softc->device_stats = devstat_new_entry("pt", 286 periph->unit_number, 0, 287 DEVSTAT_NO_BLOCKSIZE, 288 SID_TYPE(&cgd->inq_data) | 289 XPORT_DEVSTAT_TYPE(cpi.transport), 290 DEVSTAT_PRIORITY_OTHER); 291 | 299 softc->device_stats = devstat_new_entry("pt", 300 periph->unit_number, 0, 301 DEVSTAT_NO_BLOCKSIZE, 302 SID_TYPE(&cgd->inq_data) | 303 XPORT_DEVSTAT_TYPE(cpi.transport), 304 DEVSTAT_PRIORITY_OTHER); 305 |
292 softc->dev = make_dev(&pt_cdevsw, periph->unit_number, UID_ROOT, 293 GID_OPERATOR, 0600, "%s%d", periph->periph_name, 294 periph->unit_number); | |
295 cam_periph_lock(periph); | 306 cam_periph_lock(periph); |
296 softc->dev->si_drv1 = periph; | |
297 298 /* 299 * Add async callbacks for bus reset and 300 * bus device reset calls. I don't bother 301 * checking if this fails as, in most cases, 302 * the system will function just fine without 303 * them and the only alternative would be to 304 * not attach the device on failure. --- 261 unchanged lines hidden (view full) --- 566static int 567ptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) 568{ 569 struct cam_periph *periph; 570 struct pt_softc *softc; 571 int error = 0; 572 573 periph = (struct cam_periph *)dev->si_drv1; | 307 308 /* 309 * Add async callbacks for bus reset and 310 * bus device reset calls. I don't bother 311 * checking if this fails as, in most cases, 312 * the system will function just fine without 313 * them and the only alternative would be to 314 * not attach the device on failure. --- 261 unchanged lines hidden (view full) --- 576static int 577ptioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td) 578{ 579 struct cam_periph *periph; 580 struct pt_softc *softc; 581 int error = 0; 582 583 periph = (struct cam_periph *)dev->si_drv1; |
574 if (periph == NULL) 575 return(ENXIO); 576 | |
577 softc = (struct pt_softc *)periph->softc; 578 579 cam_periph_lock(periph); 580 581 switch(cmd) { 582 case PTIOCGETTIMEOUT: 583 if (softc->io_timeout >= 1000) 584 *(int *)addr = softc->io_timeout / 1000; --- 48 unchanged lines hidden --- | 584 softc = (struct pt_softc *)periph->softc; 585 586 cam_periph_lock(periph); 587 588 switch(cmd) { 589 case PTIOCGETTIMEOUT: 590 if (softc->io_timeout >= 1000) 591 *(int *)addr = softc->io_timeout / 1000; --- 48 unchanged lines hidden --- |