Re: [PATCH net-next 1/8] r8152: refactor r8156_init
From: Andrew Lunn
Date: Wed Sep 02 2026 - 09:11:19 EST
> -static int r8159_wait_backup_restore(struct r8152 *tp)
> +static void r8156_init(struct r8152 *tp)
> {
> - u32 ocp_data;
> + u16 data;
> + int i;
>
> - ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0);
> - if (!(ocp_data & PCUT_STATUS))
> - return 0;
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
>
> - return poll_timeout_us(ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_GPHY_CTRL),
> - ocp_data & BACKUP_RESTRORE, 200, 20000, false);
> + ocp_byte_clr_bits(tp, MCU_TYPE_USB, USB_ECM_OP, EN_ALL_SPEED);
> +
> + ocp_write_word(tp, MCU_TYPE_USB, USB_SPEED_OPTION, 0);
> +
> + ocp_word_set_bits(tp, MCU_TYPE_USB, USB_ECM_OPTION, BYPASS_MAC_RESET);
> +
> + r8153b_u1u2en(tp, false);
> +
> + for (i = 0; i < 500; i++) {
> + if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) &
> + AUTOLOAD_DONE)
> + break;
> +
> + msleep(20);
> + if (test_bit(RTL8152_INACCESSIBLE, &tp->flags))
> + return;
> + }
Please use one of the macros from iopoll.h. And return ETIMEDOUT on
error.
Andrew