lkml.org 
[lkml]   [2020]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC 09/10] misc: hisi_hikey_usb: add support for Hikey 970
On Fri, Sep 04, 2020 at 12:23:31PM +0200, Mauro Carvalho Chehab wrote:

> + regulator = devm_regulator_get_optional(&pdev->dev, "hub-vdd");
> + if (IS_ERR(regulator)) {
> + if (PTR_ERR(regulator) == -EPROBE_DEFER) {
> + dev_info(&pdev->dev,
> + "waiting for hub-vdd-supply to be probed\n");
> + return PTR_ERR(regulator);
> + }
> +
> + /* let it fall back to regulator dummy */
> + regulator = devm_regulator_get(&pdev->dev, "hub-vdd");
> + if (IS_ERR(regulator)) {
> + dev_err(&pdev->dev,
> + "get hub-vdd-supply failed with error %ld\n",
> + PTR_ERR(regulator));
> + return PTR_ERR(regulator);
> + }
> + }

This seems weird - if the supply is non-optional why is the code trying
with devm_regulator_get_optional()? Just use normal get directly.

> + ret = regulator_set_voltage(regulator, 3300000, 3300000);
> + if (ret)
> + dev_err(&pdev->dev, "set hub-vdd-supply voltage failed\n");

Unless the device is actively managing the voltage at runtime it should
just let the voltage be set by machine constraints, most of the time
this will do nothing. This only sets the voltage in this one place.

> + hub_reset_en_gpio = of_get_named_gpio(pdev->dev.of_node,
> + "hub_reset_en_gpio", 0);
> + if (!gpio_is_valid(hub_reset_en_gpio)) {
> + dev_err(&pdev->dev, "Failed to get a valid reset gpio\n");
> + return -ENODEV;
> + }

Why not just use devm_gpio_request() which already asks for the GPIO by
name?
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-09-04 14:24    [W:0.136 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site