--- v9
+++ v14
@@ -4,14 +4,14 @@
Signed-off-by: Daniel J. Ogorchock <djogorchock@gmail.com>
---
drivers/hid/Kconfig | 1 +
- drivers/hid/hid-nintendo.c | 133 +++++++++++++++++++++++++++++++++++++
- 2 files changed, 134 insertions(+)
+ drivers/hid/hid-nintendo.c | 134 +++++++++++++++++++++++++++++++++++++
+ 2 files changed, 135 insertions(+)
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
-index 41f7da50896f..a6e0f399bcab 100644
+index 142656b030b3e..f91e299e480b7 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
-@@ -697,6 +697,7 @@ config HID_NINTENDO
+@@ -735,6 +735,7 @@ config HID_NINTENDO
depends on HID
depends on NEW_LEDS
depends on LEDS_CLASS
@@ -20,7 +20,7 @@
Adds support for the Nintendo Switch Joy-Cons and Pro Controller.
All controllers support bluetooth, and the Pro Controller also supports
diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
-index 21d19bc96792..0caa9e1860ad 100644
+index e8f9fb8c3c11b..aea64ea8eb092 100644
--- a/drivers/hid/hid-nintendo.c
+++ b/drivers/hid/hid-nintendo.c
@@ -11,6 +11,7 @@
@@ -39,7 +39,7 @@
#include <linux/spinlock.h>
/*
-@@ -187,6 +189,7 @@ struct joycon_ctlr {
+@@ -199,6 +201,7 @@ struct joycon_ctlr {
struct input_dev *input;
struct led_classdev leds[JC_NUM_LEDS];
enum joycon_ctlr_state ctlr_state;
@@ -47,7 +47,7 @@
/* The following members are used for synchronous sends/receives */
enum joycon_msg_type msg_type;
-@@ -204,6 +207,12 @@ struct joycon_ctlr {
+@@ -216,6 +219,12 @@ struct joycon_ctlr {
struct joycon_stick_cal right_stick_cal_x;
struct joycon_stick_cal right_stick_cal_y;
@@ -60,7 +60,7 @@
};
static int __joycon_hid_send(struct hid_device *hdev, u8 *data, size_t len)
-@@ -434,9 +443,41 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr,
+@@ -446,9 +455,41 @@ static void joycon_parse_report(struct joycon_ctlr *ctlr,
struct joycon_input_report *rep)
{
struct input_dev *dev = ctlr->input;
@@ -102,7 +102,7 @@
btns = hid_field_extract(ctlr->hdev, rep->button_status, 0, 24);
if (id != USB_DEVICE_ID_NINTENDO_JOYCONR) {
-@@ -674,6 +715,90 @@ static int joycon_player_leds_create(struct joycon_ctlr *ctlr)
+@@ -743,6 +784,91 @@ static int joycon_player_leds_create(struct joycon_ctlr *ctlr)
return 0;
}
@@ -171,6 +171,7 @@
+ ctlr->battery_desc.num_properties =
+ ARRAY_SIZE(joycon_battery_props);
+ ctlr->battery_desc.get_property = joycon_battery_get_property;
++ ctlr->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY;
+ ctlr->battery_desc.use_for_apm = 0;
+ ctlr->battery_desc.name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
+ name_fmt,
@@ -186,14 +187,14 @@
+ hid_err(hdev, "Failed to register battery; ret=%d\n", ret);
+ return ret;
+ }
-+ power_supply_powers(ctlr->battery, &hdev->dev);
-+ return 0;
++
++ return power_supply_powers(ctlr->battery, &hdev->dev);
+}
+
/* Common handler for parsing inputs */
static int joycon_ctlr_read_handler(struct joycon_ctlr *ctlr, u8 *data,
int size)
-@@ -767,6 +892,7 @@ static int nintendo_hid_probe(struct hid_device *hdev,
+@@ -834,6 +960,7 @@ static int nintendo_hid_probe(struct hid_device *hdev,
hid_set_drvdata(hdev, ctlr);
mutex_init(&ctlr->output_mutex);
init_waitqueue_head(&ctlr->wait);
@@ -201,7 +202,7 @@
ret = hid_parse(hdev);
if (ret) {
-@@ -845,6 +971,13 @@ static int nintendo_hid_probe(struct hid_device *hdev,
+@@ -906,6 +1033,13 @@ static int nintendo_hid_probe(struct hid_device *hdev,
goto err_close;
}
@@ -212,9 +213,9 @@
+ goto err_close;
+ }
+
- ctlr->ctlr_state = JOYCON_CTLR_STATE_READ;
-
- hid_dbg(hdev, "probe - success\n");
+ ret = joycon_input_create(ctlr);
+ if (ret) {
+ hid_err(hdev, "Failed to create input device; ret=%d\n", ret);
--
-2.23.0
+2.32.0