Re: [PATCH v5 1/3] phy: handle optional regulator for PHY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux