.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * arch/powerpc/platforms/powermac/low_i2c.c |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2003-2005 Ben. Herrenschmidt (benh@kernel.crashing.org) |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License |
---|
8 | | - * as published by the Free Software Foundation; either version |
---|
9 | | - * 2 of the License, or (at your option) any later version. |
---|
10 | 6 | * |
---|
11 | 7 | * The linux i2c layer isn't completely suitable for our needs for various |
---|
12 | 8 | * reasons ranging from too late initialisation to semantics not perfectly |
---|
.. | .. |
---|
586 | 582 | bus->close = kw_i2c_close; |
---|
587 | 583 | bus->xfer = kw_i2c_xfer; |
---|
588 | 584 | mutex_init(&bus->mutex); |
---|
| 585 | + lockdep_register_key(&bus->lock_key); |
---|
589 | 586 | lockdep_set_class(&bus->mutex, &bus->lock_key); |
---|
590 | 587 | if (controller == busnode) |
---|
591 | 588 | bus->flags = pmac_i2c_multibus; |
---|
.. | .. |
---|
617 | 614 | * but not for now |
---|
618 | 615 | */ |
---|
619 | 616 | child = of_get_next_child(np, NULL); |
---|
620 | | - multibus = !child || strcmp(child->name, "i2c-bus"); |
---|
| 617 | + multibus = !of_node_name_eq(child, "i2c-bus"); |
---|
621 | 618 | of_node_put(child); |
---|
622 | 619 | |
---|
623 | 620 | /* For a multibus setup, we get the bus count based on the |
---|
.. | .. |
---|
633 | 630 | for (i = 0; i < chans; i++) |
---|
634 | 631 | kw_i2c_add(host, np, np, i); |
---|
635 | 632 | } else { |
---|
636 | | - for (child = NULL; |
---|
637 | | - (child = of_get_next_child(np, child)) != NULL;) { |
---|
| 633 | + for_each_child_of_node(np, child) { |
---|
638 | 634 | const u32 *reg = of_get_property(child, |
---|
639 | 635 | "reg", NULL); |
---|
640 | 636 | if (reg == NULL) |
---|
.. | .. |
---|
815 | 811 | bus->hostdata = bus + 1; |
---|
816 | 812 | bus->xfer = pmu_i2c_xfer; |
---|
817 | 813 | mutex_init(&bus->mutex); |
---|
| 814 | + lockdep_register_key(&bus->lock_key); |
---|
818 | 815 | lockdep_set_class(&bus->mutex, &bus->lock_key); |
---|
819 | 816 | bus->flags = pmac_i2c_multibus; |
---|
820 | 817 | list_add(&bus->link, &pmac_i2c_busses); |
---|
.. | .. |
---|
917 | 914 | * type as older device trees mix i2c busses and other things |
---|
918 | 915 | * at the same level |
---|
919 | 916 | */ |
---|
920 | | - for (busnode = NULL; |
---|
921 | | - (busnode = of_get_next_child(controller, busnode)) != NULL;) { |
---|
922 | | - if (strcmp(busnode->type, "i2c") && |
---|
923 | | - strcmp(busnode->type, "i2c-bus")) |
---|
| 917 | + for_each_child_of_node(controller, busnode) { |
---|
| 918 | + if (!of_node_is_type(busnode, "i2c") && |
---|
| 919 | + !of_node_is_type(busnode, "i2c-bus")) |
---|
924 | 920 | continue; |
---|
925 | 921 | reg = of_get_property(busnode, "reg", NULL); |
---|
926 | 922 | if (reg == NULL) |
---|
.. | .. |
---|
939 | 935 | bus->hostdata = bus + 1; |
---|
940 | 936 | bus->xfer = smu_i2c_xfer; |
---|
941 | 937 | mutex_init(&bus->mutex); |
---|
| 938 | + lockdep_register_key(&bus->lock_key); |
---|
942 | 939 | lockdep_set_class(&bus->mutex, &bus->lock_key); |
---|
943 | 940 | bus->flags = 0; |
---|
944 | 941 | list_add(&bus->link, &pmac_i2c_busses); |
---|
.. | .. |
---|
1198 | 1195 | * platform function instance |
---|
1199 | 1196 | */ |
---|
1200 | 1197 | list_for_each_entry(bus, &pmac_i2c_busses, link) { |
---|
1201 | | - for (np = NULL; |
---|
1202 | | - (np = of_get_next_child(bus->busnode, np)) != NULL;) { |
---|
| 1198 | + for_each_child_of_node(bus->busnode, np) { |
---|
1203 | 1199 | struct whitelist_ent *p; |
---|
1204 | 1200 | /* If multibus, check if device is on that bus */ |
---|
1205 | 1201 | if (bus->flags & pmac_i2c_multibus) |
---|
1206 | 1202 | if (bus != pmac_i2c_find_bus(np)) |
---|
1207 | 1203 | continue; |
---|
1208 | 1204 | for (p = whitelist; p->name != NULL; p++) { |
---|
1209 | | - if (strcmp(np->name, p->name)) |
---|
| 1205 | + if (!of_node_name_eq(np, p->name)) |
---|
1210 | 1206 | continue; |
---|
1211 | 1207 | if (p->compatible && |
---|
1212 | 1208 | !of_device_is_compatible(np, p->compatible)) |
---|