Thread (43 messages) 43 messages, 6 authors, 2020-12-31

Re: [PATCH 09/13] HID: playstation: add DualSense lightbar support

From: Barnabás Pőcze <hidden>
Date: 2020-12-29 19:00:41

2020. december 28., hétfő 22:26 keltezéssel, Roderick Colenbrander írta:
[...]
quoted
quoted
+/* Create a DualSense/DualShock4 RGB lightbar represented by a multicolor LED. */
+static struct led_classdev_mc *ps_lightbar_create(struct ps_device *ps_dev,
+     int (*brightness_set)(struct led_classdev *, enum led_brightness))
+{
+     struct hid_device *hdev = ps_dev->hdev;
+     struct led_classdev_mc *lightbar_mc_dev;
+     struct mc_subled *mc_led_info;
+     struct led_classdev *led_cdev;
+     int ret;
+
+     lightbar_mc_dev = devm_kzalloc(&hdev->dev, sizeof(*lightbar_mc_dev), GFP_KERNEL);
+     if (!lightbar_mc_dev)
+             return ERR_PTR(-ENOMEM);
+
+     mc_led_info = devm_kzalloc(&hdev->dev, 3*sizeof(*mc_led_info), GFP_KERNEL);
+     if (!mc_led_info)
+             return ERR_PTR(-ENOMEM);
+
Is there any reason why these are dynamically allocated?
No particular reason. I should probably at least not dynamically
allocate 'mc_dev' and pass it in similar to regular LED registration
(previously I had my regular LEDs dynamically allocated). The
mc_led_info I will probably keep dynamic. It feels a bit nasty to have
the caller be aware of these internal details.
[...]
Could you please elaborate what you mean by "It feels a bit nasty to have
the caller be aware of these internal details."? I don't think I fully understand
what you're referring to.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help