serial: 8250_pci: Replace custom pci_match_id() implementation
PATCH v2 1/2 serial: 8250_pci: Replace custom pci_match_id() implementation
Replace pci_quatech_amcc() with generic pci_match_id().
---
v2: corrected set of patches, so this one is new
drivers/tty/serial/8250/8250_pci.c | 72 +++++++++++++----------------- 1 file changed, 31 insertions(+), 41 deletions(-)
drivers/tty/serial/8250/8250_pci.c +31 -41
@@ -1063,13 +1063,6 @@ static int pci_asix_setup(struct serial_private *priv,return pci_default_setup (priv, board, port, idx); } -/* Quatech devices have their own extra interface features */ - -struct quatech_feature { -u16 devid; -bool amcc; -}; -#define QPCR_TEST_FOR1 0x3F#define QPCR_TEST_GET1 0x00#define QPCR_TEST_FOR2 0x40
@@ -1085,42 +1078,30 @@ struct quatech_feature {#define QOPR_CLOCK_X8 0x0003#define QOPR_CLOCK_RATE_MASK 0x0003 - -static struct quatech_feature quatech_cards[] = { - {PCI_DEVICE_ID_QUATECH_QSC100 ,1 }, - {PCI_DEVICE_ID_QUATECH_DSC100 ,1 }, - {PCI_DEVICE_ID_QUATECH_DSC100E ,0 }, - {PCI_DEVICE_ID_QUATECH_DSC200 ,1 }, - {PCI_DEVICE_ID_QUATECH_DSC200E ,0 }, - {PCI_DEVICE_ID_QUATECH_ESC100D ,1 }, - {PCI_DEVICE_ID_QUATECH_ESC100M ,1 }, - {PCI_DEVICE_ID_QUATECH_QSCP100 ,1 }, - {PCI_DEVICE_ID_QUATECH_DSCP100 ,1 }, - {PCI_DEVICE_ID_QUATECH_QSCP200 ,1 }, - {PCI_DEVICE_ID_QUATECH_DSCP200 ,1 }, - {PCI_DEVICE_ID_QUATECH_ESCLP100 ,0 }, - {PCI_DEVICE_ID_QUATECH_QSCLP100 ,0 }, - {PCI_DEVICE_ID_QUATECH_DSCLP100 ,0 }, - {PCI_DEVICE_ID_QUATECH_SSCLP100 ,0 }, - {PCI_DEVICE_ID_QUATECH_QSCLP200 ,0 }, - {PCI_DEVICE_ID_QUATECH_DSCLP200 ,0 }, - {PCI_DEVICE_ID_QUATECH_SSCLP200 ,0 }, - {PCI_DEVICE_ID_QUATECH_SPPXP_100 ,0 }, +/* Quatech devices have their own extra interface features */ +static struct pci_device_id quatech_cards[] = { + {PCI_DEVICE_DATA (QUATECH ,QSC100 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSC100 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSC100E ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSC200 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSC200E ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,ESC100D ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,ESC100M ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,QSCP100 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSCP100 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,QSCP200 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSCP200 ,1 ) }, + {PCI_DEVICE_DATA (QUATECH ,ESCLP100 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,QSCLP100 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSCLP100 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,SSCLP100 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,QSCLP200 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,DSCLP200 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,SSCLP200 ,0 ) }, + {PCI_DEVICE_DATA (QUATECH ,SPPXP_100 ,0 ) }, {0 , } }; -static int pci_quatech_amcc (struct pci_dev *dev) -{ -struct quatech_feature *qf = &quatech_cards[0 ]; -while (qf->devid) { -if (qf->devid == dev->device) -return qf->amcc; - qf++; - } -pci_err (dev,"unknown port type '0x%04X'.\n" , dev->device); -return 0 ; -}; -static int pci_quatech_rqopr (struct uart_8250_port *port) {unsigned long base = port->port.iobase;
@@ -1280,7 +1261,16 @@ static int pci_quatech_rs422(struct uart_8250_port *port)static int pci_quatech_init (struct pci_dev *dev) { -if (pci_quatech_amcc (dev)) { +const struct pci_device_id *match; +bool amcc; + + match =pci_match_id (quatech_cards, dev); +if (match) + amcc = match->driver_data; +else +pci_err (dev,"unknown port type '0x%04X'.\n" , dev->device); + +if (amcc) {unsigned long base =pci_resource_start (dev,0 );if (base) {u32 tmp;
Signature · 1 line
2.33.0
PATCH v2 2/2 serial: 8250_pci: Remove empty stub pci_quatech_exit()
The ->exit() callback is checked for presence anyway, no need to have an empty stub.
---
v2: corrected set of the patches, so this become patch 2 in the series
drivers/tty/serial/8250/8250_pci.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/tty/serial/8250/8250_pci.c +0 -5
@@ -1298,10 +1298,6 @@ static int pci_quatech_setup(struct serial_private *priv,return pci_default_setup (priv, board, port, idx); } -static void pci_quatech_exit (struct pci_dev *dev) -{ -} -static int pci_default_setup (struct serial_private *priv,const struct pciserial_board *board,struct uart_8250_port *port,int idx)
@@ -2176,7 +2172,6 @@ static struct pci_serial_quirk pci_serial_quirks[] = { .subdevice = PCI_ANY_ID, .init = pci_quatech_init, .setup = pci_quatech_setup, - .exit = pci_quatech_exit, },/* * Panacom
Signature · 1 line
2.33.0
kernel test robot
build botI love your patch! Perhaps something to improve:
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on tty/tty-testing]
[cannot apply to v5.15-rc7 next-20211026]
[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/Andy-Shevchenko/serial-8250_pci-Replace-custom-pci_match_id-implementation/20211025-204752 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing config: i386-randconfig-a003-20211025 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a461fa64bb37cffd73f683c74f6b0780379fc2ca)
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/24a32531ba63f472ec6f40c4d431cb5369b29818
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/serial-8250_pci-Replace-custom-pci_match_id-implementation/20211025-204752 git checkout 24a32531ba63f472ec6f40c4d431cb5369b29818
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/tty/serial/8250/8250_pci.c:1268:6: warning: variable 'amcc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (match)
^~~~~
drivers/tty/serial/8250/8250_pci.c:1273:6: note: uninitialized use occurs here
if (amcc) {
^~~~
drivers/tty/serial/8250/8250_pci.c:1268:2: note: remove the 'if' if its condition is always true
if (match)
^~~~~~~~~~
drivers/tty/serial/8250/8250_pci.c:1265:11: note: initialize the variable 'amcc' to silence this warning
bool amcc;
^
= 01 warning generated.
vim +1268 drivers/tty/serial/8250/8250_pci.c
1261
1262 static int pci_quatech_init(struct pci_dev *dev)
1263 {
1264 const struct pci_device_id *match;
1265 bool amcc;
1266
1267 match = pci_match_id(quatech_cards, dev);
> 1268 if (match)
1269 amcc = match->driver_data;
1270 else
1271 pci_err(dev, "unknown port type '0x%04X'.\n", dev->device);
1272
1273 if (amcc) {
1274 unsigned long base = pci_resource_start(dev, 0);
1275 if (base) {
1276 u32 tmp;
1277
1278 outl(inl(base + 0x38) | 0x00002000, base + 0x38);
1279 tmp = inl(base + 0x3c);
1280 outl(tmp | 0x01000000, base + 0x3c);
1281 outl(tmp &= ~0x01000000, base + 0x3c);
1282 }
1283 }
1284 return 0;
1285 }
1286
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 30 lines · kernel test robot
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on tty/tty-testing]
[cannot apply to v5.15-rc7 next-20211026]
[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/Andy-Shevchenko/serial-8250_pci-Replace-custom-pci_match_id-implementation/20211025-204752 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing config: i386-randconfig-a003-20211025 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a461fa64bb37cffd73f683c74f6b0780379fc2ca)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/24a32531ba63f472ec6f40c4d431cb5369b29818
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andy-Shevchenko/serial-8250_pci-Replace-custom-pci_match_id-implementation/20211025-204752 git checkout24a32531ba63f472ec6f40c4d431cb5369b29818
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/tty/serial/8250/8250_pci.c:1268:6: warning: variable 'amcc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
Quoted 12 lines
if (match)
^~~~~
drivers/tty/serial/8250/8250_pci.c:1273:6: note: uninitialized use occurs here
if (amcc) {
^~~~
drivers/tty/serial/8250/8250_pci.c:1268:2: note: remove the 'if' if its condition is always true
if (match)
^~~~~~~~~~
drivers/tty/serial/8250/8250_pci.c:1265:11: note: initialize the variable 'amcc' to silence this warning
bool amcc;
^
= 0Clang gives a right and wrong advice at the same time.
Thank you for the uninitialized case, but variable is boolean, what's 0 here?
I'll send a fix ASAP.
Quoted 1 line
1 warning generated.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 18 lines · Andy Shevchenko
Quoted 15 lines · kernel test robot
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386
Quoted 1 line
Quoted 1 line
drivers/tty/serial/8250/8250_pci.c:1268:6: warning: variable 'amcc' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]if (match) ^~~~~ drivers/tty/serial/8250/8250_pci.c:1273:6: note: uninitialized use occurs here if (amcc) { ^~~~ drivers/tty/serial/8250/8250_pci.c:1268:2: note: remove the 'if' if its condition is always true if (match) ^~~~~~~~~~ drivers/tty/serial/8250/8250_pci.c:1265:11: note: initialize the variable 'amcc' to silence this warning bool amcc; ^ = 0
Quoted 4 lines
Clang gives a right and wrong advice at the same time.
Thank you for the uninitialized case, but variable is boolean, what's 0 here?I'll send a fix ASAP.
Hmm... GCC haven't showed anything here.
In any case, v3 has just been sent out.
Signature · 2 lines
With Best Regards, Andy Shevchenko