aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hid-tmff2.c36
-rw-r--r--src/hid-tmff2.h11
-rw-r--r--src/tmt248/hid-tmt248.c17
-rw-r--r--src/tmt300rs/hid-tmt300rs.c16
-rw-r--r--src/tmtspc/hid-tmtspc.c16
-rw-r--r--src/tmtsxw/hid-tmtsxw.c16
-rw-r--r--src/tmtx/hid-tmtx.c16
7 files changed, 39 insertions, 89 deletions
diff --git a/src/hid-tmff2.c b/src/hid-tmff2.c
index 162a30a..3b3c0cc 100644
--- a/src/hid-tmff2.c
+++ b/src/hid-tmff2.c
@@ -486,24 +486,26 @@ static int tmff2_play(struct input_dev *dev, int effect_id, int value)
return 0;
}
-static int tmff2_open(struct input_dev *dev)
+static void tmff2_open(struct hid_device *hdev)
{
- struct tmff2_device_entry *tmff2 = tmff2_from_input(dev);
+ struct tmff2_device_entry *tmff2 = hid_get_drvdata(hdev);
- if (!tmff2)
- return -ENODEV;
+ pr_err("entering tmff2_open\n");
+
+ if (!tmff2) {
+ pr_err("no device entry\n");
+ return;
+ }
if (tmff2->open)
return tmff2->open(tmff2->data, open_mode);
-
- hid_err(tmff2->hdev, "no open callback set\n");
- return -EINVAL;
}
-static void tmff2_close(struct input_dev *dev)
+static void tmff2_close(struct hid_device *hdev)
{
- struct tmff2_device_entry *tmff2 = tmff2_from_input(dev);
+ struct tmff2_device_entry *tmff2 = hid_get_drvdata(hdev);
+ pr_err("entering tmff2_close\n");
if (!tmff2)
return;
@@ -512,12 +514,8 @@ static void tmff2_close(struct input_dev *dev)
* time */
cancel_delayed_work_sync(&tmff2->work);
- if (tmff2->close) {
- tmff2->close(tmff2->data, open_mode);
- return;
- }
-
- hid_err(tmff2->hdev, "no close callback set\n");
+ if (tmff2->close)
+ return tmff2->close(tmff2->data, open_mode);
}
static int tmff2_create_files(struct tmff2_device_entry *tmff2)
@@ -634,12 +632,6 @@ static int tmff2_wheel_init(struct tmff2_device_entry *tmff2)
ff->upload = tmff2_upload;
ff->playback = tmff2_play;
- if (tmff2->open)
- tmff2->input_dev->open = tmff2_open;
-
- if (tmff2->close)
- tmff2->input_dev->close = tmff2_close;
-
/* set defaults wherever possible */
if (tmff2->set_gain) {
ff->set_gain = tmff2_set_gain;
@@ -825,6 +817,8 @@ static struct hid_driver tmff2_driver = {
.probe = tmff2_probe,
.remove = tmff2_remove,
.report_fixup = tmff2_report_fixup,
+ .on_hid_hw_open = tmff2_open,
+ .on_hid_hw_close = tmff2_close
};
module_hid_driver(tmff2_driver);
diff --git a/src/hid-tmff2.h b/src/hid-tmff2.h
index 6ad1d82..213bebe 100644
--- a/src/hid-tmff2.h
+++ b/src/hid-tmff2.h
@@ -82,8 +82,8 @@ struct tmff2_device_entry {
int (*wheel_destroy)(void *data);
/* optional callbacks */
- int (*open)(void *data, int);
- int (*close)(void *data, int);
+ void (*open)(void *data, int);
+ void (*close)(void *data, int);
int (*set_gain)(void *data, uint16_t gain);
int (*set_range)(void *data, uint16_t range);
/* switch_mode is required to not do anything if we're alredy in the
@@ -128,9 +128,6 @@ struct t300rs_device_entry {
struct hid_field *ff_field;
struct usb_device *usbdev;
- int (*open)(struct input_dev *dev);
- void (*close)(struct input_dev *dev);
-
int mode;
int attachment;
u8 buffer_length;
@@ -142,8 +139,8 @@ int t300rs_upload_effect(void *, const struct tmff2_effect_state *);
int t300rs_update_effect(void *, const struct tmff2_effect_state *);
int t300rs_stop_effect(void *, const struct tmff2_effect_state *);
-int t300rs_open(void *, int);
-int t300rs_close(void *, int);
+void t300rs_open(void *, int);
+void t300rs_close(void *, int);
int t300rs_set_gain(void *, uint16_t);
int t300rs_set_range(void *, uint16_t);
int t300rs_set_autocenter(void *, uint16_t);
diff --git a/src/tmt248/hid-tmt248.c b/src/tmt248/hid-tmt248.c
index 9ac43d9..4c42264 100644
--- a/src/tmt248/hid-tmt248.c
+++ b/src/tmt248/hid-tmt248.c
@@ -208,17 +208,15 @@ static int t248_send_open(struct t300rs_device_entry *t248)
return 0;
}
-static int t248_open(void *data, int open_mode)
+static void t248_open(void *data, int open_mode)
{
struct t300rs_device_entry *t248 = data;
if (!t248)
- return -ENODEV;
+ return;
if (open_mode)
t248_send_open(t248);
-
- return t248->open(t248->input_dev);
}
static int t248_send_close(struct t300rs_device_entry *t248)
@@ -237,18 +235,14 @@ static int t248_send_close(struct t300rs_device_entry *t248)
return 0;
}
-static int t248_close(void *data, int open_mode)
+static void t248_close(void *data, int open_mode)
{
struct t300rs_device_entry *t248 = data;
-
if (!t248)
- return -ENODEV;
+ return;
if (open_mode)
t248_send_close(t248);
-
- t248->close(t248->input_dev);
- return 0;
}
static int t248_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
@@ -279,9 +273,6 @@ static int t248_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
t248->report = list_entry(report_list->next, struct hid_report, list);
t248->ff_field = t248->report->field[0];
- t248->open = t248->input_dev->open;
- t248->close = t248->input_dev->close;
-
if ((ret = t248_interrupts(t248)))
goto interrupt_err;
diff --git a/src/tmt300rs/hid-tmt300rs.c b/src/tmt300rs/hid-tmt300rs.c
index 00eecee..689466f 100644
--- a/src/tmt300rs/hid-tmt300rs.c
+++ b/src/tmt300rs/hid-tmt300rs.c
@@ -1287,31 +1287,26 @@ static int t300rs_send_close(struct t300rs_device_entry *t300rs)
return t300rs_send_int(t300rs);
}
-int t300rs_open(void *data, int open_mode)
+void t300rs_open(void *data, int open_mode)
{
struct t300rs_device_entry *t300rs = data;
if (!t300rs)
- return -ENODEV;
+ return;
if (open_mode && t300rs_send_open(t300rs))
hid_warn(t300rs->hdev, "failed sending open command\n");
-
- return t300rs->open(t300rs->input_dev);
}
-int t300rs_close(void *data, int open_mode)
+void t300rs_close(void *data, int open_mode)
{
struct t300rs_device_entry *t300rs = data;
int ret = 0;
if (!t300rs)
- return -ENODEV;
+ return;
if (open_mode && (ret = t300rs_send_close(t300rs)))
hid_warn(t300rs->hdev, "failed sending close command\n");
-
- t300rs->close(t300rs->input_dev);
- return ret;
}
static int t300rs_check_firmware(struct t300rs_device_entry *t300rs)
@@ -1469,9 +1464,6 @@ static int t300rs_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
t300rs->report = list_entry(report_list->next, struct hid_report, list);
t300rs->ff_field = t300rs->report->field[0];
- t300rs->open = t300rs->input_dev->open;
- t300rs->close = t300rs->input_dev->close;
-
/* TODO: PS4 advanced mode? */
alt_mode = (t300rs->mode = (t300rs->hdev->product == TMT300RS_PS3_ADV_ID));
if ((t300rs->attachment = t300rs_get_attachment(t300rs)) < 0)
diff --git a/src/tmtspc/hid-tmtspc.c b/src/tmtspc/hid-tmtspc.c
index a51ec01..031358a 100644
--- a/src/tmtspc/hid-tmtspc.c
+++ b/src/tmtspc/hid-tmtspc.c
@@ -197,17 +197,15 @@ static int tspc_send_open(struct t300rs_device_entry *tspc)
return 0;
}
-static int tspc_open(void *data, int open_mode)
+static void tspc_open(void *data, int open_mode)
{
struct t300rs_device_entry *tspc = data;
if (!tspc)
- return -ENODEV;
+ return;
if (open_mode)
tspc_send_open(tspc);
-
- return tspc->open(tspc->input_dev);
}
static int tspc_send_close(struct t300rs_device_entry *tspc)
@@ -226,18 +224,15 @@ static int tspc_send_close(struct t300rs_device_entry *tspc)
return 0;
}
-static int tspc_close(void *data, int open_mode)
+static void tspc_close(void *data, int open_mode)
{
struct t300rs_device_entry *tspc = data;
if (!tspc)
- return -ENODEV;
+ return;
if (open_mode)
tspc_send_close(tspc);
-
- tspc->close(tspc->input_dev);
- return 0;
}
static int tspc_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
@@ -268,9 +263,6 @@ static int tspc_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
tspc->report = list_entry(report_list->next, struct hid_report, list);
tspc->ff_field = tspc->report->field[0];
- tspc->open = tspc->input_dev->open;
- tspc->close = tspc->input_dev->close;
-
if ((ret = tspc_interrupts(tspc)))
goto interrupt_err;
diff --git a/src/tmtsxw/hid-tmtsxw.c b/src/tmtsxw/hid-tmtsxw.c
index b8ee1fd..ac44bdb 100644
--- a/src/tmtsxw/hid-tmtsxw.c
+++ b/src/tmtsxw/hid-tmtsxw.c
@@ -196,17 +196,15 @@ static int tsxw_send_open(struct t300rs_device_entry *tsxw)
return 0;
}
-static int tsxw_open(void *data, int open_mode)
+static void tsxw_open(void *data, int open_mode)
{
struct t300rs_device_entry *tsxw = data;
if (!tsxw)
- return -ENODEV;
+ return;
if (open_mode)
tsxw_send_open(tsxw);
-
- return tsxw->open(tsxw->input_dev);
}
static int tsxw_send_close(struct t300rs_device_entry *tsxw)
@@ -225,18 +223,15 @@ static int tsxw_send_close(struct t300rs_device_entry *tsxw)
return 0;
}
-static int tsxw_close(void *data, int open_mode)
+static void tsxw_close(void *data, int open_mode)
{
struct t300rs_device_entry *tsxw = data;
if (!tsxw)
- return -ENODEV;
+ return;
if (open_mode)
tsxw_send_close(tsxw);
-
- tsxw->close(tsxw->input_dev);
- return 0;
}
static int tsxw_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
@@ -267,9 +262,6 @@ static int tsxw_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
tsxw->report = list_entry(report_list->next, struct hid_report, list);
tsxw->ff_field = tsxw->report->field[0];
- tsxw->open = tsxw->input_dev->open;
- tsxw->close = tsxw->input_dev->close;
-
if ((ret = tsxw_interrupts(tsxw)))
goto interrupt_err;
diff --git a/src/tmtx/hid-tmtx.c b/src/tmtx/hid-tmtx.c
index 857886c..f1f1b32 100644
--- a/src/tmtx/hid-tmtx.c
+++ b/src/tmtx/hid-tmtx.c
@@ -196,17 +196,15 @@ static int tx_send_open(struct t300rs_device_entry *tx)
return 0;
}
-static int tx_open(void *data, int open_mode)
+static void tx_open(void *data, int open_mode)
{
struct t300rs_device_entry *tx = data;
if (!tx)
- return -ENODEV;
+ return;
if (open_mode)
tx_send_open(tx);
-
- return tx->open(tx->input_dev);
}
static int tx_send_close(struct t300rs_device_entry *tx)
@@ -225,18 +223,15 @@ static int tx_send_close(struct t300rs_device_entry *tx)
return 0;
}
-static int tx_close(void *data, int open_mode)
+static void tx_close(void *data, int open_mode)
{
struct t300rs_device_entry *tx = data;
if (!tx)
- return -ENODEV;
+ return;
if (open_mode)
tx_send_close(tx);
-
- tx->close(tx->input_dev);
- return 0;
}
static int tx_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
@@ -267,9 +262,6 @@ static int tx_wheel_init(struct tmff2_device_entry *tmff2, int open_mode)
tx->report = list_entry(report_list->next, struct hid_report, list);
tx->ff_field = tx->report->field[0];
- tx->open = tx->input_dev->open;
- tx->close = tx->input_dev->close;
-
if ((ret = tx_interrupts(tx)))
goto interrupt_err;