static int __init cyttsp5_loader_init(void)
{
	struct cyttsp5_core_data *cd;
	int rc = 0;
	int i, j;

	/* Check for invalid or duplicate core_ids */
	for (i = 0; i < num_core_ids; i++) {
		if (!strlen(core_ids[i])) {
			pr_err("%s: core_id %d is empty\n",
				__func__, i+1);
			return -EINVAL;
		}
		for (j = i+1; j < num_core_ids; j++) {
			if (!strcmp(core_ids[i], core_ids[j])) {
				pr_err("%s: core_ids %d and %d are same\n",
					__func__, i+1, j+1);
				return -EINVAL;
			}
		}
	}

	cmd = cyttsp5_get_commands();
	if (!cmd)
		return -EINVAL;

	for (i = 0; i < num_core_ids; i++) {
		cd = cyttsp5_get_core_data(core_ids[i]);
		if (!cd)
			continue;

		pr_info("%s: Registering loader module for core_id: %s\n",
			__func__, core_ids[i]);
		rc = cyttsp5_loader_probe(cd->dev);
		if (rc < 0) {
			pr_err("%s: Error, failed registering module\n",
				__func__);
			goto fail_unregister_devices;
		}
	}

	pr_info("%s: Cypress TTSP FW Loader Driver (Built %s) rc=%d\n",
		 __func__, CY_DRIVER_DATE, rc);
	return 0;

fail_unregister_devices:
	for (i--; i >= 0; i--) {
		cd = cyttsp5_get_core_data(core_ids[i]);
		if (!cd)
			continue;
		cyttsp5_loader_release(cd->dev);
		pr_info("%s: Unregistering loader module for core_id: %s\n",
			__func__, core_ids[i]);
	}
	return rc;
}
int cyttsp5_device_access_user_command(const char *core_name, u16 read_len,
		u8 *read_buf, u16 write_len, u8 *write_buf,
		u16 *actual_read_len)
{
	struct cyttsp5_core_data *cd;
	int rc;

	might_sleep();

	/* Check parameters */
	if (!read_buf || !write_buf || !actual_read_len)
		return -EINVAL;

	if (!core_name)
		core_name = CY_DEFAULT_CORE_ID;

	/* Find device */
	cd = cyttsp5_get_core_data((char *)core_name);
	if (!cd) {
		pr_err("%s: No device.\n", __func__);
		return -ENODEV;
	}

	pm_runtime_get_sync(cd->dev);
	rc = cmd->nonhid_cmd->user_cmd(cd->dev, 1, read_len, read_buf,
			write_len, write_buf, actual_read_len);
	pm_runtime_put(cd->dev);

	return rc;
}
static void __exit cyttsp5_loader_exit(void)
{
	struct cyttsp5_core_data *cd;
	int i;

	for (i = 0; i < num_core_ids; i++) {
		cd = cyttsp5_get_core_data(core_ids[i]);
		if (!cd)
			continue;
		cyttsp5_loader_release(cd->dev);
		pr_info("%s: Unregistering loader module for core_id: %s\n",
			__func__, core_ids[i]);
	}
}