@@ -867,11 +867,11 @@ struct fw_header {
867867} __packed ;
868868
869869/**
870- * struct fw_type_1 - a firmware block used by RTL_FW_PLA and RTL_FW_USB.
870+ * struct fw_mac - a firmware block used by RTL_FW_PLA and RTL_FW_USB.
871871 * The layout of the firmware block is:
872- * <struct fw_type_1 > + <info> + <firmware data>.
872+ * <struct fw_mac > + <info> + <firmware data>.
873873 * @fw_offset: offset of the firmware binary data. The start address of
874- * the data would be the address of struct fw_type_1 + @fw_offset.
874+ * the data would be the address of struct fw_mac + @fw_offset.
875875 * @fw_reg: the register to load the firmware. Depends on chip.
876876 * @bp_ba_addr: the register to write break point base address. Depends on
877877 * chip.
@@ -888,7 +888,7 @@ struct fw_header {
888888 * @info: additional information for debugging, and is followed by the
889889 * binary data of firmware.
890890 */
891- struct fw_type_1 {
891+ struct fw_mac {
892892 struct fw_block blk_hdr ;
893893 __le16 fw_offset ;
894894 __le16 fw_reg ;
@@ -3397,14 +3397,14 @@ static void rtl_clear_bp(struct r8152 *tp, u16 type)
33973397 ocp_write_word (tp , type , PLA_BP_BA , 0 );
33983398}
33993399
3400- static bool rtl8152_is_fw_type1_ok (struct r8152 * tp , struct fw_type_1 * type1 )
3400+ static bool rtl8152_is_fw_mac_ok (struct r8152 * tp , struct fw_mac * mac )
34013401{
34023402 u16 fw_reg , bp_ba_addr , bp_en_addr , bp_start ;
34033403 bool rc = false;
34043404 u32 length , type ;
34053405 int i , max_bp ;
34063406
3407- type = __le32_to_cpu (type1 -> blk_hdr .type );
3407+ type = __le32_to_cpu (mac -> blk_hdr .type );
34083408 if (type == RTL_FW_PLA ) {
34093409 switch (tp -> version ) {
34103410 case RTL_VER_01 :
@@ -3461,46 +3461,46 @@ static bool rtl8152_is_fw_type1_ok(struct r8152 *tp, struct fw_type_1 *type1)
34613461 goto out ;
34623462 }
34633463
3464- length = __le32_to_cpu (type1 -> blk_hdr .length );
3465- if (length < __le16_to_cpu (type1 -> fw_offset )) {
3464+ length = __le32_to_cpu (mac -> blk_hdr .length );
3465+ if (length < __le16_to_cpu (mac -> fw_offset )) {
34663466 dev_err (& tp -> intf -> dev , "invalid fw_offset\n" );
34673467 goto out ;
34683468 }
34693469
3470- length -= __le16_to_cpu (type1 -> fw_offset );
3470+ length -= __le16_to_cpu (mac -> fw_offset );
34713471 if (length < 4 || (length & 3 )) {
34723472 dev_err (& tp -> intf -> dev , "invalid block length\n" );
34733473 goto out ;
34743474 }
34753475
3476- if (__le16_to_cpu (type1 -> fw_reg ) != fw_reg ) {
3476+ if (__le16_to_cpu (mac -> fw_reg ) != fw_reg ) {
34773477 dev_err (& tp -> intf -> dev , "invalid register to load firmware\n" );
34783478 goto out ;
34793479 }
34803480
3481- if (__le16_to_cpu (type1 -> bp_ba_addr ) != bp_ba_addr ) {
3481+ if (__le16_to_cpu (mac -> bp_ba_addr ) != bp_ba_addr ) {
34823482 dev_err (& tp -> intf -> dev , "invalid base address register\n" );
34833483 goto out ;
34843484 }
34853485
3486- if (__le16_to_cpu (type1 -> bp_en_addr ) != bp_en_addr ) {
3486+ if (__le16_to_cpu (mac -> bp_en_addr ) != bp_en_addr ) {
34873487 dev_err (& tp -> intf -> dev , "invalid enabled mask register\n" );
34883488 goto out ;
34893489 }
34903490
3491- if (__le16_to_cpu (type1 -> bp_start ) != bp_start ) {
3491+ if (__le16_to_cpu (mac -> bp_start ) != bp_start ) {
34923492 dev_err (& tp -> intf -> dev ,
34933493 "invalid start register of break point\n" );
34943494 goto out ;
34953495 }
34963496
3497- if (__le16_to_cpu (type1 -> bp_num ) > max_bp ) {
3497+ if (__le16_to_cpu (mac -> bp_num ) > max_bp ) {
34983498 dev_err (& tp -> intf -> dev , "invalid break point number\n" );
34993499 goto out ;
35003500 }
35013501
3502- for (i = __le16_to_cpu (type1 -> bp_num ); i < max_bp ; i ++ ) {
3503- if (type1 -> bp [i ]) {
3502+ for (i = __le16_to_cpu (mac -> bp_num ); i < max_bp ; i ++ ) {
3503+ if (mac -> bp [i ]) {
35043504 dev_err (& tp -> intf -> dev , "unused bp%u is not zero\n" , i );
35053505 goto out ;
35063506 }
@@ -3566,7 +3566,7 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
35663566{
35673567 const struct firmware * fw = rtl_fw -> fw ;
35683568 struct fw_header * fw_hdr = (struct fw_header * )fw -> data ;
3569- struct fw_type_1 * pla = NULL , * usb = NULL ;
3569+ struct fw_mac * pla = NULL , * usb = NULL ;
35703570 long ret = - EFAULT ;
35713571 int i ;
35723572
@@ -3601,10 +3601,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
36013601 goto fail ;
36023602 }
36033603
3604- pla = (struct fw_type_1 * )block ;
3605- if (!rtl8152_is_fw_type1_ok (tp , pla )) {
3604+ pla = (struct fw_mac * )block ;
3605+ if (!rtl8152_is_fw_mac_ok (tp , pla )) {
36063606 dev_err (& tp -> intf -> dev ,
3607- "load PLA firmware failed\n" );
3607+ "check PLA firmware failed\n" );
36083608 goto fail ;
36093609 }
36103610 break ;
@@ -3615,10 +3615,10 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
36153615 goto fail ;
36163616 }
36173617
3618- usb = (struct fw_type_1 * )block ;
3619- if (!rtl8152_is_fw_type1_ok (tp , usb )) {
3618+ usb = (struct fw_mac * )block ;
3619+ if (!rtl8152_is_fw_mac_ok (tp , usb )) {
36203620 dev_err (& tp -> intf -> dev ,
3621- "load USB firmware failed\n" );
3621+ "check USB firmware failed\n" );
36223622 goto fail ;
36233623 }
36243624 break ;
@@ -3638,14 +3638,14 @@ static long rtl8152_check_firmware(struct r8152 *tp, struct rtl_fw *rtl_fw)
36383638 return ret ;
36393639}
36403640
3641- static void rtl8152_fw_type_1_apply (struct r8152 * tp , struct fw_type_1 * type1 )
3641+ static void rtl8152_fw_mac_apply (struct r8152 * tp , struct fw_mac * mac )
36423642{
36433643 u16 bp_en_addr , bp_index , type , bp_num , fw_ver_reg ;
36443644 u32 length ;
36453645 u8 * data ;
36463646 int i ;
36473647
3648- switch (__le32_to_cpu (type1 -> blk_hdr .type )) {
3648+ switch (__le32_to_cpu (mac -> blk_hdr .type )) {
36493649 case RTL_FW_PLA :
36503650 type = MCU_TYPE_PLA ;
36513651 break ;
@@ -3667,36 +3667,36 @@ static void rtl8152_fw_type_1_apply(struct r8152 *tp, struct fw_type_1 *type1)
36673667 ocp_write_word (tp , MCU_TYPE_PLA , PLA_MACDBG_POST , DEBUG_LTSSM );
36683668 }
36693669
3670- length = __le32_to_cpu (type1 -> blk_hdr .length );
3671- length -= __le16_to_cpu (type1 -> fw_offset );
3670+ length = __le32_to_cpu (mac -> blk_hdr .length );
3671+ length -= __le16_to_cpu (mac -> fw_offset );
36723672
3673- data = (u8 * )type1 ;
3674- data += __le16_to_cpu (type1 -> fw_offset );
3673+ data = (u8 * )mac ;
3674+ data += __le16_to_cpu (mac -> fw_offset );
36753675
3676- generic_ocp_write (tp , __le16_to_cpu (type1 -> fw_reg ), 0xff , length , data ,
3676+ generic_ocp_write (tp , __le16_to_cpu (mac -> fw_reg ), 0xff , length , data ,
36773677 type );
36783678
3679- ocp_write_word (tp , type , __le16_to_cpu (type1 -> bp_ba_addr ),
3680- __le16_to_cpu (type1 -> bp_ba_value ));
3679+ ocp_write_word (tp , type , __le16_to_cpu (mac -> bp_ba_addr ),
3680+ __le16_to_cpu (mac -> bp_ba_value ));
36813681
3682- bp_index = __le16_to_cpu (type1 -> bp_start );
3683- bp_num = __le16_to_cpu (type1 -> bp_num );
3682+ bp_index = __le16_to_cpu (mac -> bp_start );
3683+ bp_num = __le16_to_cpu (mac -> bp_num );
36843684 for (i = 0 ; i < bp_num ; i ++ ) {
3685- ocp_write_word (tp , type , bp_index , __le16_to_cpu (type1 -> bp [i ]));
3685+ ocp_write_word (tp , type , bp_index , __le16_to_cpu (mac -> bp [i ]));
36863686 bp_index += 2 ;
36873687 }
36883688
3689- bp_en_addr = __le16_to_cpu (type1 -> bp_en_addr );
3689+ bp_en_addr = __le16_to_cpu (mac -> bp_en_addr );
36903690 if (bp_en_addr )
36913691 ocp_write_word (tp , type , bp_en_addr ,
3692- __le16_to_cpu (type1 -> bp_en_value ));
3692+ __le16_to_cpu (mac -> bp_en_value ));
36933693
3694- fw_ver_reg = __le16_to_cpu (type1 -> fw_ver_reg );
3694+ fw_ver_reg = __le16_to_cpu (mac -> fw_ver_reg );
36953695 if (fw_ver_reg )
36963696 ocp_write_byte (tp , MCU_TYPE_USB , fw_ver_reg ,
3697- type1 -> fw_ver_data );
3697+ mac -> fw_ver_data );
36983698
3699- dev_dbg (& tp -> intf -> dev , "successfully applied %s\n" , type1 -> info );
3699+ dev_dbg (& tp -> intf -> dev , "successfully applied %s\n" , mac -> info );
37003700}
37013701
37023702static void rtl8152_apply_firmware (struct r8152 * tp )
@@ -3720,7 +3720,7 @@ static void rtl8152_apply_firmware(struct r8152 *tp)
37203720 goto post_fw ;
37213721 case RTL_FW_PLA :
37223722 case RTL_FW_USB :
3723- rtl8152_fw_type_1_apply (tp , (struct fw_type_1 * )block );
3723+ rtl8152_fw_mac_apply (tp , (struct fw_mac * )block );
37243724 break ;
37253725 default :
37263726 break ;
0 commit comments