powerpc: Make device tree accesses in VIO subsystem endian safe
Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
Родитель
1502b480e2
Коммит
7560d32757
|
@ -1312,8 +1312,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
|
||||||
{
|
{
|
||||||
struct vio_dev *viodev;
|
struct vio_dev *viodev;
|
||||||
struct device_node *parent_node;
|
struct device_node *parent_node;
|
||||||
const unsigned int *unit_address;
|
const __be32 *prop;
|
||||||
const unsigned int *pfo_resid = NULL;
|
|
||||||
enum vio_dev_family family;
|
enum vio_dev_family family;
|
||||||
const char *of_node_name = of_node->name ? of_node->name : "<unknown>";
|
const char *of_node_name = of_node->name ? of_node->name : "<unknown>";
|
||||||
|
|
||||||
|
@ -1360,6 +1359,8 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
|
||||||
/* we need the 'device_type' property, in order to match with drivers */
|
/* we need the 'device_type' property, in order to match with drivers */
|
||||||
viodev->family = family;
|
viodev->family = family;
|
||||||
if (viodev->family == VDEVICE) {
|
if (viodev->family == VDEVICE) {
|
||||||
|
unsigned int unit_address;
|
||||||
|
|
||||||
if (of_node->type != NULL)
|
if (of_node->type != NULL)
|
||||||
viodev->type = of_node->type;
|
viodev->type = of_node->type;
|
||||||
else {
|
else {
|
||||||
|
@ -1368,24 +1369,24 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
unit_address = of_get_property(of_node, "reg", NULL);
|
prop = of_get_property(of_node, "reg", NULL);
|
||||||
if (unit_address == NULL) {
|
if (prop == NULL) {
|
||||||
pr_warn("%s: node %s missing 'reg'\n",
|
pr_warn("%s: node %s missing 'reg'\n",
|
||||||
__func__, of_node_name);
|
__func__, of_node_name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
dev_set_name(&viodev->dev, "%x", *unit_address);
|
unit_address = of_read_number(prop, 1);
|
||||||
|
dev_set_name(&viodev->dev, "%x", unit_address);
|
||||||
viodev->irq = irq_of_parse_and_map(of_node, 0);
|
viodev->irq = irq_of_parse_and_map(of_node, 0);
|
||||||
viodev->unit_address = *unit_address;
|
viodev->unit_address = unit_address;
|
||||||
} else {
|
} else {
|
||||||
/* PFO devices need their resource_id for submitting COP_OPs
|
/* PFO devices need their resource_id for submitting COP_OPs
|
||||||
* This is an optional field for devices, but is required when
|
* This is an optional field for devices, but is required when
|
||||||
* performing synchronous ops */
|
* performing synchronous ops */
|
||||||
pfo_resid = of_get_property(of_node, "ibm,resource-id", NULL);
|
prop = of_get_property(of_node, "ibm,resource-id", NULL);
|
||||||
if (pfo_resid != NULL)
|
if (prop != NULL)
|
||||||
viodev->resource_id = *pfo_resid;
|
viodev->resource_id = of_read_number(prop, 1);
|
||||||
|
|
||||||
unit_address = NULL;
|
|
||||||
dev_set_name(&viodev->dev, "%s", of_node_name);
|
dev_set_name(&viodev->dev, "%s", of_node_name);
|
||||||
viodev->type = of_node_name;
|
viodev->type = of_node_name;
|
||||||
viodev->irq = 0;
|
viodev->irq = 0;
|
||||||
|
@ -1622,7 +1623,6 @@ static struct vio_dev *vio_find_name(const char *name)
|
||||||
*/
|
*/
|
||||||
struct vio_dev *vio_find_node(struct device_node *vnode)
|
struct vio_dev *vio_find_node(struct device_node *vnode)
|
||||||
{
|
{
|
||||||
const uint32_t *unit_address;
|
|
||||||
char kobj_name[20];
|
char kobj_name[20];
|
||||||
struct device_node *vnode_parent;
|
struct device_node *vnode_parent;
|
||||||
const char *dev_type;
|
const char *dev_type;
|
||||||
|
@ -1638,10 +1638,13 @@ struct vio_dev *vio_find_node(struct device_node *vnode)
|
||||||
|
|
||||||
/* construct the kobject name from the device node */
|
/* construct the kobject name from the device node */
|
||||||
if (!strcmp(dev_type, "vdevice")) {
|
if (!strcmp(dev_type, "vdevice")) {
|
||||||
unit_address = of_get_property(vnode, "reg", NULL);
|
const __be32 *prop;
|
||||||
if (!unit_address)
|
|
||||||
|
prop = of_get_property(vnode, "reg", NULL);
|
||||||
|
if (!prop)
|
||||||
return NULL;
|
return NULL;
|
||||||
snprintf(kobj_name, sizeof(kobj_name), "%x", *unit_address);
|
snprintf(kobj_name, sizeof(kobj_name), "%x",
|
||||||
|
(uint32_t)of_read_number(prop, 1));
|
||||||
} else if (!strcmp(dev_type, "ibm,platform-facilities"))
|
} else if (!strcmp(dev_type, "ibm,platform-facilities"))
|
||||||
snprintf(kobj_name, sizeof(kobj_name), "%s", vnode->name);
|
snprintf(kobj_name, sizeof(kobj_name), "%s", vnode->name);
|
||||||
else
|
else
|
||||||
|
|
Загрузка…
Ссылка в новой задаче