All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rajendra Nayak <rnayak@codeaurora.org>
To: Punit Agrawal <punit.agrawal@arm.com>
Cc: linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	rui.zhang@intel.com, edubezval@gmail.com, sboyd@codeaurora.org,
	srinivas.kandagatla@linaro.org, nrajan@codeaurora.org,
	lina.iyer@linaro.org
Subject: Re: [PATCH v2 1/9] thermal: qcom: tsens: Add a skeletal TSENS drivers
Date: Mon, 21 Sep 2015 09:56:31 +0530	[thread overview]
Message-ID: <55FF86F7.5010200@codeaurora.org> (raw)
In-Reply-To: <9hh613atr54.fsf@e105922-lin.cambridge.arm.com>

[]..

>> +Example:
>> +tsens: thermal-sensor@900000 {
>> +		compatible = "qcom,msm8916-tsens";
>> +		qcom,tsens-slopes = <1176 1176 1154 1176 1111
>> +				1132 1132 1199 1132 1199
>> +				1132>;
>> +		nvmem-cells = <&tsens_caldata>, <&tsens_calsel>;
>> +		nvmem-cell-names = "caldata", "calsel";
>> +		qcom,tsens-slopes = <3200 3200 3200 3200 3200>;
>> +		qcom,sensor-id = <0 1 2 4 5>;
>> +		#thermal-sensor-cells = <1>;
>> +	};
>
> The qcom,tsens-slopes property appears twice in the above example.

sure, will fix.

>
> [...]
>> +#ifdef CONFIG_PM
>> +static int tsens_suspend(struct device *dev)
>> +{
>> +	struct tsens_device *tmdev = dev_get_drvdata(dev);
>> +
>> +	if (tmdev->ops && tmdev->ops->suspend)
>> +		return tmdev->ops->suspend(tmdev);
>> +
>> +	return 0;
>> +}
>> +
>> +static int tsens_resume(struct device *dev)
>> +{
>> +	struct tsens_device *tmdev = dev_get_drvdata(dev);
>> +
>> +	if (tmdev->ops && tmdev->ops->resume)
>> +		return tmdev->ops->resume(tmdev);
>> +
>> +	return 0;
>> +}
>> +
>> +static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
>> +#define TSENS_PM_OPS   (&tsens_pm_ops)
>> +
>> +#else /* CONFIG_PM_SLEEP */
>           ^
>
>> +#define TSENS_PM_OPS NULL
>> +#endif /* CONFIG_PM_SLEEP */
>            ^
>
> The comments don't match the #ifdef above. I maybe wrong but looking at
> other drivers it looks like you don't need the #else part. You should be
> able to use the tsens_pm_ops without having to set it to NULL.

yes, I should be able to avoid the #else and thanks for catching the
mismatched comments.

>
>> +
>> +static const struct of_device_id tsens_table[] = {
>> +	{
>> +		.compatible = "qcom,msm8916-tsens",
>> +	}, {
>> +		.compatible = "qcom,msm8974-tsens",
>> +	},
>> +	{}
>> +};
>> +MODULE_DEVICE_TABLE(of, tsens_table);
>> +
>> +static const struct thermal_zone_of_device_ops tsens_of_ops = {
>> +	.get_temp = tsens_get_temp,
>> +	.get_trend = tsens_get_trend,
>> +};
>> +
>> +static int tsens_register(struct tsens_device *tmdev)
>> +{
>> +	int i, ret;
>> +	struct thermal_zone_device *tzd;
>> +	u32 *hw_id, n = tmdev->num_sensors;
>> +	struct device_node *np = tmdev->dev->of_node;
>> +
>> +	hw_id = devm_kcalloc(tmdev->dev, n, sizeof(u32), GFP_KERNEL);
>> +	if (!hw_id)
>> +		return -ENOMEM;
>> +
>> +	ret = of_property_read_u32_array(np, "qcom,sensor-id", hw_id, n);
>> +	if (ret)
>> +		for (i = 0;  i < tmdev->num_sensors; i++)
>> +			tmdev->sensor[i].hw_id = i;
>> +	else
>> +		for (i = 0;  i < tmdev->num_sensors; i++)
>> +			tmdev->sensor[i].hw_id = hw_id[i];
>> +
>
> You could move the check for vaild for valid sensor ids in the device
> tree (ret) inside a single for loop. In that case the loop above could
> be merged into the iteration over the sensors below.

sure, seems like a reasonable optimization to avoid a few loops.

>
>> +	for (i = 0;  i < tmdev->num_sensors; i++) {
>> +		tmdev->sensor[i].tmdev = tmdev;
>> +		tmdev->sensor[i].id = i;
>> +		tzd = thermal_zone_of_sensor_register(tmdev->dev, i,
>> +						      &tmdev->sensor[i],
>> +						      &tsens_of_ops);
>> +		if (IS_ERR(tzd))
>> +			continue;
>> +		tmdev->sensor[i].tzd = tzd;
>> +		if (tmdev->ops->enable)
>> +			tmdev->ops->enable(tmdev, i);
>> +	}
>> +	return 0;
>> +}
>> +
>> +static int tsens_probe(struct platform_device *pdev)
>> +{
>> +	int ret, i, num;
>> +	struct device *dev;
>> +	struct device_node *np;
>> +	struct tsens_sensor *s;
>> +	struct tsens_device *tmdev;
>> +	const struct of_device_id *id;
>> +
>> +	dev = &pdev->dev;
>> +	np = dev->of_node;
>
> These assignments can be done with the declaration above.

I just have these assignments done conditionally in later patches
(5/9), so left them here.
Thanks for taking time to review.

regards,
Rajendra

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

WARNING: multiple messages have this Message-ID (diff)
From: rnayak@codeaurora.org (Rajendra Nayak)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/9] thermal: qcom: tsens: Add a skeletal TSENS drivers
Date: Mon, 21 Sep 2015 09:56:31 +0530	[thread overview]
Message-ID: <55FF86F7.5010200@codeaurora.org> (raw)
In-Reply-To: <9hh613atr54.fsf@e105922-lin.cambridge.arm.com>

