@@ -641,198 +641,6 @@ void parport_remove_port(struct parport *port)
641
641
}
642
642
EXPORT_SYMBOL (parport_remove_port );
643
643
644
- /**
645
- * parport_register_device - register a device on a parallel port
646
- * @port: port to which the device is attached
647
- * @name: a name to refer to the device
648
- * @pf: preemption callback
649
- * @kf: kick callback (wake-up)
650
- * @irq_func: interrupt handler
651
- * @flags: registration flags
652
- * @handle: data for callback functions
653
- *
654
- * This function, called by parallel port device drivers,
655
- * declares that a device is connected to a port, and tells the
656
- * system all it needs to know.
657
- *
658
- * The @name is allocated by the caller and must not be
659
- * deallocated until the caller calls @parport_unregister_device
660
- * for that device.
661
- *
662
- * The preemption callback function, @pf, is called when this
663
- * device driver has claimed access to the port but another
664
- * device driver wants to use it. It is given @handle as its
665
- * parameter, and should return zero if it is willing for the
666
- * system to release the port to another driver on its behalf.
667
- * If it wants to keep control of the port it should return
668
- * non-zero, and no action will be taken. It is good manners for
669
- * the driver to try to release the port at the earliest
670
- * opportunity after its preemption callback rejects a preemption
671
- * attempt. Note that if a preemption callback is happy for
672
- * preemption to go ahead, there is no need to release the port;
673
- * it is done automatically. This function may not block, as it
674
- * may be called from interrupt context. If the device driver
675
- * does not support preemption, @pf can be %NULL.
676
- *
677
- * The wake-up ("kick") callback function, @kf, is called when
678
- * the port is available to be claimed for exclusive access; that
679
- * is, parport_claim() is guaranteed to succeed when called from
680
- * inside the wake-up callback function. If the driver wants to
681
- * claim the port it should do so; otherwise, it need not take
682
- * any action. This function may not block, as it may be called
683
- * from interrupt context. If the device driver does not want to
684
- * be explicitly invited to claim the port in this way, @kf can
685
- * be %NULL.
686
- *
687
- * The interrupt handler, @irq_func, is called when an interrupt
688
- * arrives from the parallel port. Note that if a device driver
689
- * wants to use interrupts it should use parport_enable_irq(),
690
- * and can also check the irq member of the parport structure
691
- * representing the port.
692
- *
693
- * The parallel port (lowlevel) driver is the one that has called
694
- * request_irq() and whose interrupt handler is called first.
695
- * This handler does whatever needs to be done to the hardware to
696
- * acknowledge the interrupt (for PC-style ports there is nothing
697
- * special to be done). It then tells the IEEE 1284 code about
698
- * the interrupt, which may involve reacting to an IEEE 1284
699
- * event depending on the current IEEE 1284 phase. After this,
700
- * it calls @irq_func. Needless to say, @irq_func will be called
701
- * from interrupt context, and may not block.
702
- *
703
- * The %PARPORT_DEV_EXCL flag is for preventing port sharing, and
704
- * so should only be used when sharing the port with other device
705
- * drivers is impossible and would lead to incorrect behaviour.
706
- * Use it sparingly! Normally, @flags will be zero.
707
- *
708
- * This function returns a pointer to a structure that represents
709
- * the device on the port, or %NULL if there is not enough memory
710
- * to allocate space for that structure.
711
- **/
712
-
713
- struct pardevice *
714
- parport_register_device (struct parport * port , const char * name ,
715
- int (* pf )(void * ), void (* kf )(void * ),
716
- void (* irq_func )(void * ),
717
- int flags , void * handle )
718
- {
719
- struct pardevice * tmp ;
720
-
721
- if (port -> physport -> flags & PARPORT_FLAG_EXCL ) {
722
- /* An exclusive device is registered. */
723
- printk (KERN_DEBUG "%s: no more devices allowed\n" , port -> name );
724
- return NULL ;
725
- }
726
-
727
- if (flags & PARPORT_DEV_LURK ) {
728
- if (!pf || !kf ) {
729
- pr_info ("%s: refused to register lurking device (%s) without callbacks\n" ,
730
- port -> name , name );
731
- return NULL ;
732
- }
733
- }
734
-
735
- if (flags & PARPORT_DEV_EXCL ) {
736
- if (port -> physport -> devices ) {
737
- /*
738
- * If a device is already registered and this new
739
- * device wants exclusive access, then no need to
740
- * continue as we can not grant exclusive access to
741
- * this device.
742
- */
743
- pr_err ("%s: cannot grant exclusive access for device %s\n" ,
744
- port -> name , name );
745
- return NULL ;
746
- }
747
- }
748
-
749
- /*
750
- * We up our own module reference count, and that of the port
751
- * on which a device is to be registered, to ensure that
752
- * neither of us gets unloaded while we sleep in (e.g.)
753
- * kmalloc.
754
- */
755
- if (!try_module_get (port -> ops -> owner ))
756
- return NULL ;
757
-
758
- parport_get_port (port );
759
-
760
- tmp = kmalloc (sizeof (struct pardevice ), GFP_KERNEL );
761
- if (!tmp )
762
- goto out ;
763
-
764
- tmp -> state = kmalloc (sizeof (struct parport_state ), GFP_KERNEL );
765
- if (!tmp -> state )
766
- goto out_free_pardevice ;
767
-
768
- tmp -> name = name ;
769
- tmp -> port = port ;
770
- tmp -> daisy = -1 ;
771
- tmp -> preempt = pf ;
772
- tmp -> wakeup = kf ;
773
- tmp -> private = handle ;
774
- tmp -> flags = flags ;
775
- tmp -> irq_func = irq_func ;
776
- tmp -> waiting = 0 ;
777
- tmp -> timeout = 5 * HZ ;
778
- tmp -> devmodel = false;
779
-
780
- /* Chain this onto the list */
781
- tmp -> prev = NULL ;
782
- /*
783
- * This function must not run from an irq handler so we don' t need
784
- * to clear irq on the local CPU. -arca
785
- */
786
- spin_lock (& port -> physport -> pardevice_lock );
787
-
788
- if (flags & PARPORT_DEV_EXCL ) {
789
- if (port -> physport -> devices ) {
790
- spin_unlock (& port -> physport -> pardevice_lock );
791
- printk (KERN_DEBUG "%s: cannot grant exclusive access for device %s\n" ,
792
- port -> name , name );
793
- goto out_free_all ;
794
- }
795
- port -> flags |= PARPORT_FLAG_EXCL ;
796
- }
797
-
798
- tmp -> next = port -> physport -> devices ;
799
- wmb (); /*
800
- * Make sure that tmp->next is written before it's
801
- * added to the list; see comments marked 'no locking
802
- * required'
803
- */
804
- if (port -> physport -> devices )
805
- port -> physport -> devices -> prev = tmp ;
806
- port -> physport -> devices = tmp ;
807
- spin_unlock (& port -> physport -> pardevice_lock );
808
-
809
- init_waitqueue_head (& tmp -> wait_q );
810
- tmp -> timeslice = parport_default_timeslice ;
811
- tmp -> waitnext = tmp -> waitprev = NULL ;
812
-
813
- /*
814
- * This has to be run as last thing since init_state may need other
815
- * pardevice fields. -arca
816
- */
817
- port -> ops -> init_state (tmp , tmp -> state );
818
- if (!test_and_set_bit (PARPORT_DEVPROC_REGISTERED , & port -> devflags )) {
819
- port -> proc_device = tmp ;
820
- parport_device_proc_register (tmp );
821
- }
822
- return tmp ;
823
-
824
- out_free_all :
825
- kfree (tmp -> state );
826
- out_free_pardevice :
827
- kfree (tmp );
828
- out :
829
- parport_put_port (port );
830
- module_put (port -> ops -> owner );
831
-
832
- return NULL ;
833
- }
834
- EXPORT_SYMBOL (parport_register_device );
835
-
836
644
static void free_pardevice (struct device * dev )
837
645
{
838
646
struct pardevice * par_dev = to_pardevice (dev );
0 commit comments