diff options
author | Jingoo Han <jg1.han@samsung.com> | 2014-02-11 07:10:50 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-03-03 11:01:03 -0500 |
commit | 939a0a3fe900125c1e04dc7121444f8f9972892c (patch) | |
tree | 752550358af67f945ad8baa70b6d1b6d232b88bb /drivers/hwmon/jz4740-hwmon.c | |
parent | 6700ce035f830149d48c270d84736debfb67179e (diff) |
hwmon: (jz4740) Use devm_ioremap_resource()
Use devm_ioremap_resource() in order to make the code simpler,
and move 'struct resource *mem' from 'struct jz4740_hwmon' to
jz4740_hwmon_probe() because the 'mem' variable is used only in
jz4740_hwmon_probe(). Also the redundant return value check of
platform_get_resource() is removed, because the value is checked
by devm_ioremap_resource().
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/jz4740-hwmon.c')
-rw-r--r-- | drivers/hwmon/jz4740-hwmon.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/drivers/hwmon/jz4740-hwmon.c b/drivers/hwmon/jz4740-hwmon.c index a183e488db78..7488e36809c8 100644 --- a/drivers/hwmon/jz4740-hwmon.c +++ b/drivers/hwmon/jz4740-hwmon.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/hwmon.h> | 28 | #include <linux/hwmon.h> |
29 | 29 | ||
30 | struct jz4740_hwmon { | 30 | struct jz4740_hwmon { |
31 | struct resource *mem; | ||
32 | void __iomem *base; | 31 | void __iomem *base; |
33 | 32 | ||
34 | int irq; | 33 | int irq; |
@@ -106,6 +105,7 @@ static int jz4740_hwmon_probe(struct platform_device *pdev) | |||
106 | { | 105 | { |
107 | int ret; | 106 | int ret; |
108 | struct jz4740_hwmon *hwmon; | 107 | struct jz4740_hwmon *hwmon; |
108 | struct resource *mem; | ||
109 | 109 | ||
110 | hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL); | 110 | hwmon = devm_kzalloc(&pdev->dev, sizeof(*hwmon), GFP_KERNEL); |
111 | if (!hwmon) | 111 | if (!hwmon) |
@@ -120,25 +120,10 @@ static int jz4740_hwmon_probe(struct platform_device *pdev) | |||
120 | return hwmon->irq; | 120 | return hwmon->irq; |
121 | } | 121 | } |
122 | 122 | ||
123 | hwmon->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 123 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
124 | if (!hwmon->mem) { | 124 | hwmon->base = devm_ioremap_resource(&pdev->dev, mem); |
125 | dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); | 125 | if (IS_ERR(hwmon->base)) |
126 | return -ENOENT; | 126 | return PTR_ERR(hwmon->base); |
127 | } | ||
128 | |||
129 | hwmon->mem = devm_request_mem_region(&pdev->dev, hwmon->mem->start, | ||
130 | resource_size(hwmon->mem), pdev->name); | ||
131 | if (!hwmon->mem) { | ||
132 | dev_err(&pdev->dev, "Failed to request mmio memory region\n"); | ||
133 | return -EBUSY; | ||
134 | } | ||
135 | |||
136 | hwmon->base = devm_ioremap_nocache(&pdev->dev, hwmon->mem->start, | ||
137 | resource_size(hwmon->mem)); | ||
138 | if (!hwmon->base) { | ||
139 | dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); | ||
140 | return -EBUSY; | ||
141 | } | ||
142 | 127 | ||
143 | init_completion(&hwmon->read_completion); | 128 | init_completion(&hwmon->read_completion); |
144 | mutex_init(&hwmon->lock); | 129 | mutex_init(&hwmon->lock); |