tdfx_pci.c (e42e0b86696d87a2d9ffe6e76c4b2423464cbef0) tdfx_pci.c (6bfa9a2d66dd0e00182017d6741d44e54d0b2cca)
1/*-
2 * Copyright (c) 2000-2001 by Coleman Kane <cokane@FreeBSD.org>
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

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

389static int
390tdfx_open(struct cdev *dev, int flags, int fmt, struct thread *td)
391{
392 /*
393 * The open cdev method handles open(2) calls to /dev/3dfx[n]
394 * We can pretty much allow any opening of the device.
395 */
396 struct tdfx_softc *tdfx_info = devclass_get_softc(tdfx_devclass,
1/*-
2 * Copyright (c) 2000-2001 by Coleman Kane <cokane@FreeBSD.org>
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

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

389static int
390tdfx_open(struct cdev *dev, int flags, int fmt, struct thread *td)
391{
392 /*
393 * The open cdev method handles open(2) calls to /dev/3dfx[n]
394 * We can pretty much allow any opening of the device.
395 */
396 struct tdfx_softc *tdfx_info = devclass_get_softc(tdfx_devclass,
397 UNIT(minor(dev)));
397 UNIT(dev2unit(dev)));
398 if(tdfx_info->busy != 0) return EBUSY;
399#ifdef DEBUG
400 printf("3dfx: Opened by #%d\n", td->td_proc->p_pid);
401#endif
402 /* Set the driver as busy */
403 tdfx_info->busy++;
404 return 0;
405}
406
407static int
408tdfx_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
409{
410 /*
411 * The close cdev method handles close(2) calls to /dev/3dfx[n]
412 * We'll always want to close the device when it's called.
413 */
414 struct tdfx_softc *tdfx_info = devclass_get_softc(tdfx_devclass,
398 if(tdfx_info->busy != 0) return EBUSY;
399#ifdef DEBUG
400 printf("3dfx: Opened by #%d\n", td->td_proc->p_pid);
401#endif
402 /* Set the driver as busy */
403 tdfx_info->busy++;
404 return 0;
405}
406
407static int
408tdfx_close(struct cdev *dev, int fflag, int devtype, struct thread *td)
409{
410 /*
411 * The close cdev method handles close(2) calls to /dev/3dfx[n]
412 * We'll always want to close the device when it's called.
413 */
414 struct tdfx_softc *tdfx_info = devclass_get_softc(tdfx_devclass,
415 UNIT(minor(dev)));
415 UNIT(dev2unit(dev)));
416 if(tdfx_info->busy == 0) return EBADF;
417 tdfx_info->busy = 0;
418#ifdef DEBUG
419 printf("Closed by #%d\n", td->td_proc->p_pid);
420#endif
421 return 0;
422}
423

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

430 * holds the protections requested, PROT_READ, PROT_WRITE, or both.
431 */
432
433 /**** OLD GET CONFIG ****/
434 /* struct tdfx_softc* tdfx_info; */
435
436 /* Get the configuration for our card XXX*/
437 /*tdfx_info = (struct tdfx_softc*)devclass_get_softc(tdfx_devclass,
416 if(tdfx_info->busy == 0) return EBADF;
417 tdfx_info->busy = 0;
418#ifdef DEBUG
419 printf("Closed by #%d\n", td->td_proc->p_pid);
420#endif
421 return 0;
422}
423

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

430 * holds the protections requested, PROT_READ, PROT_WRITE, or both.
431 */
432
433 /**** OLD GET CONFIG ****/
434 /* struct tdfx_softc* tdfx_info; */
435
436 /* Get the configuration for our card XXX*/
437 /*tdfx_info = (struct tdfx_softc*)devclass_get_softc(tdfx_devclass,
438 UNIT(minor(dev)));*/
438 UNIT(dev2unit(dev)));*/
439 /************************/
440
441 struct tdfx_softc* tdfx_info[2];
442
443 tdfx_info[0] = (struct tdfx_softc*)devclass_get_softc(tdfx_devclass, 0);
444
445 /* If, for some reason, its not configured, we bail out */
446 if(tdfx_info[0] == NULL) {

--- 381 unchanged lines hidden ---
439 /************************/
440
441 struct tdfx_softc* tdfx_info[2];
442
443 tdfx_info[0] = (struct tdfx_softc*)devclass_get_softc(tdfx_devclass, 0);
444
445 /* If, for some reason, its not configured, we bail out */
446 if(tdfx_info[0] == NULL) {

--- 381 unchanged lines hidden ---