Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

8250: of: remove remnants of generic of_serial driver

During build testing, I ran into a warning in a driver that I
had written myself at some point:

drivers/tty/serial/8250/8250_of.c: In function 'of_platform_serial_probe':
drivers/tty/serial/8250/8250_of.c:233:1: error: the frame size of 1200 bytes is larger than 1152 bytes [-Werror=frame-larger-than=]

This is harmless by itself, but it shows two other problems in
the driver:

- It still tries to be generic enough to handle all kinds of serial
ports, where in reality the driver has been 8250-only for a while,
and every other uart has its own DT support

- As a result of that generalization, we keep two copies of
'struct uart_port' on the stack during probe(). This is completely
unnessary.

Removing the last code dealing with unsupported port_type values
solves both problems nicely, and reduces the stack size.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Arnd Bergmann and committed by
Greg Kroah-Hartman
aa42db44 54b12c48

+26 -71
+26 -71
drivers/tty/serial/8250/8250_of.c
··· 172 172 { 173 173 const struct of_device_id *match; 174 174 struct of_serial_info *info; 175 - struct uart_port port; 175 + struct uart_8250_port port8250; 176 + u32 tx_threshold; 176 177 int port_type; 177 178 int ret; 178 179 ··· 189 188 return -ENOMEM; 190 189 191 190 port_type = (unsigned long)match->data; 192 - ret = of_platform_serial_setup(ofdev, port_type, &port, info); 191 + memset(&port8250, 0, sizeof(port8250)); 192 + ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info); 193 193 if (ret) 194 194 goto out; 195 195 196 - switch (port_type) { 197 - case PORT_8250 ... PORT_MAX_8250: 198 - { 199 - u32 tx_threshold; 200 - struct uart_8250_port port8250; 201 - memset(&port8250, 0, sizeof(port8250)); 202 - port8250.port = port; 196 + if (port8250.port.fifosize) 197 + port8250.capabilities = UART_CAP_FIFO; 203 198 204 - if (port.fifosize) 205 - port8250.capabilities = UART_CAP_FIFO; 199 + /* Check for TX FIFO threshold & set tx_loadsz */ 200 + if ((of_property_read_u32(ofdev->dev.of_node, "tx-threshold", 201 + &tx_threshold) == 0) && 202 + (tx_threshold < port8250.port.fifosize)) 203 + port8250.tx_loadsz = port8250.port.fifosize - tx_threshold; 206 204 207 - /* Check for TX FIFO threshold & set tx_loadsz */ 208 - if ((of_property_read_u32(ofdev->dev.of_node, "tx-threshold", 209 - &tx_threshold) == 0) && 210 - (tx_threshold < port.fifosize)) 211 - port8250.tx_loadsz = port.fifosize - tx_threshold; 205 + if (of_property_read_bool(ofdev->dev.of_node, "auto-flow-control")) 206 + port8250.capabilities |= UART_CAP_AFE; 212 207 213 - if (of_property_read_bool(ofdev->dev.of_node, 214 - "auto-flow-control")) 215 - port8250.capabilities |= UART_CAP_AFE; 216 - 217 - ret = serial8250_register_8250_port(&port8250); 218 - break; 219 - } 220 - default: 221 - /* need to add code for these */ 222 - case PORT_UNKNOWN: 223 - dev_info(&ofdev->dev, "Unknown serial port found, ignored\n"); 224 - ret = -ENODEV; 225 - break; 226 - } 208 + ret = serial8250_register_8250_port(&port8250); 227 209 if (ret < 0) 228 210 goto out; 229 211 ··· 216 232 return 0; 217 233 out: 218 234 kfree(info); 219 - irq_dispose_mapping(port.irq); 235 + irq_dispose_mapping(port8250.port.irq); 220 236 return ret; 221 237 } 222 238 ··· 226 242 static int of_platform_serial_remove(struct platform_device *ofdev) 227 243 { 228 244 struct of_serial_info *info = platform_get_drvdata(ofdev); 229 - switch (info->type) { 230 - case PORT_8250 ... PORT_MAX_8250: 231 - serial8250_unregister_port(info->line); 232 - break; 233 - default: 234 - /* need to add code for these */ 235 - break; 236 - } 245 + 246 + serial8250_unregister_port(info->line); 237 247 238 248 if (info->clk) 239 249 clk_disable_unprepare(info->clk); ··· 236 258 } 237 259 238 260 #ifdef CONFIG_PM_SLEEP 239 - static void of_serial_suspend_8250(struct of_serial_info *info) 261 + static int of_serial_suspend(struct device *dev) 240 262 { 263 + struct of_serial_info *info = dev_get_drvdata(dev); 241 264 struct uart_8250_port *port8250 = serial8250_get_port(info->line); 242 265 struct uart_port *port = &port8250->port; 243 266 244 267 serial8250_suspend_port(info->line); 268 + 245 269 if (info->clk && (!uart_console(port) || console_suspend_enabled)) 246 270 clk_disable_unprepare(info->clk); 247 - } 248 - 249 - static void of_serial_resume_8250(struct of_serial_info *info) 250 - { 251 - struct uart_8250_port *port8250 = serial8250_get_port(info->line); 252 - struct uart_port *port = &port8250->port; 253 - 254 - if (info->clk && (!uart_console(port) || console_suspend_enabled)) 255 - clk_prepare_enable(info->clk); 256 - 257 - serial8250_resume_port(info->line); 258 - } 259 - 260 - static int of_serial_suspend(struct device *dev) 261 - { 262 - struct of_serial_info *info = dev_get_drvdata(dev); 263 - 264 - switch (info->type) { 265 - case PORT_8250 ... PORT_MAX_8250: 266 - of_serial_suspend_8250(info); 267 - break; 268 - default: 269 - break; 270 - } 271 271 272 272 return 0; 273 273 } ··· 253 297 static int of_serial_resume(struct device *dev) 254 298 { 255 299 struct of_serial_info *info = dev_get_drvdata(dev); 300 + struct uart_8250_port *port8250 = serial8250_get_port(info->line); 301 + struct uart_port *port = &port8250->port; 256 302 257 - switch (info->type) { 258 - case PORT_8250 ... PORT_MAX_8250: 259 - of_serial_resume_8250(info); 260 - break; 261 - default: 262 - break; 263 - } 303 + if (info->clk && (!uart_console(port) || console_suspend_enabled)) 304 + clk_prepare_enable(info->clk); 305 + 306 + serial8250_resume_port(info->line); 264 307 265 308 return 0; 266 309 }