All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: mark.rutland@arm.com, drinkcat@chromium.org,
	andriy.shevchenko@linux.intel.com, srv_heupstream@mediatek.com,
	devicetree@vger.kernel.org, linus.walleij@linaro.org,
	shengnan.wang@mediatek.com, tfiga@chromium.org,
	bgolaszewski@baylibre.com, sj.huang@mediatek.com,
	robh+dt@kernel.org, linux-mediatek@lists.infradead.org,
	louis.kuo@mediatek.com, matthias.bgg@gmail.com,
	bingbu.cao@intel.com, mchehab@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver
Date: Sat, 6 Jun 2020 14:24:12 +0800	[thread overview]
Message-ID: <1591424652.8804.603.camel@mhfsdcap03> (raw)
In-Reply-To: <20200605121459.GS16711@paasikivi.fi.intel.com>

Hi Sakari,

Thanks for the timely review.

On Fri, 2020-06-05 at 15:14 +0300, Sakari Ailus wrote:
> Hi Dongchun,
> 
> Thank you for the update.
> 
> On Fri, Jun 05, 2020 at 06:54:12PM +0800, Dongchun Zhu wrote:
> > Add a V4L2 sub-device driver for DW9768 voice coil motor, providing
> > control to set the desired focus via IIC serial interface.
> > 
> > Signed-off-by: Dongchun Zhu <dongchun.zhu@mediatek.com>
> > ---
> >  MAINTAINERS                |   1 +
> >  drivers/media/i2c/Kconfig  |  13 ++
> >  drivers/media/i2c/Makefile |   1 +
> >  drivers/media/i2c/dw9768.c | 566 +++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 581 insertions(+)
> >  create mode 100644 drivers/media/i2c/dw9768.c
> > 

[snip]...

> > +
> > +static int dw9768_probe(struct i2c_client *client)
> > +{
> > +	struct device *dev = &client->dev;
> > +	struct dw9768 *dw9768;
> > +	u32 aac_mode_select;
> > +	u32 aac_timing_select;
> > +	u32 clock_presc_select;
> > +	unsigned int i;
> > +	int ret;
> > +
> > +	dw9768 = devm_kzalloc(dev, sizeof(*dw9768), GFP_KERNEL);
> > +	if (!dw9768)
> > +		return -ENOMEM;
> > +
> > +	/* Initialize subdev */
> > +	v4l2_i2c_subdev_init(&dw9768->sd, client, &dw9768_ops);
> > +
> > +	dw9768->aac_mode = DW9768_AAC_MODE_DEFAULT;
> > +	dw9768->aac_timing = DW9768_AAC_TIME_DEFAULT;
> > +	dw9768->clock_presc = DW9768_CLOCK_PRE_SCALE_DEFAULT;
> > +
> > +	/* Optional indication of AAC mode select */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-mode",
> > +				       &aac_mode_select);
> > +
> > +	if (!ret)
> > +		dw9768->aac_mode = aac_mode_select;
> > +
> > +	/* Optional indication of clock pre-scale select */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,clock-presc",
> > +				       &clock_presc_select);
> > +
> > +	if (!ret)
> > +		dw9768->clock_presc = clock_presc_select;
> > +
> > +	/* Optional indication of AAC Timing */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-timing",
> > +				       &aac_timing_select);
> > +
> > +	if (!ret)
> > +		dw9768->aac_timing = aac_timing_select;
> 
> You can assign the defaults to the dw9768 struct and use the fwnode
> property API to read the properties into the same fields. No return values
> need to be checked.
> 

Good idea :-)