[]..

>> +Example:
>> +tsens: thermal-sensor at 900000 {
>> +		compatible = "qcom,msm8916-tsens";
>> +		qcom,tsens-slopes = <1176 1176 1154 1176 1111
>> +				1132 1132 1199 1132 1199
>> +				1132>;
>> +		nvmem-cells = <&tsens_caldata>, <&tsens_calsel>;
>> +		nvmem-cell-names = "caldata", "calsel";
>> +		qcom,tsens-slopes = <3200 3200 3200 3200 3200>;
>> +		qcom,sensor-id = <0 1 2 4 5>;
>> +		#thermal-sensor-cells = <1>;
>> +	};
>
> The qcom,tsens-slopes property appears twice in the above example.

sure, will fix.

>
> [...]
>> +#ifdef CONFIG_PM
>> +static int tsens_suspend(struct device *dev)
>> +{
>> +	struct tsens_device *tmdev = dev_get_drvdata(dev);
>> +
>> +	if (tmdev->ops && tmdev->ops->suspend)
>> +		return tmdev->ops->suspend(tmdev);
>> +
>> +	return 0;
>> +}
>> +
>> +static int tsens_resume(struct device *dev)
>> +{
>> +	struct tsens_device *tmdev = dev_get_drvdata(dev);
>> +
>> +	if (tmdev->ops && tmdev->ops->resume)
>> +		return tmdev->ops->resume(tmdev);
>> +
>> +	return 0;
>> +}
>> +
>> +static SIMPLE_DEV_PM_OPS(tsens_pm_ops, tsens_suspend, tsens_resume);
>> +#define TSENS_PM_OPS   (&tsens_pm_ops)
>> +
>> +#else /* CONFIG_PM_SLEEP */
>           ^
>
>> +#define TSENS_PM_OPS NULL
>> +#endif /* CONFIG_PM_SLEEP */
>            ^
>
> The comments don't match the #ifdef above. I maybe wrong but looking at
> other drivers it looks like you don't need the #else part. You should be
> able to use the tsens_pm_ops without having to set it to NULL.

yes, I should be able to avoid the #else and thanks for catching the
mismatched comments.

