mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 14:50:19 +00:00
PTP: 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 ptp class code to use the correct field. Acked-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5baa7503a7
commit
3499116b91
@ -330,7 +330,7 @@ static int __init ptp_init(void)
|
|||||||
goto no_region;
|
goto no_region;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptp_class->dev_attrs = ptp_dev_attrs;
|
ptp_class->dev_groups = ptp_groups;
|
||||||
pr_info("PTP clock support registered\n");
|
pr_info("PTP clock support registered\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ uint ptp_poll(struct posix_clock *pc,
|
|||||||
* see ptp_sysfs.c
|
* see ptp_sysfs.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern struct device_attribute ptp_dev_attrs[];
|
extern const struct attribute_group *ptp_groups[];
|
||||||
|
|
||||||
int ptp_cleanup_sysfs(struct ptp_clock *ptp);
|
int ptp_cleanup_sysfs(struct ptp_clock *ptp);
|
||||||
|
|
||||||
|
@ -27,36 +27,43 @@ static ssize_t clock_name_show(struct device *dev,
|
|||||||
struct ptp_clock *ptp = dev_get_drvdata(dev);
|
struct ptp_clock *ptp = dev_get_drvdata(dev);
|
||||||
return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name);
|
return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name);
|
||||||
}
|
}
|
||||||
|
static DEVICE_ATTR(clock_name, 0444, clock_name_show, NULL);
|
||||||
|
|
||||||
#define PTP_SHOW_INT(name) \
|
#define PTP_SHOW_INT(name, var) \
|
||||||
static ssize_t name##_show(struct device *dev, \
|
static ssize_t var##_show(struct device *dev, \
|
||||||
struct device_attribute *attr, char *page) \
|
struct device_attribute *attr, char *page) \
|
||||||
{ \
|
{ \
|
||||||
struct ptp_clock *ptp = dev_get_drvdata(dev); \
|
struct ptp_clock *ptp = dev_get_drvdata(dev); \
|
||||||
return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->info->name); \
|
return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->info->var); \
|
||||||
}
|
} \
|
||||||
|
static DEVICE_ATTR(name, 0444, var##_show, NULL);
|
||||||
|
|
||||||
PTP_SHOW_INT(max_adj);
|
PTP_SHOW_INT(max_adjustment, max_adj);
|
||||||
PTP_SHOW_INT(n_alarm);
|
PTP_SHOW_INT(n_alarms, n_alarm);
|
||||||
PTP_SHOW_INT(n_ext_ts);
|
PTP_SHOW_INT(n_external_timestamps, n_ext_ts);
|
||||||
PTP_SHOW_INT(n_per_out);
|
PTP_SHOW_INT(n_periodic_outputs, n_per_out);
|
||||||
PTP_SHOW_INT(pps);
|
PTP_SHOW_INT(pps_available, pps);
|
||||||
|
|
||||||
#define PTP_RO_ATTR(_var, _name) { \
|
static struct attribute *ptp_attrs[] = {
|
||||||
.attr = { .name = __stringify(_name), .mode = 0444 }, \
|
&dev_attr_clock_name.attr,
|
||||||
.show = _var##_show, \
|
&dev_attr_max_adjustment.attr,
|
||||||
}
|
&dev_attr_n_alarms.attr,
|
||||||
|
&dev_attr_n_external_timestamps.attr,
|
||||||
struct device_attribute ptp_dev_attrs[] = {
|
&dev_attr_n_periodic_outputs.attr,
|
||||||
PTP_RO_ATTR(clock_name, clock_name),
|
&dev_attr_pps_available.attr,
|
||||||
PTP_RO_ATTR(max_adj, max_adjustment),
|
NULL,
|
||||||
PTP_RO_ATTR(n_alarm, n_alarms),
|
|
||||||
PTP_RO_ATTR(n_ext_ts, n_external_timestamps),
|
|
||||||
PTP_RO_ATTR(n_per_out, n_periodic_outputs),
|
|
||||||
PTP_RO_ATTR(pps, pps_available),
|
|
||||||
__ATTR_NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct attribute_group ptp_group = {
|
||||||
|
.attrs = ptp_attrs,
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct attribute_group *ptp_groups[] = {
|
||||||
|
&ptp_group,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static ssize_t extts_enable_store(struct device *dev,
|
static ssize_t extts_enable_store(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user