From b630e6a153323697dc66686a44804c6b43aaaec2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 25 Apr 2013 15:52:48 -0600 Subject: [PATCH] Useless TIOCSERGSTRUCT logic in most serial drivers is not compiled unless CONFIG_DEBUG and CONFIG_SERIAL_TIOCSERGSTRUCT are defined --- ChangeLog | 4 ++++ arch/arm/src/c5471/c5471_serial.c | 4 +++- arch/arm/src/calypso/calypso_serial.c | 4 +++- arch/arm/src/dm320/dm320_serial.c | 4 +++- arch/arm/src/imx/imx_serial.c | 4 +++- arch/arm/src/kinetis/Kconfig | 8 ++++---- arch/arm/src/lm/lm_serial.c | 4 +++- arch/arm/src/lpc17xx/lpc17_serial.c | 2 ++ arch/arm/src/lpc214x/Kconfig | 2 +- arch/arm/src/lpc214x/lpc214x_serial.c | 4 +++- arch/arm/src/lpc2378/lpc23xx_serial.c | 4 +++- arch/arm/src/lpc31xx/lpc31_serial.c | 4 +++- arch/arm/src/lpc43xx/lpc43_serial.c | 4 +++- arch/arm/src/nuc1xx/nuc_serial.c | 2 ++ arch/arm/src/sam3u/sam3u_serial.c | 4 +++- arch/arm/src/stm32/stm32_serial.c | 2 ++ arch/arm/src/str71x/str71x_serial.c | 4 +++- drivers/serial/Kconfig | 14 +++++++++++++- drivers/serial/uart_16550.c | 4 +++- 19 files changed, 64 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index dcaf044101..e6cbea97d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4628,3 +4628,7 @@ could be a good feature, the codes have not be well utilized nor documented. Give that situation it is better to remove the API and reduce the footprint a little (2014-4-25). + * drivers/serial/Kconfig and arch/*/src/*/*_serial.c: Add + compilation so that the useless TIOCSERGSTRUCT ioctl logic + is not build unless CONFIG_DEBUG and CONFIG_SERIAL_TIOCSERGSTRUCT + are defined. diff --git a/arch/arm/src/c5471/c5471_serial.c b/arch/arm/src/c5471/c5471_serial.c index cdc5b6f24c..09018cb282 100644 --- a/arch/arm/src/c5471/c5471_serial.c +++ b/arch/arm/src/c5471/c5471_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * c5471/c5471_serial.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -620,6 +620,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -633,6 +634,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { diff --git a/arch/arm/src/calypso/calypso_serial.c b/arch/arm/src/calypso/calypso_serial.c index 5817b338b7..ddb37201dc 100644 --- a/arch/arm/src/calypso/calypso_serial.c +++ b/arch/arm/src/calypso/calypso_serial.c @@ -5,7 +5,7 @@ * Author: Stefan Richter * * based on c5471/c5471_serial.c - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -707,6 +707,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -720,6 +721,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { diff --git a/arch/arm/src/dm320/dm320_serial.c b/arch/arm/src/dm320/dm320_serial.c index fbeefd8e90..5b944b9b7f 100644 --- a/arch/arm/src/dm320/dm320_serial.c +++ b/arch/arm/src/dm320/dm320_serial.c @@ -2,7 +2,7 @@ * arch/arm/src/dm320/dm320_serial.c * arch/arm/src/chip/dm320_serial.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -546,6 +546,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -559,6 +560,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { diff --git a/arch/arm/src/imx/imx_serial.c b/arch/arm/src/imx/imx_serial.c index d7a4c3296c..d7ac1a7325 100644 --- a/arch/arm/src/imx/imx_serial.c +++ b/arch/arm/src/imx/imx_serial.c @@ -2,7 +2,7 @@ * arch/arm/src/imx/imx_serial.c * arch/arm/src/chip/imx_serial.c * - * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -885,6 +885,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -898,6 +899,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */ diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig index c444c065fb..bdca8c68b2 100644 --- a/arch/arm/src/kinetis/Kconfig +++ b/arch/arm/src/kinetis/Kconfig @@ -395,14 +395,14 @@ config ENET_NRXBUFFERS default 6 ---help--- Number of Ethernet Rx buffers to use. The size of one buffer is - determined by CONFIG_NET_BUFSIZE + determined by NET_BUFSIZE config ENET_NTXBUFFERS int "Number of Ethernet Tx buffers" default 2 ---help--- Number of Ethernet Tx buffers to use. The size of one buffer is - determined by CONFIG_NET_BUFSIZE + determined by NET_BUFSIZE config ENET_PHYADDR int "PHY address" @@ -451,14 +451,14 @@ config KINETIS_MMCXFR_FREQ config KINETIS_SD1BIT_FREQ int "SD 1-bit transfer frequency" default 20000000 - depends on CONFIG_SDIO_WIDTH_D1_ONLY + depends on SDIO_WIDTH_D1_ONLY ---help--- Frequency to use for transferring data to/from an SD card using on a single data liune. config KINETIS_SD4BIT_FREQ int "SD 4-bit transfer frequency" default 20000000 - depends on !CONFIG_SDIO_WIDTH_D1_ONLY + depends on !SDIO_WIDTH_D1_ONLY ---help--- Frequency to use for transferring data to/from an SD card using all four data lines. diff --git a/arch/arm/src/lm/lm_serial.c b/arch/arm/src/lm/lm_serial.c index 6e772ecd50..f2e9796cfe 100644 --- a/arch/arm/src/lm/lm_serial.c +++ b/arch/arm/src/lm/lm_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lm/lm_serial.c * - * Copyright (C) 2009-2010, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1019,6 +1019,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -1032,6 +1033,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif default: ret = -ENOTTY; diff --git a/arch/arm/src/lpc17xx/lpc17_serial.c b/arch/arm/src/lpc17xx/lpc17_serial.c index b2da4839f2..6bf519ac30 100644 --- a/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/arch/arm/src/lpc17xx/lpc17_serial.c @@ -1169,6 +1169,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -1182,6 +1183,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { diff --git a/arch/arm/src/lpc214x/Kconfig b/arch/arm/src/lpc214x/Kconfig index 5d52eb0001..25b82bd6b1 100644 --- a/arch/arm/src/lpc214x/Kconfig +++ b/arch/arm/src/lpc214x/Kconfig @@ -117,7 +117,7 @@ config LPC214X_USBDEV_DMA bool "USB Device DMA Support" default n -config CONFIG_LPC214X_USBDEV_NDMADESCRIPTORS +config LPC214X_USBDEV_NDMADESCRIPTORS int "Number of USB DMA Descriptors" default 8 depends on LPC214X_USBDEV_DMA diff --git a/arch/arm/src/lpc214x/lpc214x_serial.c b/arch/arm/src/lpc214x/lpc214x_serial.c index c647e458a8..f27eea9772 100644 --- a/arch/arm/src/lpc214x/lpc214x_serial.c +++ b/arch/arm/src/lpc214x/lpc214x_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc214x/lpc214x_serial.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -569,6 +569,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -582,6 +583,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { diff --git a/arch/arm/src/lpc2378/lpc23xx_serial.c b/arch/arm/src/lpc2378/lpc23xx_serial.c index 08fe4ec73e..6fcb503f3b 100644 --- a/arch/arm/src/lpc2378/lpc23xx_serial.c +++ b/arch/arm/src/lpc2378/lpc23xx_serial.c @@ -7,7 +7,7 @@ * * This file is part of the NuttX RTOS and based on the lpc2148 port: * - * Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -692,6 +692,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s *)arg; @@ -705,6 +706,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, * unconditionally */ diff --git a/arch/arm/src/lpc31xx/lpc31_serial.c b/arch/arm/src/lpc31xx/lpc31_serial.c index c383253138..f5f2c57832 100644 --- a/arch/arm/src/lpc31xx/lpc31_serial.c +++ b/arch/arm/src/lpc31xx/lpc31_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc31xx/lpc31_serial.c * - * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -582,6 +582,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -595,6 +596,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ { diff --git a/arch/arm/src/lpc43xx/lpc43_serial.c b/arch/arm/src/lpc43xx/lpc43_serial.c index adbfb282a7..8736d5db21 100644 --- a/arch/arm/src/lpc43xx/lpc43_serial.c +++ b/arch/arm/src/lpc43xx/lpc43_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/lpc43xx/lpc43_serial.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1080,6 +1080,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -1093,6 +1094,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif #ifdef CONFIG_SERIAL_TERMIOS case TCGETS: diff --git a/arch/arm/src/nuc1xx/nuc_serial.c b/arch/arm/src/nuc1xx/nuc_serial.c index c07ef1109c..6ecfb11598 100644 --- a/arch/arm/src/nuc1xx/nuc_serial.c +++ b/arch/arm/src/nuc1xx/nuc_serial.c @@ -760,6 +760,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct nuc_dev_s *user = (struct nuc_dev_s*)arg; @@ -773,6 +774,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */ diff --git a/arch/arm/src/sam3u/sam3u_serial.c b/arch/arm/src/sam3u/sam3u_serial.c index a4d79a11b6..ef1345f8e2 100644 --- a/arch/arm/src/sam3u/sam3u_serial.c +++ b/arch/arm/src/sam3u/sam3u_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/sam3u/sam3u_serial.c * - * Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1138,6 +1138,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -1151,6 +1152,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif default: ret = -ENOTTY; diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index c04bcc9ee9..4594c187e8 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -1621,6 +1621,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -1634,6 +1635,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif #ifdef CONFIG_STM32_USART_SINGLEWIRE case TIOCSSINGLEWIRE: diff --git a/arch/arm/src/str71x/str71x_serial.c b/arch/arm/src/str71x/str71x_serial.c index 2098758b1c..2356898bb5 100644 --- a/arch/arm/src/str71x/str71x_serial.c +++ b/arch/arm/src/str71x/str71x_serial.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/str71x/str71x_serial.c * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -759,6 +759,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct up_dev_s *user = (struct up_dev_s*)arg; @@ -772,6 +773,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif default: ret = -ENOTTY; diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index ff81ae5599..d512784a4d 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -336,7 +336,7 @@ config STANDARD_SERIAL ---help--- Enable the standard, upper-half serial driver used by most MCU serial peripherals. -config CONFIG_SERIAL_NPOLLWAITERS +config SERIAL_NPOLLWAITERS int "Number of poll threads" default 2 depends on !DISABLE_POLL && STANDARD_SERIAL @@ -344,6 +344,18 @@ config CONFIG_SERIAL_NPOLLWAITERS Maximum number of threads than can be waiting for POLL events. Default: 2 +config SERIAL_TIOCSERGSTRUCT + bool "Support TIOCSERGSTRUCT" + default n + depends on DEBUG && (MCU_SERIAL || 16550_UART) + ---help--- + As a debug option, many serial bottom half drivers support the TIOCSERGSTRUCT + that allows you to get the internal drvier data structure. By default, this + IOCTL is not supported in order to reduce footprint. But if (1) the driver + supports the TIOCSERGSTRUCT ioctl, and (2) this option is selected, then + support for the TIOCSERGSTRUCT will be enabled. + + # # U[S]ARTn_XYZ settings for MCU serial drivers # diff --git a/drivers/serial/uart_16550.c b/drivers/serial/uart_16550.c index fbd8104263..ac025bcfa3 100644 --- a/drivers/serial/uart_16550.c +++ b/drivers/serial/uart_16550.c @@ -2,7 +2,7 @@ * drivers/serial/uart_16550.c * Serial driver for 16550 UART * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -865,6 +865,7 @@ static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg) switch (cmd) { +#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT case TIOCSERGSTRUCT: { struct u16550_s *user = (struct u16550_s*)arg; @@ -879,6 +880,7 @@ static int u16550_ioctl(struct file *filep, int cmd, unsigned long arg) } } break; +#endif case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */ {