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

PPS: convert class code to use dev_groups

The dev_attrs field of struct class is going away soon, dev_groups
should be used instead. This converts the pps class code to use the
correct field.

Cc: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+37 -22
+1 -1
drivers/pps/pps.c
··· 406 406 pr_err("failed to allocate class\n"); 407 407 return PTR_ERR(pps_class); 408 408 } 409 - pps_class->dev_attrs = pps_attrs; 409 + pps_class->dev_groups = pps_groups; 410 410 411 411 err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps"); 412 412 if (err < 0) {
+35 -20
drivers/pps/sysfs.c
··· 29 29 * Attribute functions 30 30 */ 31 31 32 - static ssize_t pps_show_assert(struct device *dev, 33 - struct device_attribute *attr, char *buf) 32 + static ssize_t assert_show(struct device *dev, struct device_attribute *attr, 33 + char *buf) 34 34 { 35 35 struct pps_device *pps = dev_get_drvdata(dev); 36 36 ··· 41 41 (long long) pps->assert_tu.sec, pps->assert_tu.nsec, 42 42 pps->assert_sequence); 43 43 } 44 + static DEVICE_ATTR_RO(assert); 44 45 45 - static ssize_t pps_show_clear(struct device *dev, 46 - struct device_attribute *attr, char *buf) 46 + static ssize_t clear_show(struct device *dev, struct device_attribute *attr, 47 + char *buf) 47 48 { 48 49 struct pps_device *pps = dev_get_drvdata(dev); 49 50 ··· 55 54 (long long) pps->clear_tu.sec, pps->clear_tu.nsec, 56 55 pps->clear_sequence); 57 56 } 57 + static DEVICE_ATTR_RO(clear); 58 58 59 - static ssize_t pps_show_mode(struct device *dev, 60 - struct device_attribute *attr, char *buf) 59 + static ssize_t mode_show(struct device *dev, struct device_attribute *attr, 60 + char *buf) 61 61 { 62 62 struct pps_device *pps = dev_get_drvdata(dev); 63 63 64 64 return sprintf(buf, "%4x\n", pps->info.mode); 65 65 } 66 + static DEVICE_ATTR_RO(mode); 66 67 67 - static ssize_t pps_show_echo(struct device *dev, 68 - struct device_attribute *attr, char *buf) 68 + static ssize_t echo_show(struct device *dev, struct device_attribute *attr, 69 + char *buf) 69 70 { 70 71 struct pps_device *pps = dev_get_drvdata(dev); 71 72 72 73 return sprintf(buf, "%d\n", !!pps->info.echo); 73 74 } 75 + static DEVICE_ATTR_RO(echo); 74 76 75 - static ssize_t pps_show_name(struct device *dev, 76 - struct device_attribute *attr, char *buf) 77 + static ssize_t name_show(struct device *dev, struct device_attribute *attr, 78 + char *buf) 77 79 { 78 80 struct pps_device *pps = dev_get_drvdata(dev); 79 81 80 82 return sprintf(buf, "%s\n", pps->info.name); 81 83 } 84 + static DEVICE_ATTR_RO(name); 82 85 83 - static ssize_t pps_show_path(struct device *dev, 84 - struct device_attribute *attr, char *buf) 86 + static ssize_t path_show(struct device *dev, struct device_attribute *attr, 87 + char *buf) 85 88 { 86 89 struct pps_device *pps = dev_get_drvdata(dev); 87 90 88 91 return sprintf(buf, "%s\n", pps->info.path); 89 92 } 93 + static DEVICE_ATTR_RO(path); 90 94 91 - struct device_attribute pps_attrs[] = { 92 - __ATTR(assert, S_IRUGO, pps_show_assert, NULL), 93 - __ATTR(clear, S_IRUGO, pps_show_clear, NULL), 94 - __ATTR(mode, S_IRUGO, pps_show_mode, NULL), 95 - __ATTR(echo, S_IRUGO, pps_show_echo, NULL), 96 - __ATTR(name, S_IRUGO, pps_show_name, NULL), 97 - __ATTR(path, S_IRUGO, pps_show_path, NULL), 98 - __ATTR_NULL, 95 + static struct attribute *pps_attrs[] = { 96 + &dev_attr_assert.attr, 97 + &dev_attr_clear.attr, 98 + &dev_attr_mode.attr, 99 + &dev_attr_echo.attr, 100 + &dev_attr_name.attr, 101 + &dev_attr_path.attr, 102 + NULL, 103 + }; 104 + 105 + static const struct attribute_group pps_group = { 106 + .attrs = pps_attrs, 107 + }; 108 + 109 + const struct attribute_group *pps_groups[] = { 110 + &pps_group, 111 + NULL, 99 112 };
+1 -1
include/linux/pps_kernel.h
··· 80 80 * Global variables 81 81 */ 82 82 83 - extern struct device_attribute pps_attrs[]; 83 + extern const struct attribute_group *pps_groups[]; 84 84 85 85 /* 86 86 * Internal functions.