Skip to content

Commit bd0eae4

Browse files
committed
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>
1 parent e80b89a commit bd0eae4

3 files changed

Lines changed: 37 additions & 22 deletions

File tree

‎drivers/pps/pps.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static int __init pps_init(void)
406406
pr_err("failed to allocate class\n");
407407
return PTR_ERR(pps_class);
408408
}
409-
pps_class->dev_attrs = pps_attrs;
409+
pps_class->dev_groups = pps_groups;
410410

411411
err = alloc_chrdev_region(&pps_devt, 0, PPS_MAX_SOURCES, "pps");
412412
if (err < 0) {

‎drivers/pps/sysfs.c‎

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
* Attribute functions
3030
*/
3131

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)
3434
{
3535
struct pps_device *pps = dev_get_drvdata(dev);
3636

@@ -41,9 +41,10 @@ static ssize_t pps_show_assert(struct device *dev,
4141
(long long) pps->assert_tu.sec, pps->assert_tu.nsec,
4242
pps->assert_sequence);
4343
}
44+
static DEVICE_ATTR_RO(assert);
4445

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)
4748
{
4849
struct pps_device *pps = dev_get_drvdata(dev);
4950

@@ -54,45 +55,59 @@ static ssize_t pps_show_clear(struct device *dev,
5455
(long long) pps->clear_tu.sec, pps->clear_tu.nsec,
5556
pps->clear_sequence);
5657
}
58+
static DEVICE_ATTR_RO(clear);
5759

58-
static ssize_t pps_show_mode(struct device *dev,
59-
struct device_attribute *attr, char *buf)
60+
static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
61+
char *buf)
6062
{
6163
struct pps_device *pps = dev_get_drvdata(dev);
6264

6365
return sprintf(buf, "%4x\n", pps->info.mode);
6466
}
67+
static DEVICE_ATTR_RO(mode);
6568

66-
static ssize_t pps_show_echo(struct device *dev,
67-
struct device_attribute *attr, char *buf)
69+
static ssize_t echo_show(struct device *dev, struct device_attribute *attr,
70+
char *buf)
6871
{
6972
struct pps_device *pps = dev_get_drvdata(dev);
7073

7174
return sprintf(buf, "%d\n", !!pps->info.echo);
7275
}
76+
static DEVICE_ATTR_RO(echo);
7377

74-
static ssize_t pps_show_name(struct device *dev,
75-
struct device_attribute *attr, char *buf)
78+
static ssize_t name_show(struct device *dev, struct device_attribute *attr,
79+
char *buf)
7680
{
7781
struct pps_device *pps = dev_get_drvdata(dev);
7882

7983
return sprintf(buf, "%s\n", pps->info.name);
8084
}
85+
static DEVICE_ATTR_RO(name);
8186

82-
static ssize_t pps_show_path(struct device *dev,
83-
struct device_attribute *attr, char *buf)
87+
static ssize_t path_show(struct device *dev, struct device_attribute *attr,
88+
char *buf)
8489
{
8590
struct pps_device *pps = dev_get_drvdata(dev);
8691

8792
return sprintf(buf, "%s\n", pps->info.path);
8893
}
94+
static DEVICE_ATTR_RO(path);
95+
96+
static struct attribute *pps_attrs[] = {
97+
&dev_attr_assert.attr,
98+
&dev_attr_clear.attr,
99+
&dev_attr_mode.attr,
100+
&dev_attr_echo.attr,
101+
&dev_attr_name.attr,
102+
&dev_attr_path.attr,
103+
NULL,
104+
};
105+
106+
static const struct attribute_group pps_group = {
107+
.attrs = pps_attrs,
108+
};
89109

90-
struct device_attribute pps_attrs[] = {
91-
__ATTR(assert, S_IRUGO, pps_show_assert, NULL),
92-
__ATTR(clear, S_IRUGO, pps_show_clear, NULL),
93-
__ATTR(mode, S_IRUGO, pps_show_mode, NULL),
94-
__ATTR(echo, S_IRUGO, pps_show_echo, NULL),
95-
__ATTR(name, S_IRUGO, pps_show_name, NULL),
96-
__ATTR(path, S_IRUGO, pps_show_path, NULL),
97-
__ATTR_NULL,
110+
const struct attribute_group *pps_groups[] = {
111+
&pps_group,
112+
NULL,
98113
};

‎include/linux/pps_kernel.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct pps_device {
8080
* Global variables
8181
*/
8282

83-
extern struct device_attribute pps_attrs[];
83+
extern const struct attribute_group *pps_groups[];
8484

8585
/*
8686
* Internal functions.

0 commit comments

Comments
 (0)