File: sysfs.c

package info (click to toggle)
linux 5.10.46-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,191,996 kB
  • sloc: ansic: 19,502,768; asm: 263,759; sh: 73,960; makefile: 44,724; perl: 34,644; python: 32,387; cpp: 6,070; yacc: 4,755; lex: 2,742; awk: 1,214; ruby: 25; sed: 5
file content (49 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-License-Identifier: GPL-2.0
/*
 * sysfs.c - MediaLB sysfs information
 *
 * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
 */

/* Author: Andrey Shvetsov <andrey.shvetsov@k2l.de> */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include "sysfs.h"
#include <linux/device.h>

static ssize_t state_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{
	bool state = dim2_sysfs_get_state_cb();

	return sprintf(buf, "%s\n", state ? "locked" : "");
}

static DEVICE_ATTR_RO(state);

static struct attribute *dev_attrs[] = {
	&dev_attr_state.attr,
	NULL,
};

static struct attribute_group dev_attr_group = {
	.attrs = dev_attrs,
};

static const struct attribute_group *dev_attr_groups[] = {
	&dev_attr_group,
	NULL,
};

int dim2_sysfs_probe(struct device *dev)
{
	dev->groups = dev_attr_groups;
	return device_register(dev);
}

void dim2_sysfs_destroy(struct device *dev)
{
	device_unregister(dev);
}