Commit bf82d375 authored by Rob Herring's avatar Rob Herring Committed by Michael Ellerman

macintosh: Use device_type helpers to access the node type

Remove directly accessing device_node.type pointer and use the
accessors instead. This will eventually allow removing the type
pointer.
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 15b680c4
...@@ -220,8 +220,8 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res, ...@@ -220,8 +220,8 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res,
return 1; return 1;
/* Some older IDE resources have bogus sizes */ /* Some older IDE resources have bogus sizes */
if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") && if (!strcmp(np->name, "IDE") || !strcmp(np->name, "ATA") ||
strcmp(np->type, "ide") && strcmp(np->type, "ata"))) { of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) {
if (index == 0 && (res->end - res->start) > 0xfff) if (index == 0 && (res->end - res->start) > 0xfff)
res->end = res->start + 0xfff; res->end = res->start + 0xfff;
if (index == 1 && (res->end - res->start) > 0xff) if (index == 1 && (res->end - res->start) > 0xff)
......
...@@ -3,17 +3,6 @@ ...@@ -3,17 +3,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <asm/macio.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 static ssize_t
compatible_show (struct device *dev, struct device_attribute *attr, char *buf) compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
{ {
...@@ -65,7 +54,12 @@ static ssize_t name_show(struct device *dev, ...@@ -65,7 +54,12 @@ static ssize_t name_show(struct device *dev,
} }
static DEVICE_ATTR_RO(name); 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[] = { static struct attribute *macio_dev_attrs[] = {
&dev_attr_name.attr, &dev_attr_name.attr,
......
...@@ -439,11 +439,11 @@ static void wf_fcu_lookup_fans(struct wf_fcu_priv *pv) ...@@ -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)); DBG(" control: %pOFn, type: %s\n", np, of_node_get_device_type(np));
/* Detect control type */ /* Detect control type */
if (!strcmp(np->type, "fan-rpm-control") || if (of_node_is_type(np, "fan-rpm-control") ||
!strcmp(np->type, "fan-rpm")) of_node_is_type(np, "fan-rpm"))
type = FCU_FAN_RPM; type = FCU_FAN_RPM;
if (!strcmp(np->type, "fan-pwm-control") || if (of_node_is_type(np, "fan-pwm-control") ||
!strcmp(np->type, "fan-pwm")) of_node_is_type(np, "fan-pwm"))
type = FCU_FAN_PWM; type = FCU_FAN_PWM;
/* Only care about fans for now */ /* Only care about fans for now */
if (type == -1) if (type == -1)
......
...@@ -197,7 +197,7 @@ static int wf_sat_probe(struct i2c_client *client, ...@@ -197,7 +197,7 @@ static int wf_sat_probe(struct i2c_client *client,
struct wf_sat *sat; struct wf_sat *sat;
struct wf_sat_sensor *sens; struct wf_sat_sensor *sens;
const u32 *reg; const u32 *reg;
const char *loc, *type; const char *loc;
u8 chip, core; u8 chip, core;
struct device_node *child; struct device_node *child;
int shift, cpu, index; int shift, cpu, index;
...@@ -220,7 +220,6 @@ static int wf_sat_probe(struct i2c_client *client, ...@@ -220,7 +220,6 @@ static int wf_sat_probe(struct i2c_client *client,
child = NULL; child = NULL;
while ((child = of_get_next_child(dev, child)) != NULL) { while ((child = of_get_next_child(dev, child)) != NULL) {
reg = of_get_property(child, "reg", NULL); reg = of_get_property(child, "reg", NULL);
type = of_get_property(child, "device_type", NULL);
loc = of_get_property(child, "location", NULL); loc = of_get_property(child, "location", NULL);
if (reg == NULL || loc == NULL) if (reg == NULL || loc == NULL)
continue; continue;
...@@ -249,15 +248,15 @@ static int wf_sat_probe(struct i2c_client *client, ...@@ -249,15 +248,15 @@ static int wf_sat_probe(struct i2c_client *client,
continue; continue;
} }
if (strcmp(type, "voltage-sensor") == 0) { if (of_node_is_type(child, "voltage-sensor")) {
name = "cpu-voltage"; name = "cpu-voltage";
shift = 4; shift = 4;
vsens[core] = index; vsens[core] = index;
} else if (strcmp(type, "current-sensor") == 0) { } else if (of_node_is_type(child, "current-sensor")) {
name = "cpu-current"; name = "cpu-current";
shift = 8; shift = 8;
isens[core] = index; isens[core] = index;
} else if (strcmp(type, "temp-sensor") == 0) { } else if (of_node_is_type(child, "temp-sensor")) {
name = "cpu-temp"; name = "cpu-temp";
shift = 10; shift = 10;
} else } else
......
...@@ -197,15 +197,14 @@ static const struct wf_sensor_ops smu_slotspow_ops = { ...@@ -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) static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
{ {
struct smu_ad_sensor *ads; struct smu_ad_sensor *ads;
const char *c, *l; const char *l;
const u32 *v; const u32 *v;
ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL);
if (ads == NULL) if (ads == NULL)
return NULL; return NULL;
c = of_get_property(node, "device_type", NULL);
l = of_get_property(node, "location", NULL); l = of_get_property(node, "location", NULL);
if (c == NULL || l == NULL) if (l == NULL)
goto fail; goto fail;
/* We currently pick the sensors based on the OF name and location /* 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) ...@@ -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 * the names and locations consistents so I'll stick with the names
* and locations for now. * and locations for now.
*/ */
if (!strcmp(c, "temp-sensor") && if (of_node_is_type(node, "temp-sensor") &&
!strcmp(l, "CPU T-Diode")) { !strcmp(l, "CPU T-Diode")) {
ads->sens.ops = &smu_cputemp_ops; ads->sens.ops = &smu_cputemp_ops;
ads->sens.name = "cpu-temp"; ads->sens.name = "cpu-temp";
...@@ -224,7 +223,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node) ...@@ -224,7 +223,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
SMU_SDB_CPUDIODE_ID); SMU_SDB_CPUDIODE_ID);
goto fail; goto fail;
} }
} else if (!strcmp(c, "current-sensor") && } else if (of_node_is_type(node, "current-sensor") &&
!strcmp(l, "CPU Current")) { !strcmp(l, "CPU Current")) {
ads->sens.ops = &smu_cpuamp_ops; ads->sens.ops = &smu_cpuamp_ops;
ads->sens.name = "cpu-current"; ads->sens.name = "cpu-current";
...@@ -233,7 +232,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node) ...@@ -233,7 +232,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
SMU_SDB_CPUVCP_ID); SMU_SDB_CPUVCP_ID);
goto fail; goto fail;
} }
} else if (!strcmp(c, "voltage-sensor") && } else if (of_node_is_type(node, "voltage-sensor") &&
!strcmp(l, "CPU Voltage")) { !strcmp(l, "CPU Voltage")) {
ads->sens.ops = &smu_cpuvolt_ops; ads->sens.ops = &smu_cpuvolt_ops;
ads->sens.name = "cpu-voltage"; ads->sens.name = "cpu-voltage";
...@@ -242,7 +241,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node) ...@@ -242,7 +241,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
SMU_SDB_CPUVCP_ID); SMU_SDB_CPUVCP_ID);
goto fail; goto fail;
} }
} else if (!strcmp(c, "power-sensor") && } else if (of_node_is_type(node, "power-sensor") &&
!strcmp(l, "Slots Power")) { !strcmp(l, "Slots Power")) {
ads->sens.ops = &smu_slotspow_ops; ads->sens.ops = &smu_slotspow_ops;
ads->sens.name = "slots-power"; ads->sens.name = "slots-power";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment