summaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel
diff options
context:
space:
mode:
authorJag Raman <jag.raman@oracle.com>2017-06-23 14:58:35 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-25 13:43:13 -0700
commite2169a32b4f03b926905be029169a8b9f0750a67 (patch)
tree9414c2ed4904caaf7e5b5785159d6c924dab483f /arch/sparc/kernel
parent06f3c3ac60111a2ebffdc6f6acf16847153c0589 (diff)
downloadop-kernel-dev-e2169a32b4f03b926905be029169a8b9f0750a67.zip
op-kernel-dev-e2169a32b4f03b926905be029169a8b9f0750a67.tar.gz
sparc64: refactor code to obtain cfg_handle property from MDESC
Refactors code to get the cfg_handle property of a node from Machine Description (MDESC) Signed-off-by: Jagannathan Raman <jag.raman@oracle.com> Reviewed-by: Liam Merwick <liam.merwick@oracle.com> Reviewed-by: Shannon Nelson <shannon.nelson@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r--arch/sparc/kernel/vio.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index f37937b..1ac5da1 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -181,6 +181,24 @@ static struct device_node *cdev_node;
static struct vio_dev *root_vdev;
static u64 cdev_cfg_handle;
+static const u64 *vio_cfg_handle(struct mdesc_handle *hp, u64 node)
+{
+ const u64 *cfg_handle = NULL;
+ u64 a;
+
+ mdesc_for_each_arc(a, hp, node, MDESC_ARC_TYPE_BACK) {
+ u64 target;
+
+ target = mdesc_arc_target(hp, a);
+ cfg_handle = mdesc_get_property(hp, target,
+ "cfg-handle", NULL);
+ if (cfg_handle)
+ break;
+ }
+
+ return cfg_handle;
+}
+
static void vio_fill_channel_info(struct mdesc_handle *hp, u64 mp,
struct vio_dev *vdev)
{
@@ -227,7 +245,6 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
struct vio_dev *vdev;
int err, tlen, clen;
const u64 *id, *cfg_handle;
- u64 a;
type = mdesc_get_property(hp, mp, "device-type", &tlen);
if (!type) {
@@ -245,16 +262,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
id = mdesc_get_property(hp, mp, "id", NULL);
- cfg_handle = NULL;
- mdesc_for_each_arc(a, hp, mp, MDESC_ARC_TYPE_BACK) {
- u64 target;
-
- target = mdesc_arc_target(hp, a);
- cfg_handle = mdesc_get_property(hp, target,
- "cfg-handle", NULL);
- if (cfg_handle)
- break;
- }
+ cfg_handle = vio_cfg_handle(hp, mp);
bus_id_name = type;
if (!strcmp(type, "domain-services-port"))
OpenPOWER on IntegriCloud