Exemple #1
0
static int __init cyttsp5_mt_init(void)
{
    int rc;
    cyttsp5_mt_driver.driver.owner = THIS_MODULE;
    rc = cyttsp5_register_driver(&cyttsp5_mt_driver);
    pr_info("%s: Cypress TTSP v5 Multi-Touch A Driver (Built %s), rc=%d\n",
            __func__, CY_DRIVER_DATE, rc);
    return rc;
}
static int __init cyttsp5_device_access_init(void)
{
	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;
			}
	}

	for (i = 0; i < num_core_ids; i++) {
		cyttsp5_device_access_infos[i].name =
			cyttsp5_device_access_name;
		cyttsp5_device_access_infos[i].core_id = core_ids[i];
		cyttsp5_device_access_infos[i].platform_data =
			&_cyttsp5_device_access_platform_data;
		pr_info("%s: Registering device access device for core_id: %s\n",
			__func__, cyttsp5_device_access_infos[i].core_id);
		rc = cyttsp5_register_device(&cyttsp5_device_access_infos[i]);
		if (rc < 0) {
			pr_err("%s: Error, failed registering device\n",
				__func__);
			goto fail_unregister_devices;
		}
	}
	rc = cyttsp5_register_driver(&cyttsp5_device_access_driver);
	if (rc) {
		pr_err("%s: Error, failed registering driver\n", __func__);
		goto fail_unregister_devices;
	}

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

fail_unregister_devices:
	for (i--; i <= 0; i--) {
		cyttsp5_unregister_device(cyttsp5_device_access_infos[i].name,
			cyttsp5_device_access_infos[i].core_id);
		pr_info("%s: Unregistering device access device for core_id: %s\n",
			__func__, cyttsp5_device_access_infos[i].core_id);
	}
	return rc;
}