1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2007-2009 Rodolfo Giometti <giometti@linux.it>
9 #include <linux/device.h>
10 #include <linux/module.h>
11 #include <linux/string.h>
12 #include <linux/pps_kernel.h>
18 static ssize_t assert_show(struct device *dev, struct device_attribute *attr,
21 struct pps_device *pps = dev_get_drvdata(dev);
23 if (!(pps->info.mode & PPS_CAPTUREASSERT))
26 return sprintf(buf, "%lld.%09d#%d\n",
27 (long long) pps->assert_tu.sec, pps->assert_tu.nsec,
28 pps->assert_sequence);
30 static DEVICE_ATTR_RO(assert);
32 static ssize_t clear_show(struct device *dev, struct device_attribute *attr,
35 struct pps_device *pps = dev_get_drvdata(dev);
37 if (!(pps->info.mode & PPS_CAPTURECLEAR))
40 return sprintf(buf, "%lld.%09d#%d\n",
41 (long long) pps->clear_tu.sec, pps->clear_tu.nsec,
44 static DEVICE_ATTR_RO(clear);
46 static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
49 struct pps_device *pps = dev_get_drvdata(dev);
51 return sprintf(buf, "%4x\n", pps->info.mode);
53 static DEVICE_ATTR_RO(mode);
55 static ssize_t echo_show(struct device *dev, struct device_attribute *attr,
58 struct pps_device *pps = dev_get_drvdata(dev);
60 return sprintf(buf, "%d\n", !!pps->info.echo);
62 static DEVICE_ATTR_RO(echo);
64 static ssize_t name_show(struct device *dev, struct device_attribute *attr,
67 struct pps_device *pps = dev_get_drvdata(dev);
69 return sprintf(buf, "%s\n", pps->info.name);
71 static DEVICE_ATTR_RO(name);
73 static ssize_t path_show(struct device *dev, struct device_attribute *attr,
76 struct pps_device *pps = dev_get_drvdata(dev);
78 return sprintf(buf, "%s\n", pps->info.path);
80 static DEVICE_ATTR_RO(path);
82 static struct attribute *pps_attrs[] = {
83 &dev_attr_assert.attr,
92 static const struct attribute_group pps_group = {
96 const struct attribute_group *pps_groups[] = {