> > +
> > +	for (i = 0; i < ARRAY_SIZE(dw9768_supply_names); i++)
> > +		dw9768->supplies[i].supply = dw9768_supply_names[i];
> > +
> > +	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dw9768_supply_names),
> > +				      dw9768->supplies);
> > +	if (ret) {
> > +		dev_err(dev, "failed to get regulators\n");
> > +		return ret;
> > +	}
> > +
> > +	/* Initialize controls */
> > +	ret = dw9768_init_controls(dw9768);
> > +	if (ret)
> > +		goto err_free_handler;
> > +
> > +	/* Initialize subdev */
> > +	dw9768->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> > +	dw9768->sd.internal_ops = &dw9768_int_ops;
> > +
> > +	ret = media_entity_pads_init(&dw9768->sd.entity, 0, NULL);
> > +	if (ret < 0)
> > +		goto err_free_handler;
> > +
> > +	dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
> > +
> > +	pm_runtime_enable(dev);
> > +	if (!pm_runtime_enabled(dev)) {
> > +		ret = dw9768_runtime_resume(dev);
> > +		if (ret < 0) {
> > +			dev_err(dev, "failed to power on: %d\n", ret);
> > +			goto err_clean_entity;
> > +		}
> > +	}
> > +
> > +	ret = v4l2_async_register_subdev(&dw9768->sd);
> > +	if (ret < 0) {
> > +		dev_err(dev, "failed to register V4L2 subdev: %d", ret);
> > +		goto error_async_register;
> > +	}
> > +
> > +	return 0;
> > +
> > +error_async_register:
> > +	if (!pm_runtime_enabled(dev))
> > +		dw9768_runtime_suspend(dev);
> > +err_clean_entity:
> > +	media_entity_cleanup(&dw9768->sd.entity);
> > +err_free_handler:
> > +	v4l2_ctrl_handler_free(&dw9768->ctrls);
> > +
> > +	return ret;
> > +}
> > +

[snip]...

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: mark.rutland@arm.com, drinkcat@chromium.org,
	andriy.shevchenko@linux.intel.com, srv_heupstream@mediatek.com,
	devicetree@vger.kernel.org, linus.walleij@linaro.org,
	shengnan.wang@mediatek.com, tfiga@chromium.org,
	bgolaszewski@baylibre.com, sj.huang@mediatek.com,
	robh+dt@kernel.org, linux-mediatek@lists.infradead.org,
	louis.kuo@mediatek.com, matthias.bgg@gmail.com,
	bingbu.cao@intel.com, mchehab@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver
Date: Sat, 6 Jun 2020 14:24:12 +0800	[thread overview]
Message-ID: <1591424652.8804.603.camel@mhfsdcap03> (raw)
In-Reply-To: <20200605121459.GS16711@paasikivi.fi.intel.com>

Hi Sakari,

Thanks for the timely review.

On Fri, 2020-06-05 at 15:14 +0300, Sakari Ailus wrote:
> Hi Dongchun,
> 
> Thank you for the update.
> 
> On Fri, Jun 05, 2020 at 06:54:12PM +0800, Dongchun Zhu wrote:
> > Add a V4L2 sub-device driver for DW9768 voice coil motor, providing
> > control to set the desired focus via IIC serial interface.
> > 
> > Signed-off-by: Dongchun Zhu <dongchun.zhu@mediatek.com>
> > ---
> >  MAINTAINERS                |   1 +
> >  drivers/media/i2c/Kconfig  |  13 ++
> >  drivers/media/i2c/Makefile |   1 +
> >  drivers/media/i2c/dw9768.c | 566 +++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 581 insertions(+)
> >  create mode 100644 drivers/media/i2c/dw9768.c
> > 

[snip]...

