@@ -605,8 +605,7 @@ static int detect_quirks_by_root_directory(const u32 *root_directory, unsigned i
605605 return quirks ;
606606}
607607
608- static int read_rom (struct fw_device * device ,
609- int generation , int index , u32 * data )
608+ static int read_rom (struct fw_device * device , int generation , int speed , int index , u32 * data )
610609{
611610 u64 offset = (CSR_REGISTER_BASE | CSR_CONFIG_ROM ) + index * 4 ;
612611 int i , rcode ;
@@ -617,7 +616,7 @@ static int read_rom(struct fw_device *device,
617616 for (i = 10 ; i < 100 ; i += 10 ) {
618617 rcode = fw_run_transaction (device -> card ,
619618 TCODE_READ_QUADLET_REQUEST , device -> node_id ,
620- generation , device -> max_speed , offset , data , 4 );
619+ generation , speed , offset , data , 4 );
621620 if (rcode != RCODE_BUSY )
622621 break ;
623622 msleep (i );
@@ -644,7 +643,7 @@ static int read_config_rom(struct fw_device *device, int generation)
644643 const u32 * old_rom , * new_rom ;
645644 u32 * rom , * stack ;
646645 u32 sp , key ;
647- int i , end , length , ret ;
646+ int i , end , length , ret , speed ;
648647 int quirks ;
649648
650649 rom = kmalloc (sizeof (* rom ) * MAX_CONFIG_ROM_SIZE +
@@ -655,11 +654,11 @@ static int read_config_rom(struct fw_device *device, int generation)
655654 stack = & rom [MAX_CONFIG_ROM_SIZE ];
656655 memset (rom , 0 , sizeof (* rom ) * MAX_CONFIG_ROM_SIZE );
657656
658- device -> max_speed = SCODE_100 ;
657+ speed = SCODE_100 ;
659658
660659 /* First read the bus info block. */
661660 for (i = 0 ; i < 5 ; i ++ ) {
662- ret = read_rom (device , generation , i , & rom [i ]);
661+ ret = read_rom (device , generation , speed , i , & rom [i ]);
663662 if (ret != RCODE_COMPLETE )
664663 goto out ;
665664 /*
@@ -681,7 +680,7 @@ static int read_config_rom(struct fw_device *device, int generation)
681680 // Just prevent from torn writing/reading.
682681 WRITE_ONCE (device -> quirks , quirks );
683682
684- device -> max_speed = device -> node -> max_speed ;
683+ speed = device -> node -> max_speed ;
685684
686685 /*
687686 * Determine the speed of
@@ -692,20 +691,18 @@ static int read_config_rom(struct fw_device *device, int generation)
692691 * because some buggy firmwares set it lower than necessary and because
693692 * 1394-1995 nodes do not have the field.
694693 */
695- if ((rom [2 ] & 0x7 ) < device -> max_speed ||
696- device -> max_speed == SCODE_BETA ||
697- card -> beta_repeaters_present ) {
694+ if ((rom [2 ] & 0x7 ) < speed || speed == SCODE_BETA || card -> beta_repeaters_present ) {
698695 u32 dummy ;
699696
700697 /* for S1600 and S3200 */
701- if (device -> max_speed == SCODE_BETA )
702- device -> max_speed = card -> link_speed ;
698+ if (speed == SCODE_BETA )
699+ speed = card -> link_speed ;
703700
704- while (device -> max_speed > SCODE_100 ) {
705- if (read_rom (device , generation , 0 , & dummy ) ==
701+ while (speed > SCODE_100 ) {
702+ if (read_rom (device , generation , speed , 0 , & dummy ) ==
706703 RCODE_COMPLETE )
707704 break ;
708- device -> max_speed -- ;
705+ -- speed ;
709706 }
710707 }
711708
@@ -734,7 +731,7 @@ static int read_config_rom(struct fw_device *device, int generation)
734731 }
735732
736733 /* Read header quadlet for the block to get the length. */
737- ret = read_rom (device , generation , i , & rom [i ]);
734+ ret = read_rom (device , generation , speed , i , & rom [i ]);
738735 if (ret != RCODE_COMPLETE )
739736 goto out ;
740737 end = i + (rom [i ] >> 16 ) + 1 ;
@@ -758,7 +755,7 @@ static int read_config_rom(struct fw_device *device, int generation)
758755 * it references another block, and push it in that case.
759756 */
760757 for (; i < end ; i ++ ) {
761- ret = read_rom (device , generation , i , & rom [i ]);
758+ ret = read_rom (device , generation , speed , i , & rom [i ]);
762759 if (ret != RCODE_COMPLETE )
763760 goto out ;
764761
@@ -785,6 +782,8 @@ static int read_config_rom(struct fw_device *device, int generation)
785782 length = i ;
786783 }
787784
785+ device -> max_speed = speed ;
786+
788787 quirks |= detect_quirks_by_root_directory (rom + ROOT_DIR_OFFSET , length - ROOT_DIR_OFFSET );
789788
790789 // Just prevent from torn writing/reading.
@@ -1234,7 +1233,7 @@ static int reread_config_rom(struct fw_device *device, int generation,
12341233 int i , rcode ;
12351234
12361235 for (i = 0 ; i < 6 ; i ++ ) {
1237- rcode = read_rom (device , generation , i , & q );
1236+ rcode = read_rom (device , generation , device -> max_speed , i , & q );
12381237 if (rcode != RCODE_COMPLETE )
12391238 return rcode ;
12401239
0 commit comments