Inter-revision diff: patch 12

Comparing v2 (message) to v6 (message)

--- v2
+++ v6
@@ -6,11 +6,11 @@
 
 Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
 ---
- drivers/hid/hid-playstation.c | 69 ++++++++++++++++++++++++++++++++++-
- 1 file changed, 68 insertions(+), 1 deletion(-)
+ drivers/hid/hid-playstation.c | 70 ++++++++++++++++++++++++++++++++++-
+ 1 file changed, 69 insertions(+), 1 deletion(-)
 
 diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c
-index 183f011f081b..1a95c81da8a3 100644
+index 2d96785c397d..973c1fe61e8a 100644
 --- a/drivers/hid/hid-playstation.c
 +++ b/drivers/hid/hid-playstation.c
 @@ -9,6 +9,7 @@
@@ -39,7 +39,7 @@
  	struct power_supply_desc battery_desc;
  	struct power_supply *battery;
  	uint8_t battery_capacity;
-@@ -299,6 +304,24 @@ static int ps_devices_list_remove(struct ps_device *dev)
+@@ -321,6 +326,24 @@ static int ps_devices_list_remove(struct ps_device *dev)
  	return 0;
  }
  
@@ -58,24 +58,25 @@
 +{
 +	ida_free(&ps_player_id_allocator, dev->player_id);
 +
-+	dev->player_id = -1;
++	dev->player_id = U32_MAX;
 +}
 +
  static struct input_dev *ps_allocate_input_dev(struct hid_device *hdev, const char *name_suffix)
  {
  	struct input_dev *input_dev;
-@@ -1102,6 +1125,28 @@ static int dualsense_reset_leds(struct dualsense *ds)
+@@ -1156,6 +1179,29 @@ static int dualsense_reset_leds(struct dualsense *ds)
  	return 0;
  }
  
 +static void dualsense_set_player_leds(struct dualsense *ds)
 +{
-+	/* The DualSense controller has a row of 5 LEDs used for player ids.
++	/*
++	 * The DualSense controller has a row of 5 LEDs used for player ids.
 +	 * Behavior on the PlayStation 5 console is to center the player id
 +	 * across the LEDs, so e.g. player 1 would be "--x--" with x being 'on'.
 +	 * Follow a similar mapping here.
 +	 */
-+	int player_ids[5] = {
++	static const int player_ids[5] = {
 +		BIT(2),
 +		BIT(3) | BIT(1),
 +		BIT(4) | BIT(2) | BIT(0),
@@ -83,7 +84,7 @@
 +		BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0)
 +	};
 +
-+	uint8_t player_id = ds->base.player_id % 5;
++	uint8_t player_id = ds->base.player_id % ARRAY_SIZE(player_ids);
 +
 +	ds->update_player_leds = true;
 +	ds->player_leds_state = player_ids[player_id];
@@ -93,13 +94,13 @@
  static struct ps_device *dualsense_create(struct hid_device *hdev)
  {
  	struct dualsense *ds;
-@@ -1207,6 +1252,15 @@ static struct ps_device *dualsense_create(struct hid_device *hdev)
+@@ -1264,6 +1310,15 @@ static struct ps_device *dualsense_create(struct hid_device *hdev)
  			goto err;
  	}
  
 +	ret = ps_device_set_player_id(ps_dev);
-+	if (ret < 0) {
-+		hid_err(hdev, "Failed to assign player id for DualSense\n");
++	if (ret) {
++		hid_err(hdev, "Failed to assign player id for DualSense: %d\n", ret);
 +		goto err;
 +	}
 +
@@ -109,7 +110,7 @@
  	return &ds->base;
  
  err:
-@@ -1271,6 +1325,7 @@ static void ps_remove(struct hid_device *hdev)
+@@ -1328,6 +1383,7 @@ static void ps_remove(struct hid_device *hdev)
  	struct ps_device *dev = hid_get_drvdata(hdev);
  
  	ps_devices_list_remove(dev);
@@ -117,8 +118,8 @@
  
  	hid_hw_close(hdev);
  	hid_hw_stop(hdev);
-@@ -1291,7 +1346,19 @@ static struct hid_driver ps_driver = {
- 	.raw_event        = ps_raw_event,
+@@ -1348,7 +1404,19 @@ static struct hid_driver ps_driver = {
+ 	.raw_event	= ps_raw_event,
  };
  
 -module_hid_driver(ps_driver);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help