HID: alps: remove variables local to u1_init() from the device struct
Move dev_ctrl, dev_type, sen_line_num_x, sen_line_num_y, pitch_x, pitch_y, resolution, btn_info from u1_dev structure to "u1_init()", because these variables are only used in there. [jkosina@suse.cz: rewrite changelog] Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
c7083d3f53
commit
5992262d59
@ -61,14 +61,10 @@
|
|||||||
* @input2: pointer to the kernel input2 device
|
* @input2: pointer to the kernel input2 device
|
||||||
* @hdev: pointer to the struct hid_device
|
* @hdev: pointer to the struct hid_device
|
||||||
*
|
*
|
||||||
* @dev_ctrl: device control parameter
|
|
||||||
* @dev_type: device type
|
* @dev_type: device type
|
||||||
* @sen_line_num_x: number of sensor line of X
|
* @max_fingers: total number of fingers
|
||||||
* @sen_line_num_y: number of sensor line of Y
|
* @has_sp: boolean of sp existense
|
||||||
* @pitch_x: sensor pitch of X
|
* @sp_btn_info: button information
|
||||||
* @pitch_y: sensor pitch of Y
|
|
||||||
* @resolution: resolution
|
|
||||||
* @btn_info: button information
|
|
||||||
* @x_active_len_mm: active area length of X (mm)
|
* @x_active_len_mm: active area length of X (mm)
|
||||||
* @y_active_len_mm: active area length of Y (mm)
|
* @y_active_len_mm: active area length of Y (mm)
|
||||||
* @x_max: maximum x coordinate value
|
* @x_max: maximum x coordinate value
|
||||||
@ -77,22 +73,14 @@
|
|||||||
* @y_min: minimum y coordinate value
|
* @y_min: minimum y coordinate value
|
||||||
* @btn_cnt: number of buttons
|
* @btn_cnt: number of buttons
|
||||||
* @sp_btn_cnt: number of stick buttons
|
* @sp_btn_cnt: number of stick buttons
|
||||||
* @has_sp: boolean of sp existense
|
|
||||||
* @max_fingers: total number of fingers
|
|
||||||
*/
|
*/
|
||||||
struct u1_dev {
|
struct u1_dev {
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
struct input_dev *input2;
|
struct input_dev *input2;
|
||||||
struct hid_device *hdev;
|
struct hid_device *hdev;
|
||||||
|
|
||||||
u8 dev_ctrl;
|
u8 max_fingers;
|
||||||
u8 dev_type;
|
u8 has_sp;
|
||||||
u8 sen_line_num_x;
|
|
||||||
u8 sen_line_num_y;
|
|
||||||
u8 pitch_x;
|
|
||||||
u8 pitch_y;
|
|
||||||
u8 resolution;
|
|
||||||
u8 btn_info;
|
|
||||||
u8 sp_btn_info;
|
u8 sp_btn_info;
|
||||||
u32 x_active_len_mm;
|
u32 x_active_len_mm;
|
||||||
u32 y_active_len_mm;
|
u32 y_active_len_mm;
|
||||||
@ -102,8 +90,6 @@ struct u1_dev {
|
|||||||
u32 y_min;
|
u32 y_min;
|
||||||
u32 btn_cnt;
|
u32 btn_cnt;
|
||||||
u32 sp_btn_cnt;
|
u32 sp_btn_cnt;
|
||||||
u8 has_sp;
|
|
||||||
u8 max_fingers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int u1_read_write_register(struct hid_device *hdev, u32 address,
|
static int u1_read_write_register(struct hid_device *hdev, u32 address,
|
||||||
@ -266,78 +252,80 @@ static int alps_post_resume(struct hid_device *hdev)
|
|||||||
static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data)
|
static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
u8 tmp, dev_ctrl, sen_line_num_x, sen_line_num_y;
|
||||||
|
u8 pitch_x, pitch_y, resolution;
|
||||||
|
|
||||||
/* Device initialization */
|
/* Device initialization */
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1,
|
||||||
&pri_data->dev_ctrl, 0, true);
|
&dev_ctrl, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_DEV_CTRL_1 (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_DEV_CTRL_1 (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
pri_data->dev_ctrl &= ~U1_DISABLE_DEV;
|
dev_ctrl &= ~U1_DISABLE_DEV;
|
||||||
pri_data->dev_ctrl |= U1_TP_ABS_MODE;
|
dev_ctrl |= U1_TP_ABS_MODE;
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1,
|
||||||
NULL, pri_data->dev_ctrl, false);
|
NULL, dev_ctrl, false);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed to change TP mode (%d)\n", ret);
|
dev_err(&hdev->dev, "failed to change TP mode (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_X,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_X,
|
||||||
&pri_data->sen_line_num_x, 0, true);
|
&sen_line_num_x, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_NUM_SENS_X (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_NUM_SENS_X (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_Y,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_Y,
|
||||||
&pri_data->sen_line_num_y, 0, true);
|
&sen_line_num_y, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_NUM_SENS_Y (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_NUM_SENS_Y (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_X,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_X,
|
||||||
&pri_data->pitch_x, 0, true);
|
&pitch_x, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_PITCH_SENS_X (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_PITCH_SENS_X (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_Y,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_Y,
|
||||||
&pri_data->pitch_y, 0, true);
|
&pitch_y, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_PITCH_SENS_Y (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_PITCH_SENS_Y (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_RESO_DWN_ABS,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_RESO_DWN_ABS,
|
||||||
&pri_data->resolution, 0, true);
|
&resolution, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_RESO_DWN_ABS (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_RESO_DWN_ABS (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
pri_data->x_active_len_mm =
|
pri_data->x_active_len_mm =
|
||||||
(pri_data->pitch_x * (pri_data->sen_line_num_x - 1)) / 10;
|
(pitch_x * (sen_line_num_x - 1)) / 10;
|
||||||
pri_data->y_active_len_mm =
|
pri_data->y_active_len_mm =
|
||||||
(pri_data->pitch_y * (pri_data->sen_line_num_y - 1)) / 10;
|
(pitch_y * (sen_line_num_y - 1)) / 10;
|
||||||
|
|
||||||
pri_data->x_max =
|
pri_data->x_max =
|
||||||
(pri_data->resolution << 2) * (pri_data->sen_line_num_x - 1);
|
(resolution << 2) * (sen_line_num_x - 1);
|
||||||
pri_data->x_min = 1;
|
pri_data->x_min = 1;
|
||||||
pri_data->y_max =
|
pri_data->y_max =
|
||||||
(pri_data->resolution << 2) * (pri_data->sen_line_num_y - 1);
|
(resolution << 2) * (sen_line_num_y - 1);
|
||||||
pri_data->y_min = 1;
|
pri_data->y_min = 1;
|
||||||
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN,
|
||||||
&pri_data->btn_info, 0, true);
|
&tmp, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_PAD_BTN (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_PAD_BTN (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ((pri_data->btn_info & 0x0F) == (pri_data->btn_info & 0xF0) >> 4) {
|
if ((tmp & 0x0F) == (tmp & 0xF0) >> 4) {
|
||||||
pri_data->btn_cnt = (pri_data->btn_info & 0x0F);
|
pri_data->btn_cnt = (tmp & 0x0F);
|
||||||
} else {
|
} else {
|
||||||
/* Button pad */
|
/* Button pad */
|
||||||
pri_data->btn_cnt = 1;
|
pri_data->btn_cnt = 1;
|
||||||
@ -346,16 +334,15 @@ static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data)
|
|||||||
pri_data->has_sp = 0;
|
pri_data->has_sp = 0;
|
||||||
/* Check StickPointer device */
|
/* Check StickPointer device */
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_DEVICE_TYP,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_DEVICE_TYP,
|
||||||
&pri_data->dev_type, 0, true);
|
&tmp, 0, true);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed U1_DEVICE_TYP (%d)\n", ret);
|
dev_err(&hdev->dev, "failed U1_DEVICE_TYP (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
if (tmp & U1_DEVTYPE_SP_SUPPORT) {
|
||||||
if (pri_data->dev_type & U1_DEVTYPE_SP_SUPPORT) {
|
dev_ctrl |= U1_SP_ABS_MODE;
|
||||||
pri_data->dev_ctrl |= U1_SP_ABS_MODE;
|
|
||||||
ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1,
|
ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1,
|
||||||
NULL, pri_data->dev_ctrl, false);
|
NULL, dev_ctrl, false);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&hdev->dev, "failed SP mode (%d)\n", ret);
|
dev_err(&hdev->dev, "failed SP mode (%d)\n", ret);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user