@@ -146,7 +146,7 @@ static int phy_dm8806_write_reg(const struct device *dev, uint8_t phyad, uint8_t
146
146
repetition );
147
147
if (repetition >= CONFIG_PHY_DM8806_SMI_BUS_CHECK_REPETITION ) {
148
148
LOG_ERR ("Maximum number of PHY write repetition exceed." );
149
- res = ( - EIO ) ;
149
+ res = - EIO ;
150
150
}
151
151
} else {
152
152
break ;
@@ -158,7 +158,7 @@ static int phy_dm8806_write_reg(const struct device *dev, uint8_t phyad, uint8_t
158
158
} else {
159
159
if (checksum_mismatch ) {
160
160
LOG_ERR ("Wrong checksum, during PHY write procedure." );
161
- res = ( - EIO ) ;
161
+ res = - EIO ;
162
162
break ;
163
163
}
164
164
}
@@ -217,20 +217,18 @@ static int phy_dm8806_read_reg(const struct device *dev, uint8_t phyad, uint8_t
217
217
218
218
if (CONFIG_PHY_DM8806_SMI_BUS_CHECK_REPETITION > 0 ) {
219
219
repetition ++ ;
220
- if (hw_checksum != sw_checksum ) {
221
- LOG_WRN ("%d repeat of PHY read procedure due to checksum error." ,
222
- repetition );
223
- if (repetition >= CONFIG_PHY_DM8806_SMI_BUS_CHECK_REPETITION ) {
224
- LOG_ERR ("Maximum number of PHY read repetition exceed." );
225
- res = (- EIO );
226
- }
227
- } else {
220
+ if (hw_checksum == sw_checksum ) {
228
221
break ;
229
222
}
223
+ LOG_WRN ("%d repeat PHY read procedure due to checksum error." , repetition );
224
+ if (repetition >= CONFIG_PHY_DM8806_SMI_BUS_CHECK_REPETITION ) {
225
+ LOG_ERR ("Maximum number of PHY read repetition exceed." );
226
+ res = - EIO ;
227
+ }
230
228
} else {
231
229
if (hw_checksum != sw_checksum ) {
232
230
LOG_ERR ("Wrong checksum, during PHY read procedure." );
233
- res = ( - EIO ) ;
231
+ res = - EIO ;
234
232
break ;
235
233
}
236
234
}
@@ -335,14 +333,14 @@ int phy_dm8806_init_interrupt(const struct device *dev)
335
333
*/
336
334
res = mdio_read (cfg -> mdio , DM8806_INT_MASK_CTRL_PHY_ADDR , DM8806_INT_MASK_CTRL_REG_ADDR ,
337
335
& data );
338
- if (res ) {
336
+ if (res < 0 ) {
339
337
LOG_ERR ("Failed to read IRQ_LED_CONTROL, %i" , res );
340
338
return res ;
341
339
}
342
340
data |= 0x1 ;
343
341
res = mdio_write (cfg -> mdio , DM8806_INT_MASK_CTRL_PHY_ADDR , DM8806_INT_MASK_CTRL_REG_ADDR ,
344
342
data );
345
- if (res ) {
343
+ if (res < 0 ) {
346
344
LOG_ERR ("Failed to read IRQ_LED_CONTROL, %i" , res );
347
345
return res ;
348
346
}
@@ -352,14 +350,14 @@ int phy_dm8806_init_interrupt(const struct device *dev)
352
350
*/
353
351
res = mdio_read (cfg -> mdio , DM8806_WOLL_CTRL_REG_PHY_ADDR , DM8806_WOLL_CTRL_REG_REG_ADDR ,
354
352
& data );
355
- if (res ) {
353
+ if (res < 0 ) {
356
354
LOG_ERR ("Failed to read IRQ_LED_CONTROL, %i" , res );
357
355
return res ;
358
356
}
359
357
data |= 0xF ;
360
358
res = mdio_write (cfg -> mdio , DM8806_WOLL_CTRL_REG_PHY_ADDR , DM8806_WOLL_CTRL_REG_REG_ADDR ,
361
359
data );
362
- if (res ) {
360
+ if (res < 0 ) {
363
361
LOG_ERR ("Failed to read IRQ_LED_CONTROL, %i" , res );
364
362
return res ;
365
363
}
@@ -634,7 +632,7 @@ static int phy_dm8806_reg_read(const struct device *dev, uint16_t reg_addr, uint
634
632
const struct phy_dm8806_config * cfg = dev -> config ;
635
633
636
634
res = mdio_read (cfg -> mdio , cfg -> switch_addr , reg_addr , (uint16_t * )data );
637
- if (res ) {
635
+ if (res < 0 ) {
638
636
LOG_ERR ("Failed to read data from DM8806" );
639
637
return res ;
640
638
}
@@ -647,7 +645,7 @@ static int phy_dm8806_reg_write(const struct device *dev, uint16_t reg_addr, uin
647
645
const struct phy_dm8806_config * cfg = dev -> config ;
648
646
649
647
res = mdio_write (cfg -> mdio , cfg -> switch_addr , reg_addr , data );
650
- if (res ) {
648
+ if (res < 0 ) {
651
649
LOG_ERR ("Failed to write data to DM8806" );
652
650
return res ;
653
651
}
0 commit comments