struct rcar_gen2_phy_data {
        const struct phy_ops *gen2_phy_ops;
        const u32 (*select_value)[PHYS_PER_CHANNEL];
+       const u32 num_channels;
 };
 
 static int rcar_gen2_phy_init(struct phy *p)
 static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = {
        .gen2_phy_ops = &rcar_gen2_phy_ops,
        .select_value = pci_select_value,
+       .num_channels = ARRAY_SIZE(pci_select_value),
 };
 
 static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = {
        .gen2_phy_ops = &rz_g1c_phy_ops,
        .select_value = usb20_select_value,
+       .num_channels = ARRAY_SIZE(usb20_select_value),
 };
 
 static const struct of_device_id rcar_gen2_phy_match_table[] = {
                channel->selected_phy = -1;
 
                error = of_property_read_u32(np, "reg", &channel_num);
-               if (error || channel_num > 2) {
+               if (error || channel_num >= data->num_channels) {
                        dev_err(dev, "Invalid \"reg\" property\n");
                        of_node_put(np);
                        return error;