Messages in this thread |  | | Date | Thu, 21 Dec 2023 10:06:50 +0100 | | From | Andrew Lunn <> | | Subject | Re: [PATCH v5 1/3] phy: handle optional regulator for PHY |
| |
> +static int > +fwnode_regulator_get_bulk_enabled(struct device *dev, > + struct fwnode_handle *fwnode, > + struct regulator_bulk_data **consumers) > +{ > + struct device_node *np; > + int ret, reg_cnt; > + > + np = to_of_node(fwnode); > + if (!np) > + return 0; > + > + reg_cnt = of_regulator_bulk_get_all(dev, np, consumers); > + if (reg_cnt < 0) { > + ret = reg_cnt; > + goto clean_consumers; > + } > + > + if (reg_cnt == 0) > + return 0;
I've not used regulators much, but i think you can combine these two into one. Its guaranteed *consumer is NULL if reg_cnt == 0. And kfree() is happy with a NULL pointer.
> + > + ret = regulator_bulk_enable(reg_cnt, *consumers); > + if (ret) > + goto clean_consumers;
I would expect this to be part of mdio_device_reset(), same as the GPIO, and reset controller, but first obviously. And parsing DT should happen in a similar place to parsing the reset GPIO and reset controller.
Andrew
|  |