예제 #1
0
int tilib_api_init(void)
{
	int ret;

	lib_handle = dynload_open(tilib_filename);
	if (!lib_handle) {
		printc_err("tilib_api: can't find %s: %s\n",
			   tilib_filename, dynload_error());
		return -1;
	}

	if (dynload_sym(lib_handle, "MSP430_HIL_MEMAP")) {
		printc_dbg("Using new (SLAC460L+) API\n");
		ret = init_new_api();
	} else {
		printc_dbg("Using old API\n");
		ret = init_old_api();
	}

	if (ret < 0) {
		dynload_close(lib_handle);
		return -1;
	}

	return 0;
}
예제 #2
0
파일: tilib.c 프로젝트: Murali8051/Aurava
static device_t tilib_open(const struct device_args *args)
{
	struct tilib_device *dev;

	if (!(args->flags & DEVICE_FLAG_TTY)) {
		printc_err("This driver does not support raw USB access.\n");
		return NULL;
	}

	dev = malloc(sizeof(*dev));
	if (!dev) {
		printc_err("tilib: can't allocate memory: %s\n",
			   last_error());
		return NULL;
	}

	memset(dev, 0, sizeof(*dev));
	dev->base.type = &device_tilib;

	dev->hnd = dynload_open(tilib_filename);
	if (!dev->hnd) {
		printc_err("tilib: can't find %s: %s\n",
			   tilib_filename, dynload_error());
		free(dev);
		return NULL;
	}

	if (get_all_funcs(dev) < 0) {
		dynload_close(dev->hnd);
		free(dev);
		return NULL;
	}

	if (do_init(dev, args) < 0) {
		printc_err("tilib: device initialization failed\n");
		dynload_close(dev->hnd);
		free(dev);
		return NULL;
	}

	return (device_t)dev;
}