Beispiel #1
0
int module_loaded(const char *module)
{
    char sys_path[128];

    snprintf(sys_path, sizeof(sys_path), "/sys/module/%s", module);
    return d_exists(sys_path);
}
Beispiel #2
0
/* Export specified GPIO
 * @return:
 * 	0:	success
 *  otherwise:	fail
 */
static int __export_gpio(uint32_t gpio)
{
	char gpio_path[PATH_MAX], export_path[PATH_MAX], gpio_str[] = "999XXX";

	if (!d_exists(GPIOLIB_DIR)) {
		_dprintf("%s does not exist!\n", __func__);
		return -1;
	}
	sprintf(gpio_path, "%s/gpio%d", GPIOLIB_DIR, gpio);
	if (d_exists(gpio_path))
		return 0;

	sprintf(export_path, "%s/export", GPIOLIB_DIR);
	sprintf(gpio_str, "%d", gpio);
	f_write_string(export_path, gpio_str, 0, 0);

	return 0;
}