Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+15
+12
drivers/hwtracing/intel_th/core.c
··· 71 71 if (ret) 72 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 83 if (thdev->type == INTEL_TH_OUTPUT && 75 84 !intel_th_output_assigned(thdev)) 76 85 ret = hubdrv->assign(hub, thdev); ··· 99 90 if (err) 100 91 return err; 101 92 } 93 + 94 + if (thdrv->attr_group) 95 + sysfs_remove_group(&thdev->dev.kobj, thdrv->attr_group); 102 96 103 97 thdrv->remove(thdev); 104 98
+3
drivers/hwtracing/intel_th/intel_th.h
··· 115 115 * @enable: enable tracing for a given output device 116 116 * @disable: disable tracing for a given output device 117 117 * @fops: file operations for device nodes 118 + * @attr_group: attributes provided by the driver 118 119 * 119 120 * Callbacks @probe and @remove are required for all device types. 120 121 * Switch device driver needs to fill in @assign, @enable and @disable ··· 140 139 void (*deactivate)(struct intel_th_device *thdev); 141 140 /* file_operations for those who want a device node */ 142 141 const struct file_operations *fops; 142 + /* optional attributes */ 143 + struct attribute_group *attr_group; 143 144 144 145 /* source ops */ 145 146 int (*set_output)(struct intel_th_device *thdev,