>
>> +
>> +static const struct of_device_id tsens_table[] = {
>> +	{
>> +		.compatible = "qcom,msm8916-tsens",
>> +	}, {
>> +		.compatible = "qcom,msm8974-tsens",
>> +	},
>> +	{}
>> +};
>> +MODULE_DEVICE_TABLE(of, tsens_table);
>> +
>> +static const struct thermal_zone_of_device_ops tsens_of_ops = {
>> +	.get_temp = tsens_get_temp,
>> +	.get_trend = tsens_get_trend,
>> +};
>> +
>> +static int tsens_register(struct tsens_device *tmdev)
>> +{
>> +	int i, ret;
>> +	struct thermal_zone_device *tzd;
>> +	u32 *hw_id, n = tmdev->num_sensors;
>> +	struct device_node *np = tmdev->dev->of_node;
>> +
>> +	hw_id = devm_kcalloc(tmdev->dev, n, sizeof(u32), GFP_KERNEL);
>> +	if (!hw_id)
>> +		return -ENOMEM;
>> +
>> +	ret = of_property_read_u32_array(np, "qcom,sensor-id", hw_id, n);
>> +	if (ret)
>> +		for (i = 0;  i < tmdev->num_sensors; i++)
>> +			tmdev->sensor[i].hw_id = i;
>> +	else
>> +		for (i = 0;  i < tmdev->num_sensors; i++)
>> +			tmdev->sensor[i].hw_id = hw_id[i];
>> +
>
> You could move the check for vaild for valid sensor ids in the device
> tree (ret) inside a single for loop. In that case the loop above could
> be merged into the iteration over the sensors below.

sure, seems like a reasonable optimization to avoid a few loops.

>
>> +	for (i = 0;  i < tmdev->num_sensors; i++) {
>> +		tmdev->sensor[i].tmdev = tmdev;
>> +		tmdev->sensor[i].id = i;
>> +		tzd = thermal_zone_of_sensor_register(tmdev->dev, i,
>> +						      &tmdev->sensor[i],
>> +						      &tsens_of_ops);
>> +		if (IS_ERR(tzd))
>> +			continue;
>> +		tmdev->sensor[i].tzd = tzd;
>> +		if (tmdev->ops->enable)
>> +			tmdev->ops->enable(tmdev, i);
>> +	}
>> +	return 0;
>> +}
>> +
>> +static int tsens_probe(struct platform_device *pdev)
>> +{
>> +	int ret, i, num;
>> +	struct device *dev;
>> +	struct device_node *np;
>> +	struct tsens_sensor *s;
>> +	struct tsens_device *tmdev;
>> +	const struct of_device_id *id;
>> +
>> +	dev = &pdev->dev;
>> +	np = dev->of_node;
>
> These assignments can be done with the declaration above.

I just have these assignments done conditionally in later patches
(5/9), so left them here.
Thanks for taking time to review.

regards,
Rajendra

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation

  reply	other threads:[~2015-09-21  4:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16  6:23 [PATCH v2 0/9] qcom: Add support for TSENS driver Rajendra Nayak
2015-09-16  6:23 ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 1/9] thermal: qcom: tsens: Add a skeletal TSENS drivers Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16 13:44   ` Punit Agrawal
2015-09-16 13:44     ` Punit Agrawal
2015-09-21  4:26     ` Rajendra Nayak [this message]
2015-09-21  4:26       ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 2/9] thermal: qcom: tsens-8916: Add support for 8916 family of SoCs Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16 13:46   ` Punit Agrawal
2015-09-16 13:46     ` Punit Agrawal
2015-09-21  4:28     ` Rajendra Nayak
2015-09-21  4:28       ` Rajendra Nayak
2015-10-08  5:05       ` Rajendra Nayak
2015-10-08  5:05         ` Rajendra Nayak
2015-10-08 14:32         ` Punit Agrawal
2015-10-08 14:32           ` Punit Agrawal
2015-09-16  6:23 ` [PATCH v2 3/9] thermal: qcom: tsens-8974: Add support for 8974 " Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 4/9] clk: qcom: create virtual child device for TSENS Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16 22:39   ` Stephen Boyd
2015-09-16 22:39     ` Stephen Boyd
2015-09-21  4:28     ` Rajendra Nayak
2015-09-21  4:28       ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 5/9] thermal: qcom: tsens-8960: Add support for 8960 family of SoCs Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 6/9] arm: dts: msm8974: Add thermal zones, tsens and qfprom nodes Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 7/9] arm: dts: apq8064: " Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 8/9] arm: dts: apq8084: " Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak
2015-09-16  6:23 ` [PATCH v2 9/9] arm64: dts: msm8916: " Rajendra Nayak
2015-09-16  6:23   ` Rajendra Nayak

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=55FF86F7.5010200@codeaurora.org \
    --to=rnayak@codeaurora.org \
    --cc=edubezval@gmail.com \
    --cc=lina.iyer@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nrajan@codeaurora.org \
    --cc=punit.agrawal@arm.com \
    --cc=rui.zhang@intel.com \
    --cc=sboyd@codeaurora.org \
    --cc=srinivas.kandagatla@linaro.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.