> > +
> > +static int dw9768_probe(struct i2c_client *client)
> > +{
> > +	struct device *dev = &client->dev;
> > +	struct dw9768 *dw9768;
> > +	u32 aac_mode_select;
> > +	u32 aac_timing_select;
> > +	u32 clock_presc_select;
> > +	unsigned int i;
> > +	int ret;
> > +
> > +	dw9768 = devm_kzalloc(dev, sizeof(*dw9768), GFP_KERNEL);
> > +	if (!dw9768)
> > +		return -ENOMEM;
> > +
> > +	/* Initialize subdev */
> > +	v4l2_i2c_subdev_init(&dw9768->sd, client, &dw9768_ops);
> > +
> > +	dw9768->aac_mode = DW9768_AAC_MODE_DEFAULT;
> > +	dw9768->aac_timing = DW9768_AAC_TIME_DEFAULT;
> > +	dw9768->clock_presc = DW9768_CLOCK_PRE_SCALE_DEFAULT;
> > +
> > +	/* Optional indication of AAC mode select */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-mode",
> > +				       &aac_mode_select);
> > +
> > +	if (!ret)
> > +		dw9768->aac_mode = aac_mode_select;
> > +
> > +	/* Optional indication of clock pre-scale select */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,clock-presc",
> > +				       &clock_presc_select);
> > +
> > +	if (!ret)
> > +		dw9768->clock_presc = clock_presc_select;
> > +
> > +	/* Optional indication of AAC Timing */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-timing",
> > +				       &aac_timing_select);
> > +
> > +	if (!ret)
> > +		dw9768->aac_timing = aac_timing_select;
> 
> You can assign the defaults to the dw9768 struct and use the fwnode
> property API to read the properties into the same fields. No return values
> need to be checked.
> 

Good idea :-)

> > +
> > +	for (i = 0; i < ARRAY_SIZE(dw9768_supply_names); i++)
> > +		dw9768->supplies[i].supply = dw9768_supply_names[i];
> > +
> > +	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dw9768_supply_names),
> > +				      dw9768->supplies);
> > +	if (ret) {
> > +		dev_err(dev, "failed to get regulators\n");
> > +		return ret;
> > +	}
> > +
> > +	/* Initialize controls */
> > +	ret = dw9768_init_controls(dw9768);
> > +	if (ret)
> > +		goto err_free_handler;
> > +
> > +	/* Initialize subdev */
> > +	dw9768->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> > +	dw9768->sd.internal_ops = &dw9768_int_ops;
> > +
> > +	ret = media_entity_pads_init(&dw9768->sd.entity, 0, NULL);
> > +	if (ret < 0)
> > +		goto err_free_handler;
> > +
> > +	dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
> > +
> > +	pm_runtime_enable(dev);
> > +	if (!pm_runtime_enabled(dev)) {
> > +		ret = dw9768_runtime_resume(dev);
> > +		if (ret < 0) {
> > +			dev_err(dev, "failed to power on: %d\n", ret);
> > +			goto err_clean_entity;
> > +		}
> > +	}
> > +
> > +	ret = v4l2_async_register_subdev(&dw9768->sd);
> > +	if (ret < 0) {
> > +		dev_err(dev, "failed to register V4L2 subdev: %d", ret);
> > +		goto error_async_register;
> > +	}
> > +
> > +	return 0;
> > +
> > +error_async_register:
> > +	if (!pm_runtime_enabled(dev))
> > +		dw9768_runtime_suspend(dev);
> > +err_clean_entity:
> > +	media_entity_cleanup(&dw9768->sd.entity);
> > +err_free_handler:
> > +	v4l2_ctrl_handler_free(&dw9768->ctrls);
> > +
> > +	return ret;
> > +}
> > +

[snip]...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: <linus.walleij@linaro.org>, <bgolaszewski@baylibre.com>,
	<mchehab@kernel.org>, <andriy.shevchenko@linux.intel.com>,
	<robh+dt@kernel.org>, <mark.rutland@arm.com>,
	<drinkcat@chromium.org>, <tfiga@chromium.org>,
	<matthias.bgg@gmail.com>, <bingbu.cao@intel.com>,
	<srv_heupstream@mediatek.com>,
	<linux-mediatek@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>, <sj.huang@mediatek.com>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<louis.kuo@mediatek.com>, <shengnan.wang@mediatek.com>
