diff mbox series

[v8,3/6] leds: ledtrig-tty: change logging if get icount failed

Message ID 20231109085038.371977-4-fe@dev.tdt.de
State New
Headers show
Series ledtrig-tty: add additional tty state evaluation | expand

Commit Message

Florian Eckert Nov. 9, 2023, 8:50 a.m. UTC
Change the log level from info to warn, because there is something
wrong. That is more a warn message than an info message.

While we are at it, the device prefix is also changed, as this is the
led device and not the tty device that generates this message.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
 drivers/leds/trigger/ledtrig-tty.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Greg KH Nov. 23, 2023, 2:08 p.m. UTC | #1
On Thu, Nov 09, 2023 at 09:50:35AM +0100, Florian Eckert wrote:
> Change the log level from info to warn, because there is something
> wrong. That is more a warn message than an info message.
> 
> While we are at it, the device prefix is also changed, as this is the
> led device and not the tty device that generates this message.
> 
> Signed-off-by: Florian Eckert <fe@dev.tdt.de>
> ---
>  drivers/leds/trigger/ledtrig-tty.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
> index 3e69a7bde928..86595add72cd 100644
> --- a/drivers/leds/trigger/ledtrig-tty.c
> +++ b/drivers/leds/trigger/ledtrig-tty.c
> @@ -83,6 +83,7 @@ static void ledtrig_tty_work(struct work_struct *work)
>  	struct ledtrig_tty_data *trigger_data =
>  		container_of(work, struct ledtrig_tty_data, dwork.work);
>  	struct serial_icounter_struct icount;
> +	struct led_classdev *led_cdev = trigger_data->led_cdev;
>  	int ret;
>  
>  	mutex_lock(&trigger_data->mutex);
> @@ -117,7 +118,7 @@ static void ledtrig_tty_work(struct work_struct *work)
>  
>  	ret = tty_get_icount(trigger_data->tty, &icount);
>  	if (ret) {
> -		dev_info(trigger_data->tty->dev, "Failed to get icount, stopped polling\n");
> +		dev_warn(led_cdev->dev, "Failed to get icount, stop polling\n");

You changed the device that is reporting the error here.  It's the tty
device that you failed to get the icount for, not the LED device, so you
just confused the user by saying that a LED now can not get tty data :)

>  		mutex_unlock(&trigger_data->mutex);
>  		return;
>  	}
> @@ -126,8 +127,7 @@ static void ledtrig_tty_work(struct work_struct *work)
>  	    icount.tx != trigger_data->tx) {
>  		unsigned long interval = LEDTRIG_TTY_INTERVAL;
>  
> -		led_blink_set_oneshot(trigger_data->led_cdev, &interval,
> -				      &interval, 0);
> +		led_blink_set_oneshot(led_cdev, &interval, &interval, 0);

This is fine, but not needed if you fix up the above change.

thanks,

greg k-h
diff mbox series

Patch

diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
index 3e69a7bde928..86595add72cd 100644
--- a/drivers/leds/trigger/ledtrig-tty.c
+++ b/drivers/leds/trigger/ledtrig-tty.c
@@ -83,6 +83,7 @@  static void ledtrig_tty_work(struct work_struct *work)
 	struct ledtrig_tty_data *trigger_data =
 		container_of(work, struct ledtrig_tty_data, dwork.work);
 	struct serial_icounter_struct icount;
+	struct led_classdev *led_cdev = trigger_data->led_cdev;
 	int ret;
 
 	mutex_lock(&trigger_data->mutex);
@@ -117,7 +118,7 @@  static void ledtrig_tty_work(struct work_struct *work)
 
 	ret = tty_get_icount(trigger_data->tty, &icount);
 	if (ret) {
-		dev_info(trigger_data->tty->dev, "Failed to get icount, stopped polling\n");
+		dev_warn(led_cdev->dev, "Failed to get icount, stop polling\n");
 		mutex_unlock(&trigger_data->mutex);
 		return;
 	}
@@ -126,8 +127,7 @@  static void ledtrig_tty_work(struct work_struct *work)
 	    icount.tx != trigger_data->tx) {
 		unsigned long interval = LEDTRIG_TTY_INTERVAL;
 
-		led_blink_set_oneshot(trigger_data->led_cdev, &interval,
-				      &interval, 0);
+		led_blink_set_oneshot(led_cdev, &interval, &interval, 0);
 
 		trigger_data->rx = icount.rx;
 		trigger_data->tx = icount.tx;