Commit 5e06723a authored by Alexander Shishkin's avatar Alexander Shishkin

intel_th: Streamline the subdevice tree accessors

Make to_intel_th*() accessors available from the main header file.
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
parent 5376be63
......@@ -156,21 +156,6 @@ static struct device_type intel_th_source_device_type = {
.release = intel_th_device_release,
};
static struct intel_th *to_intel_th(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)
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);
}
static char *intel_th_output_devnode(struct device *dev, umode_t *mode,
kuid_t *uid, kgid_t *gid)
{
......
......@@ -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);
......
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