Add more hid_err

This commit is contained in:
Florian RICHER 2025-03-09 20:51:43 +01:00
parent a124cb33a8
commit 5095cabcad
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77

View file

@ -61,8 +61,12 @@ static inline int lnp_register_rgb_led(struct lnp_device *lnp_dev,
mc_leds_info = devm_kmalloc_array(&hdev->dev, 3, sizeof(*mc_leds_info), mc_leds_info = devm_kmalloc_array(&hdev->dev, 3, sizeof(*mc_leds_info),
GFP_KERNEL); GFP_KERNEL);
if (!mc_leds_info) if (!mc_leds_info) {
hid_err(lnp_dev->hdev,
"Failed to allocate multicolor leds info for LED %d on FAN %d\n",
rgb_led_data->led_index, fan_data->fan_index);
return -ENOMEM; return -ENOMEM;
}
mc_leds_info[0].color_index = LED_COLOR_ID_RED; mc_leds_info[0].color_index = LED_COLOR_ID_RED;
mc_leds_info[1].color_index = LED_COLOR_ID_GREEN; mc_leds_info[1].color_index = LED_COLOR_ID_GREEN;
@ -76,8 +80,13 @@ static inline int lnp_register_rgb_led(struct lnp_device *lnp_dev,
"%s:rgb:fan-%d-led-%d", "%s:rgb:fan-%d-led-%d",
lnp_dev->dev_name, fan_data->fan_index, lnp_dev->dev_name, fan_data->fan_index,
rgb_led_data->led_index); rgb_led_data->led_index);
if (!led_cdev->name)
if (!led_cdev->name) {
hid_err(lnp_dev->hdev,
"Failed to allocate name for LED %d on FAN %d\n",
rgb_led_data->led_index, fan_data->fan_index);
return -ENOMEM; return -ENOMEM;
}
led_cdev->brightness = 0; led_cdev->brightness = 0;
led_cdev->max_brightness = 255; led_cdev->max_brightness = 255;
@ -85,7 +94,9 @@ static inline int lnp_register_rgb_led(struct lnp_device *lnp_dev,
ret = devm_led_classdev_multicolor_register(&hdev->dev, ret = devm_led_classdev_multicolor_register(&hdev->dev,
&rgb_led_data->cdev); &rgb_led_data->cdev);
if (ret < 0) { if (ret < 0) {
hid_err(hdev, "Cannot register multicolor LED device\n"); hid_err(hdev,
"Cannot register multicolor LED device for LED %d on FAN %d\n",
rgb_led_data->led_index, fan_data->fan_index);
return ret; return ret;
} }
@ -100,7 +111,11 @@ static inline int lnp_register_fan(struct lnp_device *lnp_dev,
fan_data->rgb_leds_data = devm_kmalloc_array( fan_data->rgb_leds_data = devm_kmalloc_array(
&lnp_dev->hdev->dev, lnp_dev->rgb_leds_per_fan_count, &lnp_dev->hdev->dev, lnp_dev->rgb_leds_per_fan_count,
sizeof(struct lnp_rgb_led), GFP_KERNEL | __GFP_ZERO); sizeof(struct lnp_rgb_led), GFP_KERNEL | __GFP_ZERO);
if (!fan_data->rgb_leds_data) { if (!fan_data->rgb_leds_data) {
hid_err(lnp_dev->hdev,
"Failed to allocate rgb leds data for FAN %d\n",
fan_data->fan_index);
return -ENOMEM; return -ENOMEM;
} }
@ -141,8 +156,10 @@ static inline int lnp_init(struct hid_device *hdev)
struct lnp_device *lnp_dev; struct lnp_device *lnp_dev;
lnp_dev = devm_kzalloc(&hdev->dev, sizeof(*lnp_dev), GFP_KERNEL); lnp_dev = devm_kzalloc(&hdev->dev, sizeof(*lnp_dev), GFP_KERNEL);
if (!lnp_dev) if (!lnp_dev) {
hid_err(hdev, "Failed to allocate lnp device data\n");
return -ENOMEM; return -ENOMEM;
}
lnp_dev->hdev = hdev; lnp_dev->hdev = hdev;
lnp_dev->dev_name = dev_name(&hdev->dev); lnp_dev->dev_name = dev_name(&hdev->dev);
@ -154,7 +171,7 @@ static inline int lnp_init(struct hid_device *hdev)
if (lnp_dev->type == LNP_LED_LL120) { if (lnp_dev->type == LNP_LED_LL120) {
lnp_dev->rgb_leds_per_fan_count = NUMBER_OF_LEDS_PER_LL120_FAN; lnp_dev->rgb_leds_per_fan_count = NUMBER_OF_LEDS_PER_LL120_FAN;
} else { } else {
hid_err(lnp_dev->hdev, "Invalid fan type\n"); hid_err(lnp_dev->hdev, "Invalid fan type %d\n", lnp_dev->type);
return -ENOSYS; return -ENOSYS;
} }
@ -163,8 +180,10 @@ static inline int lnp_init(struct hid_device *hdev)
sizeof(struct lnp_fan), sizeof(struct lnp_fan),
GFP_KERNEL | __GFP_ZERO); GFP_KERNEL | __GFP_ZERO);
if (!lnp_dev->fans_data) if (!lnp_dev->fans_data) {
hid_err(hdev, "Failed to allocate fans data\n");
return -ENOMEM; return -ENOMEM;
}
ret = lnp_register_fans(lnp_dev); ret = lnp_register_fans(lnp_dev);
if (ret) { if (ret) {
@ -179,8 +198,6 @@ static inline int lnp_init(struct hid_device *hdev)
static int lnp_probe(struct hid_device *hdev, const struct hid_device_id *id) static int lnp_probe(struct hid_device *hdev, const struct hid_device_id *id)
{ {
pr_info("Détection USB pour Lightning Node Pro\n");
int ret; int ret;
ret = hid_parse(hdev); ret = hid_parse(hdev);
@ -216,7 +233,6 @@ err_stop:
static void lnp_remove(struct hid_device *hdev) static void lnp_remove(struct hid_device *hdev)
{ {
pr_info("Retrait USB pour Lightning Node Pro\n");
hid_hw_close(hdev); hid_hw_close(hdev);
hid_hw_stop(hdev); hid_hw_stop(hdev);
} }