Skip to content

Commit 93cfa6f

Browse files
robherringmpe
authored andcommitted
macintosh: Use of_address_to_resource()
Replace open coded reading of "reg" and of_translate_address() calls with single call to of_address_to_resource(). Signed-off-by: Rob Herring <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent bc1cf75 commit 93cfa6f

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

drivers/macintosh/via-cuda.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ int __init find_via_cuda(void)
235235
int __init find_via_cuda(void)
236236
{
237237
struct adb_request req;
238-
phys_addr_t taddr;
239-
const u32 *reg;
238+
struct resource res;
240239
int err;
241240

242241
if (vias)
@@ -245,17 +244,12 @@ int __init find_via_cuda(void)
245244
if (!vias)
246245
return 0;
247246

248-
reg = of_get_property(vias, "reg", NULL);
249-
if (reg == NULL) {
250-
printk(KERN_ERR "via-cuda: No \"reg\" property !\n");
251-
goto fail;
252-
}
253-
taddr = of_translate_address(vias, reg);
254-
if (taddr == 0) {
255-
printk(KERN_ERR "via-cuda: Can't translate address !\n");
247+
err = of_address_to_resource(vias, 0, &res);
248+
if (err) {
249+
printk(KERN_ERR "via-cuda: Error getting \"reg\" property !\n");
256250
goto fail;
257251
}
258-
via = ioremap(taddr, 0x2000);
252+
via = ioremap(res.start, 0x2000);
259253
if (via == NULL) {
260254
printk(KERN_ERR "via-cuda: Can't map address !\n");
261255
goto fail;

drivers/macintosh/via-pmu.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,25 +286,22 @@ static char *pbook_type[] = {
286286
int __init find_via_pmu(void)
287287
{
288288
#ifdef CONFIG_PPC_PMAC
289+
int err;
289290
u64 taddr;
290-
const u32 *reg;
291+
struct resource res;
291292

292293
if (pmu_state != uninitialized)
293294
return 1;
294295
vias = of_find_node_by_name(NULL, "via-pmu");
295296
if (vias == NULL)
296297
return 0;
297298

298-
reg = of_get_property(vias, "reg", NULL);
299-
if (reg == NULL) {
300-
printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
301-
goto fail;
302-
}
303-
taddr = of_translate_address(vias, reg);
304-
if (taddr == OF_BAD_ADDR) {
305-
printk(KERN_ERR "via-pmu: Can't translate address !\n");
299+
err = of_address_to_resource(vias, 0, &res);
300+
if (err) {
301+
printk(KERN_ERR "via-pmu: Error getting \"reg\" property !\n");
306302
goto fail;
307303
}
304+
taddr = res.start;
308305

309306
pmu_has_adb = 1;
310307

@@ -324,7 +321,6 @@ int __init find_via_pmu(void)
324321
|| of_device_is_compatible(vias->parent, "K2-Keylargo")) {
325322
struct device_node *gpiop;
326323
struct device_node *adbp;
327-
u64 gaddr = OF_BAD_ADDR;
328324

329325
pmu_kind = PMU_KEYLARGO_BASED;
330326
adbp = of_find_node_by_type(NULL, "adb");
@@ -338,11 +334,8 @@ int __init find_via_pmu(void)
338334

339335
gpiop = of_find_node_by_name(NULL, "gpio");
340336
if (gpiop) {
341-
reg = of_get_property(gpiop, "reg", NULL);
342-
if (reg)
343-
gaddr = of_translate_address(gpiop, reg);
344-
if (gaddr != OF_BAD_ADDR)
345-
gpio_reg = ioremap(gaddr, 0x10);
337+
if (!of_address_to_resource(gpiop, 0, &res))
338+
gpio_reg = ioremap(res.start, 0x10);
346339
of_node_put(gpiop);
347340
}
348341
if (gpio_reg == NULL) {

0 commit comments

Comments
 (0)