static int rmi_spi_remove(struct spi_device *spi) { struct rmi_spi_xport *rmi_spi = spi_get_drvdata(spi); rmi_unregister_transport_device(&rmi_spi->xport); return 0; }
static int rmi_smb_remove(struct i2c_client *client) { struct rmi_smb_xport *rmi_smb = i2c_get_clientdata(client); rmi_unregister_transport_device(&rmi_smb->xport); return 0; }
static void rmi_hid_remove(struct hid_device *hdev) { struct rmi_transport_device *xport = hid_get_drvdata(hdev); struct rmi_hid_data * hdata = xport->data; clear_bit(RMI_HID_STARTED, &hdata->flags); cancel_work_sync(&hdata->attn_report_work); cancel_work_sync(&hdata->reset_work); if (IS_ENABLED(CONFIG_RMI4_DEBUG)) teardown_debugfs(xport->data); rmi_unregister_transport_device(xport); hdev->ll_driver->close(hdev); hid_hw_stop(hdev); }
static int rmi_hid_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct rmi_transport_device *xport = NULL; struct rmi_hid_data *data = NULL; unsigned int connect_mask = HID_CONNECT_HIDRAW | HID_CONNECT_HIDDEV; int ret; dev_dbg(&hdev->dev, "%s\n", __func__); xport = devm_kzalloc(&hdev->dev, sizeof(struct rmi_transport_device), GFP_KERNEL); if (!xport) { ret = -ENOMEM; goto err; } data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_hid_data), GFP_KERNEL); if (!data) { ret =-ENOMEM; goto err; } data->xport = xport; xport->data = data; xport->dev = &hdev->dev; xport->write_block = rmi_hid_write_block; xport->read_block = rmi_hid_read_block; xport->info.proto_type = RMI_PROTOCOL_HID; xport->info.proto = transport_proto_name; xport->post_reset = rmi_hid_post_reset; hid_set_drvdata(hdev, xport); ret = hid_parse(hdev); if (ret) { hid_err(hdev, "parse failed\n"); goto err; } data->input_report_size = (hdev->report_enum[HID_INPUT_REPORT] .report_id_hash[RMI_ATTN_REPORT_ID]->size >> 3) + 1 /* report id */; data->output_report_size = (hdev->report_enum[HID_OUTPUT_REPORT] .report_id_hash[RMI_WRITE_REPORT_ID]->size >> 3) + 1 /* report id */; data->feature_report_size = (hdev->report_enum[HID_FEATURE_REPORT] .report_id_hash[RMI_SET_RMI_MODE_REPORT_ID]->size >> 3) + 1 /* report id */; dev_dbg(&hdev->dev, "input report size %d\n", data->input_report_size); dev_dbg(&hdev->dev, "output report size %d\n", data->output_report_size); dev_dbg(&hdev->dev, "feature report size %d\n", data->feature_report_size); data->input_queue = devm_kzalloc(&hdev->dev, data->input_report_size * RMI_HID_INPUT_REPORT_QUEUE_LEN, GFP_KERNEL); if (!data->input_queue) { ret = -ENOMEM; goto err; } data->writeReport = devm_kzalloc(&hdev->dev, data->output_report_size, GFP_KERNEL); if (!data->writeReport) { ret = -ENOMEM; goto err; } data->readReport = devm_kzalloc(&hdev->dev, data->input_report_size, GFP_KERNEL); if (!data->readReport) { ret = -ENOMEM; goto err; } data->attnReport = devm_kzalloc(&hdev->dev, data->input_report_size, GFP_KERNEL); if (!data->attnReport) { ret = -ENOMEM; goto err; } tp_platformdata.pm_data = hdev; xport->dev->platform_data = &tp_platformdata; #ifdef TOUCHPAD_WAKE_SYSTEM if (tp_platformdata.f11_sensor_data[0].sensor_type == rmi_sensor_touchpad) { device_init_wakeup(hdev->dev.parent, 1); } #endif spin_lock_init(&data->input_queue_consumer_lock); spin_lock_init(&data->input_queue_producer_lock); data->input_queue_head = 0; data->input_queue_tail = 0; INIT_WORK(&data->attn_report_work, rmi_hid_attn_report_work); INIT_WORK(&data->reset_work, rmi_hid_reset_work); init_waitqueue_head(&data->wait); mutex_init(&data->page_mutex); ret = hid_hw_start(hdev, connect_mask); if (ret) { hid_err(hdev, "hw start failed\n"); goto err; } dev_dbg(&hdev->dev, "Opening low level driver\n"); hdev->ll_driver->open(hdev); /* Allow incoming hid reports */ hid_device_io_start(hdev); ret = rmi_hid_set_mode(hdev, RMI_HID_MODE_ATTN_REPORTS); if (ret < 0) { dev_err(&hdev->dev, "failed to set rmi mode\n"); goto rmi_read_failed; } ret = rmi_set_page(xport, 0); if (ret < 0) { dev_err(&hdev->dev, "failed to set page select to 0.\n"); goto rmi_read_failed; } ret = rmi_register_transport_device(xport); if (ret) { dev_err(&hdev->dev, "failed to register transport device at %s\n", hdev->phys); goto rmi_read_failed; } if (!xport->probe_succeeded) { dev_err(&hdev->dev, "Probe failed in rmi_driver\n"); ret = -ENODEV; goto rmi_driver_probe_failed; } set_bit(RMI_HID_STARTED, &data->flags); if (IS_ENABLED(CONFIG_RMI4_DEBUG)) ret = setup_debugfs(xport->rmi_dev, data); dev_info(&hdev->dev, "registered rmi hid driver at %s\n", hdev->phys); return 0; rmi_driver_probe_failed: rmi_unregister_transport_device(xport); rmi_read_failed: hdev->ll_driver->close(hdev); hid_hw_stop(hdev); err: return ret; }