Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edf48f3a authored by Henrik Rydberg's avatar Henrik Rydberg Committed by Guenter Roeck
Browse files

hwmon: (applesmc) Skip sensor mapping



The special motion sensor mapping is unnecessary; remove it.

Signed-off-by: default avatarHenrik Rydberg <rydberg@euromail.se>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0ef63e48
Loading
Loading
Loading
Loading
+13 −28
Original line number Original line Diff line number Diff line
@@ -96,10 +96,6 @@ static const char *const fan_speed_fmt[] = {
#define APPLESMC_INPUT_FUZZ	4	/* input event threshold */
#define APPLESMC_INPUT_FUZZ	4	/* input event threshold */
#define APPLESMC_INPUT_FLAT	4
#define APPLESMC_INPUT_FLAT	4


#define SENSOR_X 0
#define SENSOR_Y 1
#define SENSOR_Z 2

#define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff)
#define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff)
#define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16)
#define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16)


@@ -432,30 +428,19 @@ static int applesmc_has_key(const char *key, bool *value)
}
}


/*
/*
 * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z).
 * applesmc_read_s16 - Read 16-bit signed big endian register
 */
 */
static int applesmc_read_motion_sensor(int index, s16 *value)
static int applesmc_read_s16(const char *key, s16 *value)
{
{
	u8 buffer[2];
	u8 buffer[2];
	int ret;
	int ret;


	switch (index) {
	ret = applesmc_read_key(key, buffer, 2);
	case SENSOR_X:
	if (ret)
		ret = applesmc_read_key(MOTION_SENSOR_X_KEY, buffer, 2);
		return ret;
		break;
	case SENSOR_Y:
		ret = applesmc_read_key(MOTION_SENSOR_Y_KEY, buffer, 2);
		break;
	case SENSOR_Z:
		ret = applesmc_read_key(MOTION_SENSOR_Z_KEY, buffer, 2);
		break;
	default:
		ret = -EINVAL;
	}


	*value = ((s16)buffer[0] << 8) | buffer[1];
	*value = ((s16)buffer[0] << 8) | buffer[1];

	return 0;
	return ret;
}
}


/*
/*
@@ -624,8 +609,8 @@ static struct platform_driver applesmc_driver = {
 */
 */
static void applesmc_calibrate(void)
static void applesmc_calibrate(void)
{
{
	applesmc_read_motion_sensor(SENSOR_X, &rest_x);
	applesmc_read_s16(MOTION_SENSOR_X_KEY, &rest_x);
	applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
	applesmc_read_s16(MOTION_SENSOR_Y_KEY, &rest_y);
	rest_x = -rest_x;
	rest_x = -rest_x;
}
}


@@ -634,9 +619,9 @@ static void applesmc_idev_poll(struct input_polled_dev *dev)
	struct input_dev *idev = dev->input;
	struct input_dev *idev = dev->input;
	s16 x, y;
	s16 x, y;


	if (applesmc_read_motion_sensor(SENSOR_X, &x))
	if (applesmc_read_s16(MOTION_SENSOR_X_KEY, &x))
		return;
		return;
	if (applesmc_read_motion_sensor(SENSOR_Y, &y))
	if (applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y))
		return;
		return;


	x = -x;
	x = -x;
@@ -659,13 +644,13 @@ static ssize_t applesmc_position_show(struct device *dev,
	int ret;
	int ret;
	s16 x, y, z;
	s16 x, y, z;


	ret = applesmc_read_motion_sensor(SENSOR_X, &x);
	ret = applesmc_read_s16(MOTION_SENSOR_X_KEY, &x);
	if (ret)
	if (ret)
		goto out;
		goto out;
	ret = applesmc_read_motion_sensor(SENSOR_Y, &y);
	ret = applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y);
	if (ret)
	if (ret)
		goto out;
		goto out;
	ret = applesmc_read_motion_sensor(SENSOR_Z, &z);
	ret = applesmc_read_s16(MOTION_SENSOR_Z_KEY, &z);
	if (ret)
	if (ret)
		goto out;
		goto out;