Re: [PATCH 2/2] media: i2c: dw9768: Add DW9768 VCM driver

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

 



On Mon, Jul 8, 2019 at 5:13 PM <dongchun.zhu@xxxxxxxxxxxx> wrote:
>
> From: Dongchun Zhu <dongchun.zhu@xxxxxxxxxxxx>
>
> This patch adds a V4L2 sub-device driver for DW9768 lens voice coil,
> and provides control to set the desired focus.
>
> The DW9807 is a 10 bit DAC from Dongwoon, designed for linear
> control of voice coil motor.

> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2018 MediaTek Inc.
> + */

2019?

> +       if (!client->adapter)
> +               return -ENODEV;

Is it ever possible?

> +       w_buf = kzalloc(size, GFP_KERNEL);
> +       if (!w_buf)
> +               return -1;

Error code?

> +       do {
> +               ret = i2c_transfer(client->adapter, &msg, 1);

> +               if (ret != 1)
> +                       dev_err(&client->dev, "write fail, ret:%d, retry:%d\n",
> +                               ret, retry_cnt);

This is noise. And better to use positive condition.

> +               else
> +                       break;

> +               retry_cnt--;
> +       } while (retry_cnt != 0);
> +

} while (--retry_cnt);

> +       if (retry_cnt == 0)     {
> +               dev_err(&client->dev, "i2c write fail(%d)\n", ret);
> +               return -EIO;
> +       }

> +
> +       kfree(w_buf);
> +
> +       return 0;
> +}

> +static int dw9768_power_off(struct dw9768_device *dw9768_dev, bool standby)
> +{
> +       struct i2c_client *client = v4l2_get_subdevdata(&dw9768_dev->sd);
> +       int ret;
> +
> +       /*
> +        * Go to standby first as real power off my be denied by the hardware
> +        * (single power line control for both dw9768_dev and sensor).
> +        */
> +       if (standby) {
> +               dw9768_dev->standby = true;
> +               ret = dw9768_release(dw9768_dev);

> +               if (ret)

> +                       dev_err(&client->dev, "dw9768_release failed!\n");

Is it fatal or not?

> +       }

> +       ret = regulator_disable(dw9768_dev->analog_regulator);
> +       if (ret)
> +               return ret;
> +
> +       return 0;

return regulator_disable(...);

> +}

> +               dev_err(dw9768_dev->sd.dev, "%s fail error: 0x%x\n",
> +                       __func__, hdl->error);

Non-informative message.

> +static int dw9768_probe(struct i2c_client *client)
> +{
> +       struct device *dev = &client->dev;
> +       struct dw9768_device *dw9768_dev;
> +       int rval;
> +
> +       dw9768_dev = devm_kzalloc(&client->dev, sizeof(*dw9768_dev),
> +                                 GFP_KERNEL);
> +       if (!dw9768_dev)
> +               return -ENOMEM;
> +
> +       dw9768_dev->analog_regulator = devm_regulator_get(dev, "afvdd");
> +       if (IS_ERR(dw9768_dev->analog_regulator)) {

> +               dev_err(dev, "cannot get analog regulator\n");

Would be noise in case of deferred probe.

> +               return PTR_ERR(dw9768_dev->analog_regulator);
> +       }

> +err_cleanup:
> +       mutex_destroy(&dw9768_dev->power_lock);
> +       dw9768_subdev_cleanup(dw9768_dev);

> +       dev_err(dev, "Probe failed: %d\n", rval);

Noise. Device core has this already.

> +       return rval;
> +}

> +static const struct i2c_device_id dw9768_id_table[] = {
> +       { DW9768_NAME, 0 },
> +       { { 0 } }

{} is enough.

> +};
> +MODULE_DEVICE_TABLE(i2c, dw9768_id_table);
> +
> +static const struct of_device_id dw9768_of_table[] = {
> +       { .compatible = "dongwoon,dw9768" },

> +       { { 0 } }

Ditto.

> +};

-- 
With Best Regards,
Andy Shevchenko



[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