mirror of git://git.sysmocom.de/ofono
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
This commit is contained in:
parent
61bbbb0d7a
commit
c33c567ef6
|
@ -143,13 +143,6 @@ static int file_exists(char const *filename)
|
||||||
return stat(filename, &st) == 0;
|
return stat(filename, &st) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dir_exists(char const *filename)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
|
|
||||||
return stat(filename, &st) == 0 && S_ISDIR(st.st_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int file_write(char const *filename, char const *output)
|
static int file_write(char const *filename, char const *output)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -632,74 +625,15 @@ static void phonet_status_cb(GIsiModem *idx, enum GIsiPhonetLinkState state,
|
||||||
|
|
||||||
static int gpio_probe_links(void)
|
static int gpio_probe_links(void)
|
||||||
{
|
{
|
||||||
char const *gpiodir = "/sys/class/gpio";
|
|
||||||
char const *cmtdir = "/dev/cmt";
|
char const *cmtdir = "/dev/cmt";
|
||||||
DIR *gpio;
|
|
||||||
struct dirent *d;
|
|
||||||
|
|
||||||
if (file_exists(cmtdir)) {
|
if (!file_exists(cmtdir)) {
|
||||||
DBG("Using %s", cmtdir);
|
DBG("%s: %s", cmtdir, strerror(errno));
|
||||||
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));
|
|
||||||
return -(errno = ENODEV);
|
return -(errno = ENODEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((d = readdir(gpio)) != NULL) {
|
DBG("Using %s", cmtdir);
|
||||||
char nn[PATH_MAX], name[PATH_MAX], from[PATH_MAX], to[PATH_MAX];
|
return 0;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue