]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
macintosh: Use device_type helpers to access the node type
authorRob Herring <robh@kernel.org>
Fri, 16 Nov 2018 22:11:01 +0000 (16:11 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 26 Nov 2018 11:33:37 +0000 (22:33 +1100)
Remove directly accessing device_node.type pointer and use the
accessors instead. This will eventually allow removing the type
pointer.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/macintosh/macio_asic.c
drivers/macintosh/macio_sysfs.c
drivers/macintosh/windfarm_fcu_controls.c
drivers/macintosh/windfarm_smu_sat.c
drivers/macintosh/windfarm_smu_sensors.c

index 17d3bc917562ed5024b60e9f1d95ca1137162791..bc8418801224fce278a051917977ebae7375f7dd 100644 (file)
@@ -220,8 +220,8 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res,
                return 1;
 
        /* Some older IDE resources have bogus sizes */
-       if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") &&
-             strcmp(np->type, "ide") && strcmp(np->type, "ata"))) {
+       if (!strcmp(np->name, "IDE") || !strcmp(np->name, "ATA") ||
+           of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) {
                if (index == 0 && (res->end - res->start) > 0xfff)
                        res->end = res->start + 0xfff;
                if (index == 1 && (res->end - res->start) > 0xff)
index d2451e58acb97986441889a205612591afcb8433..27f5eefc508f4afbe240d4d96c9aaf1d4ab191d1 100644 (file)
@@ -3,17 +3,6 @@
 #include <linux/stat.h>
 #include <asm/macio.h>
 
-
-#define macio_config_of_attr(field, format_string)                     \
-static ssize_t                                                         \
-field##_show (struct device *dev, struct device_attribute *attr,       \
-              char *buf)                                               \
-{                                                                      \
-       struct macio_dev *mdev = to_macio_device (dev);                 \
-       return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \
-}                                                                      \
-static DEVICE_ATTR_RO(field);
-
 static ssize_t
 compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -65,7 +54,12 @@ static ssize_t name_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(name);
 
-macio_config_of_attr (type, "%s\n");
+static ssize_t type_show(struct device *dev,
+                        struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%s\n", of_node_get_device_type(dev->of_node));
+}
+static DEVICE_ATTR_RO(type);
 
 static struct attribute *macio_dev_attrs[] = {
        &dev_attr_name.attr,
index 2b3ca628a6504d5355a44c875c5f53139a19ccb8..629f19875d7f30eb2630f055cf5d6ded71cc2fe6 100644 (file)
@@ -439,11 +439,11 @@ static void wf_fcu_lookup_fans(struct wf_fcu_priv *pv)
                DBG(" control: %pOFn, type: %s\n", np, of_node_get_device_type(np));
 
                /* Detect control type */
-               if (!strcmp(np->type, "fan-rpm-control") ||
-                   !strcmp(np->type, "fan-rpm"))
+               if (of_node_is_type(np, "fan-rpm-control") ||
+                   of_node_is_type(np, "fan-rpm"))
                        type = FCU_FAN_RPM;
-               if (!strcmp(np->type, "fan-pwm-control") ||
-                   !strcmp(np->type, "fan-pwm"))
+               if (of_node_is_type(np, "fan-pwm-control") ||
+                   of_node_is_type(np, "fan-pwm"))
                        type = FCU_FAN_PWM;
                /* Only care about fans for now */
                if (type == -1)
index a0f61eb853c55155e6f4f2df37f7bb2c53a1381c..b4be718beba82973da9df9c1c133068567f57c98 100644 (file)
@@ -197,7 +197,7 @@ static int wf_sat_probe(struct i2c_client *client,
        struct wf_sat *sat;
        struct wf_sat_sensor *sens;
        const u32 *reg;
-       const char *loc, *type;
+       const char *loc;
        u8 chip, core;
        struct device_node *child;
        int shift, cpu, index;
@@ -220,7 +220,6 @@ static int wf_sat_probe(struct i2c_client *client,
        child = NULL;
        while ((child = of_get_next_child(dev, child)) != NULL) {
                reg = of_get_property(child, "reg", NULL);
-               type = of_get_property(child, "device_type", NULL);
                loc = of_get_property(child, "location", NULL);
                if (reg == NULL || loc == NULL)
                        continue;
@@ -249,15 +248,15 @@ static int wf_sat_probe(struct i2c_client *client,
                        continue;
                }
 
-               if (strcmp(type, "voltage-sensor") == 0) {
+               if (of_node_is_type(child, "voltage-sensor")) {
                        name = "cpu-voltage";
                        shift = 4;
                        vsens[core] = index;
-               } else if (strcmp(type, "current-sensor") == 0) {
+               } else if (of_node_is_type(child, "current-sensor")) {
                        name = "cpu-current";
                        shift = 8;
                        isens[core] = index;
-               } else if (strcmp(type, "temp-sensor") == 0) {
+               } else if (of_node_is_type(child, "temp-sensor")) {
                        name = "cpu-temp";
                        shift = 10;
                } else
index 172fd267dcf6071cf892a558f118e47d1646f34c..1ba86de93f92aac5b430880de2a38fd2a1d10eac 100644 (file)
@@ -197,15 +197,14 @@ static const struct wf_sensor_ops smu_slotspow_ops = {
 static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
 {
        struct smu_ad_sensor *ads;
-       const char *c, *l;
+       const char *l;
        const u32 *v;
 
        ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL);
        if (ads == NULL)
                return NULL;
-       c = of_get_property(node, "device_type", NULL);
        l = of_get_property(node, "location", NULL);
-       if (c == NULL || l == NULL)
+       if (l == NULL)
                goto fail;
 
        /* We currently pick the sensors based on the OF name and location
@@ -215,7 +214,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
         * the names and locations consistents so I'll stick with the names
         * and locations for now.
         */
-       if (!strcmp(c, "temp-sensor") &&
+       if (of_node_is_type(node, "temp-sensor") &&
            !strcmp(l, "CPU T-Diode")) {
                ads->sens.ops = &smu_cputemp_ops;
                ads->sens.name = "cpu-temp";
@@ -224,7 +223,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
                            SMU_SDB_CPUDIODE_ID);
                        goto fail;
                }
-       } else if (!strcmp(c, "current-sensor") &&
+       } else if (of_node_is_type(node, "current-sensor") &&
                   !strcmp(l, "CPU Current")) {
                ads->sens.ops = &smu_cpuamp_ops;
                ads->sens.name = "cpu-current";
@@ -233,7 +232,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
                            SMU_SDB_CPUVCP_ID);
                        goto fail;
                }
-       } else if (!strcmp(c, "voltage-sensor") &&
+       } else if (of_node_is_type(node, "voltage-sensor") &&
                   !strcmp(l, "CPU Voltage")) {
                ads->sens.ops = &smu_cpuvolt_ops;
                ads->sens.name = "cpu-voltage";
@@ -242,7 +241,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
                            SMU_SDB_CPUVCP_ID);
                        goto fail;
                }
-       } else if (!strcmp(c, "power-sensor") &&
+       } else if (of_node_is_type(node, "power-sensor") &&
                   !strcmp(l, "Slots Power")) {
                ads->sens.ops = &smu_slotspow_ops;
                ads->sens.name = "slots-power";