@@ -427,7 +427,7 @@ static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t leng
427
427
{
428
428
int retval ;
429
429
struct agilent_82357a_priv * a_priv = board -> private_data ;
430
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
430
+ struct usb_device * usb_dev ;
431
431
u8 * out_data , * in_data ;
432
432
int out_data_length , in_data_length ;
433
433
int bytes_written , bytes_read ;
@@ -438,6 +438,10 @@ static int agilent_82357a_read(gpib_board_t *board, uint8_t *buffer, size_t leng
438
438
439
439
* nbytes = 0 ;
440
440
* end = 0 ;
441
+
442
+ if (!a_priv -> bus_interface )
443
+ return - ENODEV ;
444
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
441
445
out_data_length = 0x9 ;
442
446
out_data = kmalloc (out_data_length , GFP_KERNEL );
443
447
if (!out_data )
@@ -534,7 +538,7 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
534
538
{
535
539
int retval ;
536
540
struct agilent_82357a_priv * a_priv = board -> private_data ;
537
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
541
+ struct usb_device * usb_dev ;
538
542
u8 * out_data = NULL ;
539
543
u8 * status_data = NULL ;
540
544
int out_data_length ;
@@ -545,6 +549,10 @@ static ssize_t agilent_82357a_generic_write(gpib_board_t *board, uint8_t *buffer
545
549
struct agilent_82357a_register_pairlet read_reg ;
546
550
547
551
* bytes_written = 0 ;
552
+ if (!a_priv -> bus_interface )
553
+ return - ENODEV ;
554
+
555
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
548
556
out_data_length = length + 0x8 ;
549
557
out_data = kmalloc (out_data_length , GFP_KERNEL );
550
558
if (!out_data )
@@ -697,9 +705,13 @@ int agilent_82357a_take_control_internal(gpib_board_t *board, int synchronous)
697
705
698
706
static int agilent_82357a_take_control (gpib_board_t * board , int synchronous )
699
707
{
708
+ struct agilent_82357a_priv * a_priv = board -> private_data ;
700
709
const int timeout = 10 ;
701
710
int i ;
702
711
712
+ if (!a_priv -> bus_interface )
713
+ return - ENODEV ;
714
+
703
715
/* It looks like the 9914 does not handle tcs properly.
704
716
* See comment above tms9914_take_control_workaround() in
705
717
* drivers/gpib/tms9914/tms9914_aux.c
@@ -723,10 +735,14 @@ static int agilent_82357a_take_control(gpib_board_t *board, int synchronous)
723
735
static int agilent_82357a_go_to_standby (gpib_board_t * board )
724
736
{
725
737
struct agilent_82357a_priv * a_priv = board -> private_data ;
726
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
738
+ struct usb_device * usb_dev ;
727
739
struct agilent_82357a_register_pairlet write ;
728
740
int retval ;
729
741
742
+ if (!a_priv -> bus_interface )
743
+ return - ENODEV ;
744
+
745
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
730
746
write .address = AUXCR ;
731
747
write .value = AUX_GTS ;
732
748
retval = agilent_82357a_write_registers (a_priv , & write , 1 );
@@ -739,11 +755,15 @@ static int agilent_82357a_go_to_standby(gpib_board_t *board)
739
755
static void agilent_82357a_request_system_control (gpib_board_t * board , int request_control )
740
756
{
741
757
struct agilent_82357a_priv * a_priv = board -> private_data ;
742
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
758
+ struct usb_device * usb_dev ;
743
759
struct agilent_82357a_register_pairlet writes [2 ];
744
760
int retval ;
745
761
int i = 0 ;
746
762
763
+ if (!a_priv -> bus_interface )
764
+ return ; // -ENODEV;
765
+
766
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
747
767
/* 82357B needs bit to be set in 9914 AUXCR register */
748
768
writes [i ].address = AUXCR ;
749
769
if (request_control ) {
@@ -767,10 +787,14 @@ static void agilent_82357a_request_system_control(gpib_board_t *board, int reque
767
787
static void agilent_82357a_interface_clear (gpib_board_t * board , int assert )
768
788
{
769
789
struct agilent_82357a_priv * a_priv = board -> private_data ;
770
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
790
+ struct usb_device * usb_dev ;
771
791
struct agilent_82357a_register_pairlet write ;
772
792
int retval ;
773
793
794
+ if (!a_priv -> bus_interface )
795
+ return ; // -ENODEV;
796
+
797
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
774
798
write .address = AUXCR ;
775
799
write .value = AUX_SIC ;
776
800
if (assert ) {
@@ -785,10 +809,14 @@ static void agilent_82357a_interface_clear(gpib_board_t *board, int assert)
785
809
static void agilent_82357a_remote_enable (gpib_board_t * board , int enable )
786
810
{
787
811
struct agilent_82357a_priv * a_priv = board -> private_data ;
788
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
812
+ struct usb_device * usb_dev ;
789
813
struct agilent_82357a_register_pairlet write ;
790
814
int retval ;
791
815
816
+ if (!a_priv -> bus_interface )
817
+ return ; //-ENODEV;
818
+
819
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
792
820
write .address = AUXCR ;
793
821
write .value = AUX_SRE ;
794
822
if (enable )
@@ -804,6 +832,8 @@ static int agilent_82357a_enable_eos(gpib_board_t *board, uint8_t eos_byte, int
804
832
{
805
833
struct agilent_82357a_priv * a_priv = board -> private_data ;
806
834
835
+ if (!a_priv -> bus_interface )
836
+ return - ENODEV ;
807
837
if (compare_8_bits == 0 )
808
838
return - EOPNOTSUPP ;
809
839
@@ -822,10 +852,13 @@ static void agilent_82357a_disable_eos(gpib_board_t *board)
822
852
static unsigned int agilent_82357a_update_status (gpib_board_t * board , unsigned int clear_mask )
823
853
{
824
854
struct agilent_82357a_priv * a_priv = board -> private_data ;
825
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
855
+ struct usb_device * usb_dev ;
826
856
struct agilent_82357a_register_pairlet address_status , bus_status ;
827
857
int retval ;
828
858
859
+ if (!a_priv -> bus_interface )
860
+ return - ENODEV ;
861
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
829
862
board -> status &= ~clear_mask ;
830
863
if (a_priv -> is_cic )
831
864
set_bit (CIC_NUM , & board -> status );
@@ -885,6 +918,9 @@ static int agilent_82357a_primary_address(gpib_board_t *board, unsigned int addr
885
918
struct agilent_82357a_register_pairlet write ;
886
919
int retval ;
887
920
921
+ if (!a_priv -> bus_interface )
922
+ return - ENODEV ;
923
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
888
924
// put primary address in address0
889
925
write .address = ADR ;
890
926
write .value = address & ADDRESS_MASK ;
@@ -906,11 +942,14 @@ static int agilent_82357a_secondary_address(gpib_board_t *board, unsigned int ad
906
942
static int agilent_82357a_parallel_poll (gpib_board_t * board , uint8_t * result )
907
943
{
908
944
struct agilent_82357a_priv * a_priv = board -> private_data ;
909
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
945
+ struct usb_device * usb_dev ;
910
946
struct agilent_82357a_register_pairlet writes [2 ];
911
947
struct agilent_82357a_register_pairlet read ;
912
948
int retval ;
913
949
950
+ if (!a_priv -> bus_interface )
951
+ return - ENODEV ;
952
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
914
953
// execute parallel poll
915
954
writes [0 ].address = AUXCR ;
916
955
writes [0 ].value = AUX_CS | AUX_RPP ;
@@ -975,11 +1014,14 @@ static void agilent_82357a_return_to_local(gpib_board_t *board)
975
1014
static int agilent_82357a_line_status (const gpib_board_t * board )
976
1015
{
977
1016
struct agilent_82357a_priv * a_priv = board -> private_data ;
978
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
1017
+ struct usb_device * usb_dev ;
979
1018
struct agilent_82357a_register_pairlet bus_status ;
980
1019
int retval ;
981
1020
int status = ValidALL ;
982
1021
1022
+ if (!a_priv -> bus_interface )
1023
+ return - ENODEV ;
1024
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
983
1025
bus_status .address = BSR ;
984
1026
retval = agilent_82357a_read_registers (a_priv , & bus_status , 1 , 0 );
985
1027
if (retval ) {
@@ -1025,10 +1067,13 @@ static unsigned short nanosec_to_fast_talker_bits(unsigned int *nanosec)
1025
1067
static unsigned int agilent_82357a_t1_delay (gpib_board_t * board , unsigned int nanosec )
1026
1068
{
1027
1069
struct agilent_82357a_priv * a_priv = board -> private_data ;
1028
- struct usb_device * usb_dev = interface_to_usbdev ( a_priv -> bus_interface ) ;
1070
+ struct usb_device * usb_dev ;
1029
1071
struct agilent_82357a_register_pairlet write ;
1030
1072
int retval ;
1031
1073
1074
+ if (!a_priv -> bus_interface )
1075
+ return - ENODEV ;
1076
+ usb_dev = interface_to_usbdev (a_priv -> bus_interface );
1032
1077
write .address = FAST_TALKER_T1 ;
1033
1078
write .value = nanosec_to_fast_talker_bits (& nanosec );
1034
1079
retval = agilent_82357a_write_registers (a_priv , & write , 1 );
0 commit comments