summaryrefslogtreecommitdiff
path: root/drivers/hwtracing/intel_th/intel_th.h
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2016-11-18 15:05:01 +0200
committerAlexander Shishkin <alexander.shishkin@linux.intel.com>2017-08-25 17:58:36 +0300
commit5e06723af998779210dffe9553b36b28955d5860 (patch)
treee3fd77c3263232935a735909b48105596b9ac494 /drivers/hwtracing/intel_th/intel_th.h
parent5376be63ff4ff357d40dbe75c925d7cd5aef19a9 (diff)
intel_th: Streamline the subdevice tree accessors
Make to_intel_th*() accessors available from the main header file. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Diffstat (limited to 'drivers/hwtracing/intel_th/intel_th.h')
-rw-r--r--drivers/hwtracing/intel_th/intel_th.h25
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
index c03f28ef6409..496286ce79e8 100644
--- a/drivers/hwtracing/intel_th/intel_th.h
+++ b/drivers/hwtracing/intel_th/intel_th.h
@@ -173,7 +173,7 @@ struct intel_th_driver {
((_d) ? to_intel_th_driver(_d) : NULL)
static inline struct intel_th_device *
-to_intel_th_hub(struct intel_th_device *thdev)
+to_intel_th_parent(struct intel_th_device *thdev)
{
struct device *parent = thdev->dev.parent;
@@ -183,6 +183,29 @@ to_intel_th_hub(struct intel_th_device *thdev)
return to_intel_th_device(parent);
}
+static inline struct intel_th_device *
+to_intel_th_hub(struct intel_th_device *thdev)
+{
+ /*
+ * subdevice tree is flat: if this one is not a switch, its
+ * parent must be
+ */
+ if (thdev->type == INTEL_TH_SWITCH)
+ return thdev;
+
+ return to_intel_th_parent(thdev);
+}
+
+static inline struct intel_th *to_intel_th(struct intel_th_device *thdev)
+{
+ thdev = to_intel_th_hub(thdev);
+
+ if (WARN_ON_ONCE(!thdev || thdev->type != INTEL_TH_SWITCH))
+ return NULL;
+
+ return dev_get_drvdata(thdev->dev.parent);
+}
+
struct intel_th *
intel_th_alloc(struct device *dev, struct resource *devres,
unsigned int ndevres, int irq);