Deleted Added
full compact
scsi_enc.c (291126) scsi_enc.c (293350)
1/*-
2 * Copyright (c) 2000 Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000 Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc.c 291126 2015-11-21 10:22:01Z mav $");
28__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_enc.c 293350 2016-01-07 20:22:55Z kib $");
29
30#include <sys/param.h>
31
32#include <sys/conf.h>
33#include <sys/errno.h>
34#include <sys/fcntl.h>
35#include <sys/kernel.h>
36#include <sys/kthread.h>

--- 222 unchanged lines hidden (view full) ---

259static int
260enc_open(struct cdev *dev, int flags, int fmt, struct thread *td)
261{
262 struct cam_periph *periph;
263 struct enc_softc *softc;
264 int error = 0;
265
266 periph = (struct cam_periph *)dev->si_drv1;
29
30#include <sys/param.h>
31
32#include <sys/conf.h>
33#include <sys/errno.h>
34#include <sys/fcntl.h>
35#include <sys/kernel.h>
36#include <sys/kthread.h>

--- 222 unchanged lines hidden (view full) ---

259static int
260enc_open(struct cdev *dev, int flags, int fmt, struct thread *td)
261{
262 struct cam_periph *periph;
263 struct enc_softc *softc;
264 int error = 0;
265
266 periph = (struct cam_periph *)dev->si_drv1;
267 if (periph == NULL) {
268 return (ENXIO);
269 }
270
271 if (cam_periph_acquire(periph) != CAM_REQ_CMP)
272 return (ENXIO);
273
274 cam_periph_lock(periph);
275
276 softc = (struct enc_softc *)periph->softc;
277
278 if ((softc->enc_flags & ENC_FLAG_INITIALIZED) == 0) {

--- 18 unchanged lines hidden (view full) ---

297static int
298enc_close(struct cdev *dev, int flag, int fmt, struct thread *td)
299{
300 struct cam_periph *periph;
301 struct enc_softc *enc;
302 struct mtx *mtx;
303
304 periph = (struct cam_periph *)dev->si_drv1;
267 if (cam_periph_acquire(periph) != CAM_REQ_CMP)
268 return (ENXIO);
269
270 cam_periph_lock(periph);
271
272 softc = (struct enc_softc *)periph->softc;
273
274 if ((softc->enc_flags & ENC_FLAG_INITIALIZED) == 0) {

--- 18 unchanged lines hidden (view full) ---

293static int
294enc_close(struct cdev *dev, int flag, int fmt, struct thread *td)
295{
296 struct cam_periph *periph;
297 struct enc_softc *enc;
298 struct mtx *mtx;
299
300 periph = (struct cam_periph *)dev->si_drv1;
305 if (periph == NULL)
306 return (ENXIO);
307 mtx = cam_periph_mtx(periph);
308 mtx_lock(mtx);
309
310 enc = periph->softc;
311 enc->open_count--;
312
313 cam_periph_release_locked(periph);
314

--- 44 unchanged lines hidden (view full) ---

359
360
361 if (arg_addr)
362 addr = *((caddr_t *) arg_addr);
363 else
364 addr = NULL;
365
366 periph = (struct cam_periph *)dev->si_drv1;
301 mtx = cam_periph_mtx(periph);
302 mtx_lock(mtx);
303
304 enc = periph->softc;
305 enc->open_count--;
306
307 cam_periph_release_locked(periph);
308

--- 44 unchanged lines hidden (view full) ---

353
354
355 if (arg_addr)
356 addr = *((caddr_t *) arg_addr);
357 else
358 addr = NULL;
359
360 periph = (struct cam_periph *)dev->si_drv1;
367 if (periph == NULL)
368 return (ENXIO);
369
370 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering encioctl\n"));
371
372 cam_periph_lock(periph);
373 enc = (struct enc_softc *)periph->softc;
374 cache = &enc->enc_cache;
375
376 /*
377 * Now check to see whether we're initialized or not.

--- 522 unchanged lines hidden (view full) ---

900static cam_status
901enc_ctor(struct cam_periph *periph, void *arg)
902{
903 cam_status status = CAM_REQ_CMP_ERR;
904 int err;
905 enc_softc_t *enc;
906 struct ccb_getdev *cgd;
907 char *tname;
361 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("entering encioctl\n"));
362
363 cam_periph_lock(periph);
364 enc = (struct enc_softc *)periph->softc;
365 cache = &enc->enc_cache;
366
367 /*
368 * Now check to see whether we're initialized or not.

--- 522 unchanged lines hidden (view full) ---

891static cam_status
892enc_ctor(struct cam_periph *periph, void *arg)
893{
894 cam_status status = CAM_REQ_CMP_ERR;
895 int err;
896 enc_softc_t *enc;
897 struct ccb_getdev *cgd;
898 char *tname;
899 struct make_dev_args args;
908
909 cgd = (struct ccb_getdev *)arg;
910 if (cgd == NULL) {
911 printf("enc_ctor: no getdev CCB, can't register device\n");
912 goto out;
913 }
914
915 enc = ENC_MALLOCZ(sizeof(*enc));

--- 66 unchanged lines hidden (view full) ---

982 if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
983 xpt_print(periph->path, "%s: lost periph during "
984 "registration!\n", __func__);
985 cam_periph_lock(periph);
986
987 return (CAM_REQ_CMP_ERR);
988 }
989
900
901 cgd = (struct ccb_getdev *)arg;
902 if (cgd == NULL) {
903 printf("enc_ctor: no getdev CCB, can't register device\n");
904 goto out;
905 }
906
907 enc = ENC_MALLOCZ(sizeof(*enc));

--- 66 unchanged lines hidden (view full) ---

974 if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
975 xpt_print(periph->path, "%s: lost periph during "
976 "registration!\n", __func__);
977 cam_periph_lock(periph);
978
979 return (CAM_REQ_CMP_ERR);
980 }
981
990 enc->enc_dev = make_dev(&enc_cdevsw, periph->unit_number,
991 UID_ROOT, GID_OPERATOR, 0600, "%s%d",
992 periph->periph_name, periph->unit_number);
993
982 make_dev_args_init(&args);
983 args.mda_devsw = &enc_cdevsw;
984 args.mda_unit = periph->unit_number;
985 args.mda_uid = UID_ROOT;
986 args.mda_gid = GID_OPERATOR;
987 args.mda_mode = 0600;
988 args.mda_si_drv1 = periph;
989 err = make_dev_s(&args, &enc->enc_dev, "%s%d", periph->periph_name,
990 periph->unit_number);
994 cam_periph_lock(periph);
991 cam_periph_lock(periph);
995 enc->enc_dev->si_drv1 = periph;
992 if (err != 0) {
993 cam_periph_release_locked(periph);
994 return (CAM_REQ_CMP_ERR);
995 }
996
997 enc->enc_flags |= ENC_FLAG_INITIALIZED;
998
999 /*
1000 * Add an async callback so that we get notified if this
1001 * device goes away.
1002 */
1003 xpt_register_async(AC_LOST_DEVICE, enc_async, periph, periph->path);

--- 34 unchanged lines hidden ---
996
997 enc->enc_flags |= ENC_FLAG_INITIALIZED;
998
999 /*
1000 * Add an async callback so that we get notified if this
1001 * device goes away.
1002 */
1003 xpt_register_async(AC_LOST_DEVICE, enc_async, periph, periph->path);

--- 34 unchanged lines hidden ---