diff --git a/10_lightning_node_pro_led/lightning_node_pro_led.c b/10_lightning_node_pro_led/lightning_node_pro_led.c index 1c74265..5b42122 100644 --- a/10_lightning_node_pro_led/lightning_node_pro_led.c +++ b/10_lightning_node_pro_led/lightning_node_pro_led.c @@ -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), 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; + } mc_leds_info[0].color_index = LED_COLOR_ID_RED; 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", lnp_dev->dev_name, fan_data->fan_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; + } led_cdev->brightness = 0; 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, &rgb_led_data->cdev); 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; } @@ -100,7 +111,11 @@ static inline int lnp_register_fan(struct lnp_device *lnp_dev, fan_data->rgb_leds_data = devm_kmalloc_array( &lnp_dev->hdev->dev, lnp_dev->rgb_leds_per_fan_count, sizeof(struct lnp_rgb_led), GFP_KERNEL | __GFP_ZERO); + 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; } @@ -141,8 +156,10 @@ static inline int lnp_init(struct hid_device *hdev) struct lnp_device *lnp_dev; 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; + } lnp_dev->hdev = hdev; 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) { lnp_dev->rgb_leds_per_fan_count = NUMBER_OF_LEDS_PER_LL120_FAN; } 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; } @@ -163,8 +180,10 @@ static inline int lnp_init(struct hid_device *hdev) sizeof(struct lnp_fan), 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; + } ret = lnp_register_fans(lnp_dev); 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) { - pr_info("Détection USB pour Lightning Node Pro\n"); - int ret; ret = hid_parse(hdev); @@ -216,7 +233,6 @@ err_stop: static void lnp_remove(struct hid_device *hdev) { - pr_info("Retrait USB pour Lightning Node Pro\n"); hid_hw_close(hdev); hid_hw_stop(hdev); }