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

misc: bcm-vk: only support ttyVK if CONFIG_TTY is set

Correct compile issue if CONFIG_TTY is not set by
only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Link: https://lore.kernel.org/r/20210203223826.21674-1-scott.branden@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Scott Branden and committed by
Greg Kroah-Hartman
3a11b0b5 8078efff

+61 -8
+12
drivers/misc/bcm-vk/Kconfig
··· 15 15 accelerators via /dev/bcm-vk.N devices. 16 16 17 17 If unsure, say N. 18 + 19 + config BCM_VK_TTY 20 + bool "Enable tty ports on a Broadcom VK Accelerator device" 21 + depends on TTY 22 + depends on BCM_VK 23 + help 24 + Select this option to enable tty support to allow console 25 + access to Broadcom VK Accelerator cards from host. 26 + 27 + Device node will in the form /dev/bcm-vk.x_ttyVKy where: 28 + x is the instance of the VK card 29 + y is the tty device number on the VK card.
+2 -2
drivers/misc/bcm-vk/Makefile
··· 7 7 bcm_vk-objs := \ 8 8 bcm_vk_dev.o \ 9 9 bcm_vk_msg.o \ 10 - bcm_vk_sg.o \ 11 - bcm_vk_tty.o 10 + bcm_vk_sg.o 12 11 12 + bcm_vk-$(CONFIG_BCM_VK_TTY) += bcm_vk_tty.o
+39 -3
drivers/misc/bcm-vk/bcm_vk.h
··· 258 258 BAR_2 259 259 }; 260 260 261 + #ifdef CONFIG_BCM_VK_TTY 261 262 #define BCM_VK_NUM_TTY 2 263 + #else 264 + #define BCM_VK_NUM_TTY 0 265 + #endif 262 266 263 267 struct bcm_vk_tty { 264 268 struct tty_port port; ··· 370 366 struct miscdevice miscdev; 371 367 int devid; /* dev id allocated */ 372 368 369 + #ifdef CONFIG_BCM_VK_TTY 373 370 struct tty_driver *tty_drv; 374 371 struct timer_list serial_timer; 375 372 struct bcm_vk_tty tty[BCM_VK_NUM_TTY]; 376 373 struct workqueue_struct *tty_wq_thread; 377 374 struct work_struct tty_wq_work; 375 + #endif 378 376 379 377 /* Reference-counting to handle file operations */ 380 378 struct kref kref; ··· 507 501 const pid_t pid, const u32 q_num); 508 502 void bcm_to_v_q_doorbell(struct bcm_vk *vk, u32 q_num, u32 db_val); 509 503 int bcm_vk_auto_load_all_images(struct bcm_vk *vk); 510 - int bcm_vk_tty_init(struct bcm_vk *vk, char *name); 511 - void bcm_vk_tty_exit(struct bcm_vk *vk); 512 - void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk); 513 504 void bcm_vk_hb_init(struct bcm_vk *vk); 514 505 void bcm_vk_hb_deinit(struct bcm_vk *vk); 515 506 void bcm_vk_handle_notf(struct bcm_vk *vk); 516 507 bool bcm_vk_drv_access_ok(struct bcm_vk *vk); 517 508 void bcm_vk_set_host_alert(struct bcm_vk *vk, u32 bit_mask); 509 + 510 + #ifdef CONFIG_BCM_VK_TTY 511 + int bcm_vk_tty_init(struct bcm_vk *vk, char *name); 512 + void bcm_vk_tty_exit(struct bcm_vk *vk); 513 + void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk); 514 + void bcm_vk_tty_wq_exit(struct bcm_vk *vk); 515 + 516 + static inline void bcm_vk_tty_set_irq_enabled(struct bcm_vk *vk, int index) 517 + { 518 + vk->tty[index].irq_enabled = true; 519 + } 520 + #else 521 + static inline int bcm_vk_tty_init(struct bcm_vk *vk, char *name) 522 + { 523 + return 0; 524 + } 525 + 526 + static inline void bcm_vk_tty_exit(struct bcm_vk *vk) 527 + { 528 + } 529 + 530 + static inline void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk) 531 + { 532 + } 533 + 534 + static inline void bcm_vk_tty_wq_exit(struct bcm_vk *vk) 535 + { 536 + } 537 + 538 + static inline void bcm_vk_tty_set_irq_enabled(struct bcm_vk *vk, int index) 539 + { 540 + } 541 + #endif /* CONFIG_BCM_VK_TTY */ 518 542 519 543 #endif
+2 -3
drivers/misc/bcm-vk/bcm_vk_dev.c
··· 1397 1397 pdev->irq + vk->num_irqs, vk->num_irqs + 1); 1398 1398 goto err_irq; 1399 1399 } 1400 - vk->tty[i].irq_enabled = true; 1400 + bcm_vk_tty_set_irq_enabled(vk, i); 1401 1401 } 1402 1402 1403 1403 id = ida_simple_get(&bcm_vk_ida, 0, 0, GFP_KERNEL); ··· 1582 1582 1583 1583 cancel_work_sync(&vk->wq_work); 1584 1584 destroy_workqueue(vk->wq_thread); 1585 - cancel_work_sync(&vk->tty_wq_work); 1586 - destroy_workqueue(vk->tty_wq_thread); 1585 + bcm_vk_tty_wq_exit(vk); 1587 1586 1588 1587 for (i = 0; i < MAX_BAR; i++) { 1589 1588 if (vk->bar[i])
+6
drivers/misc/bcm-vk/bcm_vk_tty.c
··· 331 331 kill_pid(find_vpid(vktty->pid), SIGKILL, 1); 332 332 } 333 333 } 334 + 335 + void bcm_vk_tty_wq_exit(struct bcm_vk *vk) 336 + { 337 + cancel_work_sync(&vk->tty_wq_work); 338 + destroy_workqueue(vk->tty_wq_thread); 339 + }