lpt.c (ca3d37955c7c41e64a80c97b3f1c1fa4e9ff4897) | lpt.c (6bfa9a2d66dd0e00182017d6741d44e54d0b2cca) |
---|---|
1/*- 2 * Copyright (c) 1990 William F. Jolitz, TeleMuse 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 --- 447 unchanged lines hidden (view full) --- 456 * printer -- this is just used for passing ioctls. 457 */ 458 459static int 460lptopen(struct cdev *dev, int flags, int fmt, struct thread *td) 461{ 462 int s; 463 int trys, err; | 1/*- 2 * Copyright (c) 1990 William F. Jolitz, TeleMuse 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 --- 447 unchanged lines hidden (view full) --- 456 * printer -- this is just used for passing ioctls. 457 */ 458 459static int 460lptopen(struct cdev *dev, int flags, int fmt, struct thread *td) 461{ 462 int s; 463 int trys, err; |
464 u_int unit = LPTUNIT(minor(dev)); | 464 u_int unit = LPTUNIT(dev2unit(dev)); |
465 struct lpt_data *sc = UNITOSOFTC(unit); 466 device_t lptdev = UNITODEVICE(unit); 467 device_t ppbus = device_get_parent(lptdev); 468 469 if (!sc) 470 return (ENXIO); 471 472 if (sc->sc_state) { 473 lprintf((LPT_NAME ": still open %x\n", sc->sc_state)); 474 return(EBUSY); 475 } else 476 sc->sc_state |= LPTINIT; 477 | 465 struct lpt_data *sc = UNITOSOFTC(unit); 466 device_t lptdev = UNITODEVICE(unit); 467 device_t ppbus = device_get_parent(lptdev); 468 469 if (!sc) 470 return (ENXIO); 471 472 if (sc->sc_state) { 473 lprintf((LPT_NAME ": still open %x\n", sc->sc_state)); 474 return(EBUSY); 475 } else 476 sc->sc_state |= LPTINIT; 477 |
478 sc->sc_flags = LPTFLAGS(minor(dev)); | 478 sc->sc_flags = LPTFLAGS(dev2unit(dev)); |
479 480 /* Check for open with BYPASS flag set. */ 481 if (sc->sc_flags & LP_BYPASS) { 482 sc->sc_state = OPEN; 483 return(0); 484 } 485 486 /* request the ppbus only if we don't have it already */ --- 87 unchanged lines hidden (view full) --- 574 * lptclose -- close the device, free the local line buffer. 575 * 576 * Check for interrupted write call added. 577 */ 578 579static int 580lptclose(struct cdev *dev, int flags, int fmt, struct thread *td) 581{ | 479 480 /* Check for open with BYPASS flag set. */ 481 if (sc->sc_flags & LP_BYPASS) { 482 sc->sc_state = OPEN; 483 return(0); 484 } 485 486 /* request the ppbus only if we don't have it already */ --- 87 unchanged lines hidden (view full) --- 574 * lptclose -- close the device, free the local line buffer. 575 * 576 * Check for interrupted write call added. 577 */ 578 579static int 580lptclose(struct cdev *dev, int flags, int fmt, struct thread *td) 581{ |
582 u_int unit = LPTUNIT(minor(dev)); | 582 u_int unit = LPTUNIT(dev2unit(dev)); |
583 struct lpt_data *sc = UNITOSOFTC(unit); 584 device_t lptdev = UNITODEVICE(unit); 585 device_t ppbus = device_get_parent(lptdev); 586 int err; 587 588 if(sc->sc_flags & LP_BYPASS) 589 goto end_close; 590 --- 92 unchanged lines hidden (view full) --- 683 684/* 685 * lptread --retrieve printer status in IEEE1284 NIBBLE mode 686 */ 687 688static int 689lptread(struct cdev *dev, struct uio *uio, int ioflag) 690{ | 583 struct lpt_data *sc = UNITOSOFTC(unit); 584 device_t lptdev = UNITODEVICE(unit); 585 device_t ppbus = device_get_parent(lptdev); 586 int err; 587 588 if(sc->sc_flags & LP_BYPASS) 589 goto end_close; 590 --- 92 unchanged lines hidden (view full) --- 683 684/* 685 * lptread --retrieve printer status in IEEE1284 NIBBLE mode 686 */ 687 688static int 689lptread(struct cdev *dev, struct uio *uio, int ioflag) 690{ |
691 u_int unit = LPTUNIT(minor(dev)); | 691 u_int unit = LPTUNIT(dev2unit(dev)); |
692 struct lpt_data *sc = UNITOSOFTC(unit); 693 device_t lptdev = UNITODEVICE(unit); 694 device_t ppbus = device_get_parent(lptdev); 695 int error = 0, len; 696 697 if (sc->sc_flags & LP_BYPASS) { 698 /* we can't do reads in bypass mode */ 699 return (EPERM); --- 30 unchanged lines hidden (view full) --- 730 * Flagging of interrupted write added. 731 */ 732 733static int 734lptwrite(struct cdev *dev, struct uio *uio, int ioflag) 735{ 736 register unsigned n; 737 int err; | 692 struct lpt_data *sc = UNITOSOFTC(unit); 693 device_t lptdev = UNITODEVICE(unit); 694 device_t ppbus = device_get_parent(lptdev); 695 int error = 0, len; 696 697 if (sc->sc_flags & LP_BYPASS) { 698 /* we can't do reads in bypass mode */ 699 return (EPERM); --- 30 unchanged lines hidden (view full) --- 730 * Flagging of interrupted write added. 731 */ 732 733static int 734lptwrite(struct cdev *dev, struct uio *uio, int ioflag) 735{ 736 register unsigned n; 737 int err; |
738 u_int unit = LPTUNIT(minor(dev)); | 738 u_int unit = LPTUNIT(dev2unit(dev)); |
739 struct lpt_data *sc = UNITOSOFTC(unit); 740 device_t lptdev = UNITODEVICE(unit); 741 device_t ppbus = device_get_parent(lptdev); 742 743 if(sc->sc_flags & LP_BYPASS) { 744 /* we can't do writes in bypass mode */ 745 return(EPERM); 746 } --- 150 unchanged lines hidden (view full) --- 897 splx(s); 898 return; 899} 900 901static int 902lptioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) 903{ 904 int error = 0; | 739 struct lpt_data *sc = UNITOSOFTC(unit); 740 device_t lptdev = UNITODEVICE(unit); 741 device_t ppbus = device_get_parent(lptdev); 742 743 if(sc->sc_flags & LP_BYPASS) { 744 /* we can't do writes in bypass mode */ 745 return(EPERM); 746 } --- 150 unchanged lines hidden (view full) --- 897 splx(s); 898 return; 899} 900 901static int 902lptioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) 903{ 904 int error = 0; |
905 u_int unit = LPTUNIT(minor(dev)); | 905 u_int unit = LPTUNIT(dev2unit(dev)); |
906 struct lpt_data *sc = UNITOSOFTC(unit); 907 u_char old_sc_irq; /* old printer IRQ status */ 908 909 switch (cmd) { 910 case LPT_IRQ : 911 if(sc->sc_irq & LP_HAS_IRQ) { 912 /* 913 * NOTE: --- 65 unchanged lines hidden --- | 906 struct lpt_data *sc = UNITOSOFTC(unit); 907 u_char old_sc_irq; /* old printer IRQ status */ 908 909 switch (cmd) { 910 case LPT_IRQ : 911 if(sc->sc_irq & LP_HAS_IRQ) { 912 /* 913 * NOTE: --- 65 unchanged lines hidden --- |