Linux Audio

Check our new training course

Loading...
v3.1
 
 1/*
 2 * PPS sysfs support
 3 *
 4 *
 5 * Copyright (C) 2007-2009   Rodolfo Giometti <giometti@linux.it>
 6 *
 7 *   This program is free software; you can redistribute it and/or modify
 8 *   it under the terms of the GNU General Public License as published by
 9 *   the Free Software Foundation; either version 2 of the License, or
10 *   (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22
23#include <linux/device.h>
24#include <linux/module.h>
25#include <linux/string.h>
26#include <linux/pps_kernel.h>
27
28/*
29 * Attribute functions
30 */
31
32static ssize_t pps_show_assert(struct device *dev,
33				struct device_attribute *attr, char *buf)
34{
35	struct pps_device *pps = dev_get_drvdata(dev);
36
37	if (!(pps->info.mode & PPS_CAPTUREASSERT))
38		return 0;
39
40	return sprintf(buf, "%lld.%09d#%d\n",
41			(long long) pps->assert_tu.sec, pps->assert_tu.nsec,
42			pps->assert_sequence);
43}
 
44
45static ssize_t pps_show_clear(struct device *dev,
46				struct device_attribute *attr, char *buf)
47{
48	struct pps_device *pps = dev_get_drvdata(dev);
49
50	if (!(pps->info.mode & PPS_CAPTURECLEAR))
51		return 0;
52
53	return sprintf(buf, "%lld.%09d#%d\n",
54			(long long) pps->clear_tu.sec, pps->clear_tu.nsec,
55			pps->clear_sequence);
56}
 
57
58static ssize_t pps_show_mode(struct device *dev,
59				struct device_attribute *attr, char *buf)
60{
61	struct pps_device *pps = dev_get_drvdata(dev);
62
63	return sprintf(buf, "%4x\n", pps->info.mode);
64}
 
65
66static ssize_t pps_show_echo(struct device *dev,
67				struct device_attribute *attr, char *buf)
68{
69	struct pps_device *pps = dev_get_drvdata(dev);
70
71	return sprintf(buf, "%d\n", !!pps->info.echo);
72}
 
73
74static ssize_t pps_show_name(struct device *dev,
75				struct device_attribute *attr, char *buf)
76{
77	struct pps_device *pps = dev_get_drvdata(dev);
78
79	return sprintf(buf, "%s\n", pps->info.name);
80}
 
81
82static ssize_t pps_show_path(struct device *dev,
83				struct device_attribute *attr, char *buf)
84{
85	struct pps_device *pps = dev_get_drvdata(dev);
86
87	return sprintf(buf, "%s\n", pps->info.path);
88}
 
89
90struct 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,
 
 
 
 
 
 
 
 
 
98};
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 * PPS sysfs support
 4 *
 
 5 * Copyright (C) 2007-2009   Rodolfo Giometti <giometti@linux.it>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 6 */
 7
 8
 9#include <linux/device.h>
10#include <linux/module.h>
11#include <linux/string.h>
12#include <linux/pps_kernel.h>
13
14/*
15 * Attribute functions
16 */
17
18static ssize_t assert_show(struct device *dev, struct device_attribute *attr,
19			   char *buf)
20{
21	struct pps_device *pps = dev_get_drvdata(dev);
22
23	if (!(pps->info.mode & PPS_CAPTUREASSERT))
24		return 0;
25
26	return sprintf(buf, "%lld.%09d#%d\n",
27			(long long) pps->assert_tu.sec, pps->assert_tu.nsec,
28			pps->assert_sequence);
29}
30static DEVICE_ATTR_RO(assert);
31
32static ssize_t clear_show(struct device *dev, struct device_attribute *attr,
33			  char *buf)
34{
35	struct pps_device *pps = dev_get_drvdata(dev);
36
37	if (!(pps->info.mode & PPS_CAPTURECLEAR))
38		return 0;
39
40	return sprintf(buf, "%lld.%09d#%d\n",
41			(long long) pps->clear_tu.sec, pps->clear_tu.nsec,
42			pps->clear_sequence);
43}
44static DEVICE_ATTR_RO(clear);
45
46static ssize_t mode_show(struct device *dev, struct device_attribute *attr,
47			 char *buf)
48{
49	struct pps_device *pps = dev_get_drvdata(dev);
50
51	return sprintf(buf, "%4x\n", pps->info.mode);
52}
53static DEVICE_ATTR_RO(mode);
54
55static ssize_t echo_show(struct device *dev, struct device_attribute *attr,
56			 char *buf)
57{
58	struct pps_device *pps = dev_get_drvdata(dev);
59
60	return sprintf(buf, "%d\n", !!pps->info.echo);
61}
62static DEVICE_ATTR_RO(echo);
63
64static ssize_t name_show(struct device *dev, struct device_attribute *attr,
65			 char *buf)
66{
67	struct pps_device *pps = dev_get_drvdata(dev);
68
69	return sprintf(buf, "%s\n", pps->info.name);
70}
71static DEVICE_ATTR_RO(name);
72
73static ssize_t path_show(struct device *dev, struct device_attribute *attr,
74			 char *buf)
75{
76	struct pps_device *pps = dev_get_drvdata(dev);
77
78	return sprintf(buf, "%s\n", pps->info.path);
79}
80static DEVICE_ATTR_RO(path);
81
82static 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,
90};
91
92static const struct attribute_group pps_group = {
93	.attrs = pps_attrs,
94};
95
96const struct attribute_group *pps_groups[] = {
97	&pps_group,
98	NULL,
99};