Esempio n. 1
0
	return err;
}

static int ev3_motor_remove(struct lego_device *ldev)
{
	struct ev3_motor_data *data = dev_get_drvdata(&ldev->dev);

	unregister_tacho_motor(&data->tm);
	dev_set_drvdata(&ldev->dev, NULL);
	kfree(data);

	return 0;
}

static const struct lego_device_id ev3_motor_driver_id_table[] = {
	LEGO_DEVICE_ID(LEGO_NXT_MOTOR),
	LEGO_DEVICE_ID(LEGO_EV3_LARGE_MOTOR),
	LEGO_DEVICE_ID(LEGO_EV3_MEDIUM_MOTOR),
	LEGO_DEVICE_ID(FIRGELLI_L12_EV3_50),
	LEGO_DEVICE_ID(FIRGELLI_L12_EV3_100),
};

static ssize_t driver_names_show(struct device_driver *drv, char *buf)
{
	int i;
	int size = 0;

	for (i = 0; i < NUM_EV3_MOTOR_ID; i++) {
		size += sprintf(buf + size, "%s ",
				ev3_motor_driver_id_table[i].name);
	}
	lego_port_set_raw_data_ptr_and_func(ldev->port, NULL, 0, NULL, NULL);
	unregister_lego_sensor(&data->sensor);
	dev_set_drvdata(&ldev->dev, NULL);
	kfree(data);
	return 0;
}

#define EV3_ANALOG_SENSOR_GENERIC(type) {		\
	.name		= type##_NAME,			\
	.driver_data	= GENERIC_EV3_ANALOG_SENSOR,	\
}

static struct lego_device_id ev3_analog_sensor_device_ids [] = {
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_01),
	LEGO_DEVICE_ID(LEGO_EV3_TOUCH_SENSOR),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_03),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_04),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_05),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_06),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_07),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_08),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_09),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_10),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_11),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_12),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_13),
	EV3_ANALOG_SENSOR_GENERIC(EV3_ANALOG_SENSOR_ID_14),
	{ }
};