Private
Public Access
2
0

gpio: Add gpio chardev interface

Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Mihai Stefanescu
2017-08-27 19:10:17 +02:00
committed by Brendan Le Foll
parent aa7006cce9
commit 1665e09928
4 changed files with 1477 additions and 237 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@
#include <unistd.h>
#include <ctype.h>
#include <limits.h>
#include <sys/utsname.h>
#if defined(IMRAA)
#include <json-c/json.h>
@@ -98,6 +98,57 @@ mraa_set_log_level(int level)
return MRAA_ERROR_INVALID_PARAMETER;
}
mraa_boolean_t mraa_is_kernel_chardev_interface_compatible()
{
struct utsname buf;
int status;
status = uname(&buf);
if (status) {
syslog(LOG_ERR, "uname() error");
return 0;
}
int major, minor;
char *token;
token = strtok(buf.release, ".");
if (token == NULL) {
syslog(LOG_ERR, "Could not find kernel version major number");
return 0;
}
status = mraa_atoi(token, &major);
if (status) {
syslog(LOG_ERR, "mraa_atoi() error");
return 0;
}
token = strtok(NULL, ".");
if (token == NULL) {
syslog(LOG_ERR, "Could not find kernel version minor number");
return 0;
}
status = mraa_atoi(token, &minor);
if (status) {
syslog(LOG_ERR, "mraa_atoi() error");
return 0;
}
if (major < 4 || minor < 8) {
syslog(LOG_ERR, "Kernel version %i.%i not supported for chardev interface. Need version 4.8 or newer!", major, minor);
return 0;
}
return 1;
}
/* TODO: Add all relevant checks here and return the overall result. */
mraa_boolean_t mraa_is_platform_chardev_interface_capable()
{
return mraa_is_kernel_chardev_interface_compatible();
}
/**
* Whilst the actual mraa init function is now called imraa_init, it's only
* callable externally if IMRAA is enabled
@@ -218,6 +269,11 @@ imraa_init()
return MRAA_ERROR_NO_RESOURCES;
}
plat->chardev_capable = mraa_is_platform_chardev_interface_capable();
if (plat->chardev_capable) {
syslog(LOG_NOTICE, "libmraa: support for chardev interface is activated");
}
syslog(LOG_NOTICE, "libmraa initialised for platform '%s' of type %d", mraa_get_platform_name(), mraa_get_platform_type());
return MRAA_SUCCESS;
}