Date: Mon, 11 Nov 2019 14:56:22 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354613 - in stable/12/sys: compat/linuxkpi/common/include/linux sys Message-ID: <201911111456.xABEuMcJ004936@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Mon Nov 11 14:56:22 2019 New Revision: 354613 URL: https://svnweb.freebsd.org/changeset/base/354613 Log: MFC r354335: Enable device class group attributes in the LinuxKPI. Bump the __FreeBSD_version to force recompilation of external kernel modules due to structure change. Differential Revision: https://reviews.freebsd.org/D21564 Submitted by: Greg V <greg@unrelenting.technology> Sponsored by: Mellanox Technologies Modified: stable/12/sys/compat/linuxkpi/common/include/linux/device.h stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linuxkpi/common/include/linux/device.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 14:51:56 2019 (r354612) +++ stable/12/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 14:56:22 2019 (r354613) @@ -54,6 +54,7 @@ struct class { struct kobject kobj; devclass_t bsdclass; const struct dev_pm_ops *pm; + const struct attribute_group **dev_groups; void (*class_release)(struct class *class); void (*dev_release)(struct device *dev); char * (*devnode)(struct device *dev, umode_t *mode); @@ -426,6 +427,8 @@ done: kobject_init(&dev->kobj, &linux_dev_ktype); kobject_add(&dev->kobj, &dev->class->kobj, dev_name(dev)); + sysfs_create_groups(&dev->kobj, dev->class->dev_groups); + return (0); } @@ -433,6 +436,8 @@ static inline void device_unregister(struct device *dev) { device_t bsddev; + + sysfs_remove_groups(&dev->kobj, dev->class->dev_groups); bsddev = dev->bsddev; dev->bsddev = NULL; Modified: stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 14:51:56 2019 (r354612) +++ stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 14:56:22 2019 (r354613) @@ -62,12 +62,13 @@ struct attribute_group { #define ATTRIBUTE_GROUPS(_name) \ static struct attribute_group _name##_group = { \ + .name = __stringify(_name), \ .attrs = _name##_attrs, \ }; \ - static struct attribute_group *_name##_groups[] = { \ + static const struct attribute_group *_name##_groups[] = { \ &_name##_group, \ NULL, \ - }; + } /* * Handle our generic '\0' terminated 'C' string. @@ -210,12 +211,25 @@ sysfs_create_groups(struct kobject *kobj, const struct int error = 0; int i; + if (grps == NULL) + goto done; for (i = 0; grps[i] && !error; i++) error = sysfs_create_group(kobj, grps[i]); while (error && --i >= 0) sysfs_remove_group(kobj, grps[i]); - +done: return (error); +} + +static inline void +sysfs_remove_groups(struct kobject *kobj, const struct attribute_group **grps) +{ + int i; + + if (grps == NULL) + return; + for (i = 0; grps[i]; i++) + sysfs_remove_group(kobj, grps[i]); } static inline int Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Mon Nov 11 14:51:56 2019 (r354612) +++ stable/12/sys/sys/param.h Mon Nov 11 14:56:22 2019 (r354613) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1201501 /* Master, propagated to newvers */ +#define __FreeBSD_version 1201502 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911111456.xABEuMcJ004936>