mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-25 18:12:57 +01:00
LinuxKPI: Add devm_device_add_group to linux/device.h
devm_device_add_group creates a managed attribute group for a device. Sponsored by: Serenity Cyber Security, LLC MFC after: 1 week Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D45845
This commit is contained in:
parent
80aa295a52
commit
a1181662d3
@ -701,4 +701,8 @@ int lkpi_devm_add_action_or_reset(struct device *dev, void (*action)(void *), vo
|
||||
#define devm_add_action_or_reset(dev, action, data) \
|
||||
lkpi_devm_add_action_or_reset(dev, action, data)
|
||||
|
||||
int lkpi_devm_device_add_group(struct device *dev, const struct attribute_group *group);
|
||||
#define devm_device_add_group(dev, group) \
|
||||
lkpi_devm_device_add_group(dev, group)
|
||||
|
||||
#endif /* _LINUXKPI_LINUX_DEVICE_H_ */
|
||||
|
@ -2615,6 +2615,36 @@ device_can_wakeup(struct device *dev)
|
||||
return (false);
|
||||
}
|
||||
|
||||
static void
|
||||
devm_device_group_remove(struct device *dev, void *p)
|
||||
{
|
||||
const struct attribute_group **dr = p;
|
||||
const struct attribute_group *group = *dr;
|
||||
|
||||
sysfs_remove_group(&dev->kobj, group);
|
||||
}
|
||||
|
||||
int
|
||||
lkpi_devm_device_add_group(struct device *dev,
|
||||
const struct attribute_group *group)
|
||||
{
|
||||
const struct attribute_group **dr;
|
||||
int ret;
|
||||
|
||||
dr = devres_alloc(devm_device_group_remove, sizeof(*dr), GFP_KERNEL);
|
||||
if (dr == NULL)
|
||||
return (-ENOMEM);
|
||||
|
||||
ret = sysfs_create_group(&dev->kobj, group);
|
||||
if (ret == 0) {
|
||||
*dr = group;
|
||||
devres_add(dev, dr);
|
||||
} else
|
||||
devres_free(dr);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#if defined(__i386__) || defined(__amd64__)
|
||||
bool linux_cpu_has_clflush;
|
||||
struct cpuinfo_x86 boot_cpu_data;
|
||||
|
Loading…
Reference in New Issue
Block a user