Subject: Re: [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver
Date: Sat, 6 Jun 2020 14:24:12 +0800	[thread overview]
Message-ID: <1591424652.8804.603.camel@mhfsdcap03> (raw)
In-Reply-To: <20200605121459.GS16711@paasikivi.fi.intel.com>

Hi Sakari,

Thanks for the timely review.

On Fri, 2020-06-05 at 15:14 +0300, Sakari Ailus wrote:
> Hi Dongchun,
> 
> Thank you for the update.
> 
> On Fri, Jun 05, 2020 at 06:54:12PM +0800, Dongchun Zhu wrote:
> > Add a V4L2 sub-device driver for DW9768 voice coil motor, providing
> > control to set the desired focus via IIC serial interface.
> > 
> > Signed-off-by: Dongchun Zhu <dongchun.zhu@mediatek.com>
> > ---
> >  MAINTAINERS                |   1 +
> >  drivers/media/i2c/Kconfig  |  13 ++
> >  drivers/media/i2c/Makefile |   1 +
> >  drivers/media/i2c/dw9768.c | 566 +++++++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 581 insertions(+)
> >  create mode 100644 drivers/media/i2c/dw9768.c
> > 

[snip]...

> > +
> > +static int dw9768_probe(struct i2c_client *client)
> > +{
> > +	struct device *dev = &client->dev;
> > +	struct dw9768 *dw9768;
> > +	u32 aac_mode_select;
> > +	u32 aac_timing_select;
> > +	u32 clock_presc_select;
> > +	unsigned int i;
> > +	int ret;
> > +
> > +	dw9768 = devm_kzalloc(dev, sizeof(*dw9768), GFP_KERNEL);
> > +	if (!dw9768)
> > +		return -ENOMEM;
> > +
> > +	/* Initialize subdev */
> > +	v4l2_i2c_subdev_init(&dw9768->sd, client, &dw9768_ops);
> > +
> > +	dw9768->aac_mode = DW9768_AAC_MODE_DEFAULT;
> > +	dw9768->aac_timing = DW9768_AAC_TIME_DEFAULT;
> > +	dw9768->clock_presc = DW9768_CLOCK_PRE_SCALE_DEFAULT;
> > +
> > +	/* Optional indication of AAC mode select */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-mode",
> > +				       &aac_mode_select);
> > +
> > +	if (!ret)
> > +		dw9768->aac_mode = aac_mode_select;
> > +
> > +	/* Optional indication of clock pre-scale select */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,clock-presc",
> > +				       &clock_presc_select);
> > +
> > +	if (!ret)
> > +		dw9768->clock_presc = clock_presc_select;
> > +
> > +	/* Optional indication of AAC Timing */
> > +	ret = fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-timing",
> > +				       &aac_timing_select);
> > +
> > +	if (!ret)
> > +		dw9768->aac_timing = aac_timing_select;
> 
> You can assign the defaults to the dw9768 struct and use the fwnode
> property API to read the properties into the same fields. No return values
> need to be checked.
> 

Good idea :-)

> > +
> > +	for (i = 0; i < ARRAY_SIZE(dw9768_supply_names); i++)
> > +		dw9768->supplies[i].supply = dw9768_supply_names[i];
> > +
> > +	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dw9768_supply_names),
> > +				      dw9768->supplies);
> > +	if (ret) {
> > +		dev_err(dev, "failed to get regulators\n");
> > +		return ret;
> > +	}
> > +
> > +	/* Initialize controls */
> > +	ret = dw9768_init_controls(dw9768);
> > +	if (ret)
> > +		goto err_free_handler;
> > +
> > +	/* Initialize subdev */
> > +	dw9768->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> > +	dw9768->sd.internal_ops = &dw9768_int_ops;
> > +
> > +	ret = media_entity_pads_init(&dw9768->sd.entity, 0, NULL);
> > +	if (ret < 0)
> > +		goto err_free_handler;
> > +
> > +	dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
> > +
> > +	pm_runtime_enable(dev);
> > +	if (!pm_runtime_enabled(dev)) {
> > +		ret = dw9768_runtime_resume(dev);
> > +		if (ret < 0) {
> > +			dev_err(dev, "failed to power on: %d\n", ret);
> > +			goto err_clean_entity;
> > +		}
> > +	}
> > +
> > +	ret = v4l2_async_register_subdev(&dw9768->sd);
> > +	if (ret < 0) {
> > +		dev_err(dev, "failed to register V4L2 subdev: %d", ret);
> > +		goto error_async_register;
> > +	}
> > +
> > +	return 0;
> > +
> > +error_async_register:
> > +	if (!pm_runtime_enabled(dev))
> > +		dw9768_runtime_suspend(dev);
> > +err_clean_entity:
> > +	media_entity_cleanup(&dw9768->sd.entity);
> > +err_free_handler:
> > +	v4l2_ctrl_handler_free(&dw9768->ctrls);
> > +
> > +	return ret;
> > +}
> > +

