Re: [PATCH v8 3/3] leds: trigger: implement a tty trigger

From: kernel test robot
Date: Mon Oct 12 2020 - 10:17:15 EST


Hi "Uwe,

I love your patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on pavel-linux-leds/for-next linus/master j.anaszewski-leds/for-next v5.9 next-20201012]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Uwe-Kleine-K-nig/leds-trigger-implement-a-tty-trigger/20201012-203510
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/4185c273a8de0340cee6655a363f98c3737665d0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Uwe-Kleine-K-nig/leds-trigger-implement-a-tty-trigger/20201012-203510
git checkout 4185c273a8de0340cee6655a363f98c3737665d0
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

drivers/leds/trigger/ledtrig-tty.c: In function 'ledtrig_tty_work':
>> drivers/leds/trigger/ledtrig-tty.c:92:7: warning: variable 'firstrun' set but not used [-Wunused-but-set-variable]
92 | bool firstrun = false;
| ^~~~~~~~

vim +/firstrun +92 drivers/leds/trigger/ledtrig-tty.c

85
86 static void ledtrig_tty_work(struct work_struct *work)
87 {
88 struct ledtrig_tty_data *trigger_data =
89 container_of(work, struct ledtrig_tty_data, dwork.work);
90 struct serial_icounter_struct icount;
91 int ret;
> 92 bool firstrun = false;
93
94 mutex_lock(&trigger_data->mutex);
95
96 BUG_ON(!trigger_data->ttyname);
97
98 /* try to get the tty corresponding to $ttyname */
99 if (!trigger_data->tty) {
100 dev_t devno;
101 struct tty_struct *tty;
102 int ret;
103
104 firstrun = true;
105
106 ret = tty_dev_name_to_number(trigger_data->ttyname, &devno);
107 if (ret < 0)
108 /*
109 * A device with this name might appear later, so keep
110 * retrying.
111 */
112 goto out;
113
114 tty = tty_kopen_shared(devno);
115 if (IS_ERR(tty) || !tty)
116 /* What to do? retry or abort */
117 goto out;
118
119 trigger_data->tty = tty;
120 }
121
122 ret = tty_get_icount(trigger_data->tty, &icount);
123 if (ret) {
124 mutex_unlock(&trigger_data->mutex);
125 dev_info(trigger_data->tty->dev, "Failed to get icount, stopped polling\n");
126 mutex_unlock(&trigger_data->mutex);
127 return;
128 }
129
130 if (icount.rx != trigger_data->rx ||
131 icount.tx != trigger_data->tx) {
132 led_set_brightness(trigger_data->led_cdev, LED_ON);
133
134 trigger_data->rx = icount.rx;
135 trigger_data->tx = icount.tx;
136 } else {
137 led_set_brightness(trigger_data->led_cdev, LED_OFF);
138 }
139
140 out:
141 mutex_unlock(&trigger_data->mutex);
142 schedule_delayed_work(&trigger_data->dwork, msecs_to_jiffies(100));
143 }
144

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip