From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: edubezval@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
daniel.lezcano@linaro.org, leo.yan@linaro.org,
Zhang Rui <rui.zhang@intel.com>
Subject: [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions
Date: Tue, 25 Sep 2018 11:03:02 +0200 [thread overview]
Message-ID: <1537866192-12320-5-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org>
The hi6220 and the hi3660 probe functions are doing almost the same
operations, they can share 90% of their code.
Factor out the probe functions by moving the common code in the common
probe function.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
drivers/thermal/hisi_thermal.c | 39 ++++++++++++---------------------------
1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c
index 567fde6..7287818 100644
--- a/drivers/thermal/hisi_thermal.c
+++ b/drivers/thermal/hisi_thermal.c
@@ -391,16 +391,8 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
{
struct platform_device *pdev = data->pdev;
struct device *dev = &pdev->dev;
- struct resource *res;
int ret;
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- data->regs = devm_ioremap_resource(dev, res);
- if (IS_ERR(data->regs)) {
- dev_err(dev, "failed to get io address\n");
- return PTR_ERR(data->regs);
- }
-
data->clk = devm_clk_get(dev, "thermal_clk");
if (IS_ERR(data->clk)) {
ret = PTR_ERR(data->clk);
@@ -409,10 +401,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
return ret;
}
- data->irq = platform_get_irq(pdev, 0);
- if (data->irq < 0)
- return data->irq;
-
data->sensor.id = HI6220_DEFAULT_SENSOR;
return 0;
@@ -420,21 +408,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data)
static int hi3660_thermal_probe(struct hisi_thermal_data *data)
{
- struct platform_device *pdev = data->pdev;
- struct device *dev = &pdev->dev;
- struct resource *res;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- data->regs = devm_ioremap_resource(dev, res);
- if (IS_ERR(data->regs)) {
- dev_err(dev, "failed to get io address\n");
- return PTR_ERR(data->regs);
- }
-
- data->irq = platform_get_irq(pdev, 0);
- if (data->irq < 0)
- return data->irq;
-
data->sensor.id = HI3660_DEFAULT_SENSOR;
return 0;
@@ -553,6 +526,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)
{
struct hisi_thermal_data *data;
struct device *dev = &pdev->dev;
+ struct resource *res;
int ret;
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
@@ -564,6 +538,17 @@ static int hisi_thermal_probe(struct platform_device *pdev)
data->sensor.data = data;
data->ops = of_device_get_match_data(dev);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ data->regs = devm_ioremap_resource(dev, res);
+ if (IS_ERR(data->regs)) {
+ dev_err(dev, "failed to get io address\n");
+ return PTR_ERR(data->regs);
+ }
+
+ data->irq = platform_get_irq(pdev, 0);
+ if (data->irq < 0)
+ return data->irq;
+
ret = data->ops->probe(data);
if (ret)
return ret;
--
2.7.4
next prev parent reply other threads:[~2018-09-25 9:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-25 9:02 [PATCH 00/14] thermal/drivers/hi3660: Dual cluster sensors support Daniel Lezcano
2018-09-25 9:02 ` [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Daniel Lezcano
2018-09-25 9:03 ` [PATCH 02/14] thermal/drivers/hisi: Change the driver to be sensor oriented Daniel Lezcano
2018-09-25 9:03 ` [PATCH 03/14] thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer Daniel Lezcano
2018-09-25 9:03 ` Daniel Lezcano [this message]
2018-09-25 9:03 ` [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Daniel Lezcano
2018-09-25 9:03 ` [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support Daniel Lezcano
2018-09-25 9:03 ` [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location Daniel Lezcano
2018-09-25 9:03 ` [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name Daniel Lezcano
2018-10-15 16:28 ` Rob Herring
2018-10-15 18:01 ` Daniel Lezcano
2018-10-16 14:44 ` Rob Herring
2018-10-16 15:12 ` Daniel Lezcano
2018-09-25 9:03 ` [PATCH 09/14] thermal/drivers/hisi: Use platform_get_irq_byname Daniel Lezcano
2018-09-25 9:03 ` [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Daniel Lezcano
2018-10-15 16:31 ` Rob Herring
2018-10-15 18:01 ` Daniel Lezcano
2018-09-25 9:03 ` [PATCH 11/14] thermal/drivers/hisi: Remove pointless irq field Daniel Lezcano
2018-09-25 9:03 ` [PATCH 12/14] thermal/drivers/hisi: Add more sensors channel Daniel Lezcano
2018-09-25 9:03 ` [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660 Daniel Lezcano
2018-09-25 9:03 ` [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors " Daniel Lezcano
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=1537866192-12320-5-git-send-email-daniel.lezcano@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=edubezval@gmail.com \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rui.zhang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).