[snip]...


  parent reply	other threads:[~2020-06-06  6:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 10:54 [V7, 0/2] media: i2c: Add support for DW9768 VCM driver Dongchun Zhu
2020-06-05 10:54 ` Dongchun Zhu
2020-06-05 10:54 ` Dongchun Zhu
2020-06-05 10:54 ` [V7, 1/2] media: dt-bindings: media: i2c: Document DW9768 bindings Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-09 19:47   ` Rob Herring
2020-06-09 19:47     ` Rob Herring
2020-06-09 19:47     ` Rob Herring
2020-06-05 10:54 ` [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-05 12:14   ` Sakari Ailus
2020-06-05 12:14     ` Sakari Ailus
2020-06-05 12:14     ` Sakari Ailus
2020-06-05 13:02     ` Tomasz Figa
2020-06-05 13:02       ` Tomasz Figa
2020-06-05 13:02       ` Tomasz Figa
2020-06-05 13:37       ` Sakari Ailus
2020-06-05 13:37         ` Sakari Ailus
2020-06-05 13:37         ` Sakari Ailus
2020-06-06  6:24     ` Dongchun Zhu [this message]
2020-06-06  6:24       ` Dongchun Zhu
2020-06-06  6:24       ` Dongchun Zhu
2020-06-05 12:46   ` Andy Shevchenko
2020-06-05 12:46     ` Andy Shevchenko
2020-06-05 12:46     ` Andy Shevchenko
2020-06-05 13:10     ` Tomasz Figa
2020-06-05 13:10       ` Tomasz Figa
2020-06-05 13:10       ` Tomasz Figa
2020-06-06  6:19     ` Dongchun Zhu
2020-06-06  6:19       ` Dongchun Zhu
2020-06-06  6:19       ` Dongchun Zhu
2020-06-08 13:27       ` Andy Shevchenko
2020-06-08 13:27         ` Andy Shevchenko
2020-06-08 13:27         ` Andy Shevchenko
2020-06-09  3:45         ` Dongchun Zhu
2020-06-09  3:45           ` Dongchun Zhu
2020-06-09  3:45           ` Dongchun Zhu
2020-06-09 11:14           ` Andy Shevchenko
2020-06-09 11:14             ` Andy Shevchenko
2020-06-09 11:14             ` Andy Shevchenko
2020-06-10 12:58             ` Sakari Ailus
2020-06-10 12:58               ` Sakari Ailus
2020-06-10 12:58               ` Sakari Ailus
2020-06-05 13:44   ` Tomasz Figa
2020-06-05 13:44     ` Tomasz Figa
2020-06-05 13:44     ` Tomasz Figa
2020-06-06  6:42     ` Dongchun Zhu
2020-06-06  6:42       ` Dongchun Zhu
2020-06-06  6:42       ` Dongchun Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1591424652.8804.603.camel@mhfsdcap03 \
    --to=dongchun.zhu@mediatek.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=bingbu.cao@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@chromium.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=louis.kuo@mediatek.com \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shengnan.wang@mediatek.com \
    --cc=sj.huang@mediatek.com \
    --cc=srv_heupstream@mediatek.com \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.