staging: erofs: integrate decompression inplace
[linux/fpc-iii.git] / drivers / pps / sysfs.c
blob134bc33f6ad0056e4c4ddc6f56c58d43197535fa
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * PPS sysfs support
5 * Copyright (C) 2007-2009 Rodolfo Giometti <giometti@linux.it>
6 */
9 #include <linux/device.h>
10 #include <linux/module.h>
11 #include <linux/string.h>
12 #include <linux/pps_kernel.h>
15 * Attribute functions
18 static ssize_t assert_show(struct device *dev, struct device_attribute *attr,
19 char *buf)
21 struct pps_device *pps = dev_get_drvdata(dev);
23 if (!(pps->info.mode & PPS_CAPTUREASSERT))
24 return 0;
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,
33 char *buf)
35 struct pps_device *pps = dev_get_drvdata(dev);
37 if (!(pps->info.mode & PPS_CAPTURECLEAR))
38 return 0;
40 return sprintf(buf, "%lld.%09d#%d\n",
41 (long long) pps->clear_tu.sec, pps->clear_tu.nsec,
42 pps->clear_sequence);
44 static DEVICE_ATTR_RO(clear);
46 static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
47 char *buf)
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,
56 char *buf)
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,
65 char *buf)
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,
74 char *buf)
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,
84 &dev_attr_clear.attr,
85 &dev_attr_mode.attr,
86 &dev_attr_echo.attr,
87 &dev_attr_name.attr,
88 &dev_attr_path.attr,
89 NULL,
92 static const struct attribute_group pps_group = {
93 .attrs = pps_attrs,
96 const struct attribute_group *pps_groups[] = {
97 &pps_group,
98 NULL,