aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing/intel_th
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2016-03-04 12:42:48 -0500
committerAlexander Shishkin <alexander.shishkin@linux.intel.com>2016-04-08 09:11:56 -0400
commitb5edbf1ea3ad044b185be7015cffabba9c442660 (patch)
tree8b49f20d96bef096649200656e4838a90ce09c3e /drivers/hwtracing/intel_th
parent6575cbd67172bbcbfbb50ddd854d2b90c9f4e358 (diff)
intel_th: Allow subdevice drivers to bring in own attribute groups
Some subdevices (MSU, PTI) need to register their own driver-specific attribute groups. Provide a way for those to pass their attribute groups to the core driver in their driver structure so that the core can take care of creating and removing them. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Reviewed-by: Laurent Fert <laurent.fert@intel.com>
Diffstat (limited to 'drivers/hwtracing/intel_th')
-rw-r--r--drivers/hwtracing/intel_th/core.c12
-rw-r--r--drivers/hwtracing/intel_th/intel_th.h3
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/hwtracing/intel_th/core.c b/drivers/hwtracing/intel_th/core.c
index 4272f2ce5f6e..db0691929a60 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -71,6 +71,15 @@ static int intel_th_probe(struct device *dev)
71 if (ret) 71 if (ret)
72 return ret; 72 return ret;
73 73
74 if (thdrv->attr_group) {
75 ret = sysfs_create_group(&thdev->dev.kobj, thdrv->attr_group);
76 if (ret) {
77 thdrv->remove(thdev);
78
79 return ret;
80 }
81 }
82
74 if (thdev->type == INTEL_TH_OUTPUT && 83 if (thdev->type == INTEL_TH_OUTPUT &&
75 !intel_th_output_assigned(thdev)) 84 !intel_th_output_assigned(thdev))
76 ret = hubdrv->assign(hub, thdev); 85 ret = hubdrv->assign(hub, thdev);
@@ -91,6 +100,9 @@ static int intel_th_remove(struct device *dev)
91 return err; 100 return err;
92 } 101 }
93 102
103 if (thdrv->attr_group)
104 sysfs_remove_group(&thdev->dev.kobj, thdrv->attr_group);
105
94 thdrv->remove(thdev); 106 thdrv->remove(thdev);
95 107
96 if (intel_th_output_assigned(thdev)) { 108 if (intel_th_output_assigned(thdev)) {
diff --git a/drivers/hwtracing/intel_th/intel_th.h b/drivers/hwtracing/intel_th/intel_th.h
index eedd09332db6..15ebd48a29f2 100644
--- a/drivers/hwtracing/intel_th/intel_th.h
+++ b/drivers/hwtracing/intel_th/intel_th.h
@@ -115,6 +115,7 @@ intel_th_output_assigned(struct intel_th_device *thdev)
115 * @enable: enable tracing for a given output device 115 * @enable: enable tracing for a given output device
116 * @disable: disable tracing for a given output device 116 * @disable: disable tracing for a given output device
117 * @fops: file operations for device nodes 117 * @fops: file operations for device nodes
118 * @attr_group: attributes provided by the driver
118 * 119 *
119 * Callbacks @probe and @remove are required for all device types. 120 * Callbacks @probe and @remove are required for all device types.
120 * Switch device driver needs to fill in @assign, @enable and @disable 121 * Switch device driver needs to fill in @assign, @enable and @disable
@@ -139,6 +140,8 @@ struct intel_th_driver {
139 void (*deactivate)(struct intel_th_device *thdev); 140 void (*deactivate)(struct intel_th_device *thdev);
140 /* file_operations for those who want a device node */ 141 /* file_operations for those who want a device node */
141 const struct file_operations *fops; 142 const struct file_operations *fops;
143 /* optional attributes */
144 struct attribute_group *attr_group;
142 145
143 /* source ops */ 146 /* source ops */
144 int (*set_output)(struct intel_th_device *thdev, 147 int (*set_output)(struct intel_th_device *thdev,