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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
From 20642bfed99dac5559f88743c3043f33fa3e7796 Mon Sep 17 00:00:00 2001
From: Clayton Craft <clayton@craftyguy.net>
Date: Tue, 26 Sep 2017 19:42:11 -0700
Subject: [PATCH] nokia-gpio: do not create links to gpios in /dev/cmt
The nokia-gpio plugin should not try to create symlinks to relevant gpio
pins under /dev/cmt, since the location it is looking is no longer
correct on newer kernels and it might change again in the future. This
patch removes code from nokia-gpio that tries to create a symlink.
Users will now need to symlink the modem gpios to /dev/cmt themselves.
On the 4.13 kernel, this can be done by, for example, adding a udev rule
to:
# ln -sf /sys/bus/hsi/devices/n900-modem /dev/cmt
---
plugins/nokia-gpio.c | 67 ++++------------------------------------------------
1 file changed, 4 insertions(+), 63 deletions(-)
diff --git a/plugins/nokia-gpio.c b/plugins/nokia-gpio.c
index 7a93106c..1d014337 100644
--- a/plugins/nokia-gpio.c
+++ b/plugins/nokia-gpio.c
@@ -632,74 +632,15 @@ static void phonet_status_cb(GIsiModem *idx, enum GIsiPhonetLinkState state,
static int gpio_probe_links(void)
{
- char const *gpiodir = "/sys/class/gpio";
char const *cmtdir = "/dev/cmt";
- DIR *gpio;
- struct dirent *d;
- if (file_exists(cmtdir)) {
- DBG("Using %s", cmtdir);
- return 0;
- }
-
- DBG("Using %s: trying to make links to %s", gpiodir, cmtdir);
-
- if (!dir_exists(cmtdir)) {
- if (mkdir(cmtdir, 0755) == -1) {
- DBG("%s: %s", cmtdir, strerror(errno));
- return -(errno = ENODEV);
- }
- }
-
- gpio = opendir(gpiodir);
- if (gpio == NULL) {
- DBG("%s: %s", "gpiodir", strerror(errno));
+ if (!file_exists(cmtdir)) {
+ DBG("%s: %s", cmtdir, strerror(errno));
return -(errno = ENODEV);
}
- while ((d = readdir(gpio)) != NULL) {
- char nn[PATH_MAX], name[PATH_MAX], from[PATH_MAX], to[PATH_MAX];
- FILE *nf;
- size_t len;
-
- snprintf(nn, sizeof nn, "%s/%s/name", gpiodir, d->d_name);
-
- nf = fopen(nn, "rb");
- if (nf == NULL) {
- DBG("%s: %s", nn, strerror(errno));
- continue;
- }
-
- len = fread(name, sizeof name, 1, nf);
-
- if (ferror(nf)) {
- DBG("read from %s: %s", nn, strerror(errno));
- fclose(nf);
- continue;
- }
-
- fclose(nf);
-
- if (len < 4)
- continue;
-
- name[--len] = '\0';
-
- if (strncmp(name, "cmt_", 4))
- continue;
-
- snprintf(from, sizeof from, "%s/%s", gpiodir, d->d_name);
- snprintf(to, sizeof to, "%s/%s", cmtdir, name);
-
- if (symlink(from, to) == -1)
- DBG("%s: %s", to, strerror(errno));
- }
-
- DBG("%s: %s", "/sys/class/gpio", strerror(errno));
-
- (void) closedir(gpio);
-
- return -(errno = ENODEV);
+ DBG("Using %s", cmtdir);
+ return 0;
}
--
2.14.1
|