diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2023-09-01 19:38:00 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2023-09-01 19:38:00 +0300 |
commit | 8e1e49550dc85694abd04d86a8ee36bc98bd8b9e (patch) | |
tree | 03133476605e455accd14770365ea05a3bce7007 /drivers/tty/synclink_gt.c | |
parent | e925992671907314b7db6793a28eb39b36bc21a4 (diff) | |
parent | ebf05c7dc92c11b0355aaa0e94064beadaa4b05c (diff) | |
download | linux-8e1e49550dc85694abd04d86a8ee36bc98bd8b9e.tar.xz |
Merge tag 'tty-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial driver updates from Greg KH:
"Here is the big set of tty and serial driver changes for 6.6-rc1.
Lots of cleanups in here this cycle, and some driver updates. Short
summary is:
- Jiri's continued work to make the tty code and apis be a bit more
sane with regards to modern kernel coding style and types
- cpm_uart driver updates
- n_gsm updates and fixes
- meson driver updates
- sc16is7xx driver updates
- 8250 driver updates for different hardware types
- qcom-geni driver fixes
- tegra serial driver change
- stm32 driver updates
- synclink_gt driver cleanups
- tty structure size reduction
All of these have been in linux-next this week with no reported
issues. The last bit of cleanups from Jiri and the tty structure size
reduction came in last week, a bit late but as they were just style
changes and size reductions, I figured they should get into this merge
cycle so that others can work on top of them with no merge conflicts"
* tag 'tty-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (199 commits)
tty: shrink the size of struct tty_struct by 40 bytes
tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw()
tty: n_tty: extract ECHO_OP processing to a separate function
tty: n_tty: unify counts to size_t
tty: n_tty: use u8 for chars and flags
tty: n_tty: simplify chars_in_buffer()
tty: n_tty: remove unsigned char casts from character constants
tty: n_tty: move newline handling to a separate function
tty: n_tty: move canon handling to a separate function
tty: n_tty: use MASK() for masking out size bits
tty: n_tty: make n_tty_data::num_overrun unsigned
tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun()
tty: n_tty: use 'num' for writes' counts
tty: n_tty: use output character directly
tty: n_tty: make flow of n_tty_receive_buf_common() a bool
Revert "tty: serial: meson: Add a earlycon for the T7 SoC"
Documentation: devices.txt: Fix minors for ttyCPM*
Documentation: devices.txt: Remove ttySIOC*
Documentation: devices.txt: Remove ttyIOC*
serial: 8250_bcm7271: improve bcm7271 8250 port
...
Diffstat (limited to 'drivers/tty/synclink_gt.c')
-rw-r--r-- | drivers/tty/synclink_gt.c | 83 |
1 files changed, 36 insertions, 47 deletions
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 16e469e581ec..8112d9d5a0d8 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c @@ -87,18 +87,17 @@ /* * module identification */ -static char *driver_name = "SyncLink GT"; -static char *slgt_driver_name = "synclink_gt"; -static char *tty_dev_prefix = "ttySLG"; +static const char driver_name[] = "SyncLink GT"; +static const char tty_dev_prefix[] = "ttySLG"; MODULE_LICENSE("GPL"); #define MAX_DEVICES 32 static const struct pci_device_id pci_table[] = { - {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, - {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT2_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, - {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT4_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, - {PCI_VENDOR_ID_MICROGATE, SYNCLINK_AC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, - {0,}, /* terminate list */ + { PCI_VDEVICE(MICROGATE, SYNCLINK_GT_DEVICE_ID) }, + { PCI_VDEVICE(MICROGATE, SYNCLINK_GT2_DEVICE_ID) }, + { PCI_VDEVICE(MICROGATE, SYNCLINK_GT4_DEVICE_ID) }, + { PCI_VDEVICE(MICROGATE, SYNCLINK_AC_DEVICE_ID) }, + { 0 }, /* terminate list */ }; MODULE_DEVICE_TABLE(pci, pci_table); @@ -323,7 +322,7 @@ struct slgt_info { }; -static MGSL_PARAMS default_params = { +static const MGSL_PARAMS default_params = { .mode = MGSL_MODE_HDLC, .loopback = 0, .flags = HDLC_FLAG_UNDERRUN_ABORT15, @@ -432,7 +431,7 @@ static void tx_set_idle(struct slgt_info *info); static unsigned int tbuf_bytes(struct slgt_info *info); static void reset_tbufs(struct slgt_info *info); static void tdma_reset(struct slgt_info *info); -static bool tx_load(struct slgt_info *info, const char *buf, unsigned int count); +static bool tx_load(struct slgt_info *info, const u8 *buf, unsigned int count); static void get_gtsignals(struct slgt_info *info); static void set_gtsignals(struct slgt_info *info); @@ -746,8 +745,7 @@ static void update_tx_timer(struct slgt_info *info) } } -static int write(struct tty_struct *tty, - const unsigned char *buf, int count) +static ssize_t write(struct tty_struct *tty, const u8 *buf, size_t count) { int ret = 0; struct slgt_info *info = tty->driver_data; @@ -756,7 +754,7 @@ static int write(struct tty_struct *tty, if (sanity_check(info, tty->name, "write")) return -EIO; - DBGINFO(("%s write count=%d\n", info->device_name, count)); + DBGINFO(("%s write count=%zu\n", info->device_name, count)); if (!info->tx_buf || (count > info->max_frame_size)) return -EIO; @@ -782,7 +780,7 @@ cleanup: return ret; } -static int put_char(struct tty_struct *tty, unsigned char ch) +static int put_char(struct tty_struct *tty, u8 ch) { struct slgt_info *info = tty->driver_data; unsigned long flags; @@ -790,7 +788,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch) if (sanity_check(info, tty->name, "put_char")) return 0; - DBGINFO(("%s put_char(%d)\n", info->device_name, ch)); + DBGINFO(("%s put_char(%u)\n", info->device_name, ch)); if (!info->tx_buf) return 0; spin_lock_irqsave(&info->lock,flags); @@ -1088,12 +1086,13 @@ static long get_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *us static long set_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *new_params) { struct MGSL_PARAMS32 tmp_params; + unsigned long flags; DBGINFO(("%s set_params32\n", info->device_name)); if (copy_from_user(&tmp_params, new_params, sizeof(struct MGSL_PARAMS32))) return -EFAULT; - spin_lock(&info->lock); + spin_lock_irqsave(&info->lock, flags); if (tmp_params.mode == MGSL_MODE_BASE_CLOCK) { info->base_clock = tmp_params.clock_speed; } else { @@ -1111,7 +1110,7 @@ static long set_params32(struct slgt_info *info, struct MGSL_PARAMS32 __user *ne info->params.stop_bits = tmp_params.stop_bits; info->params.parity = tmp_params.parity; } - spin_unlock(&info->lock); + spin_unlock_irqrestore(&info->lock, flags); program_hw(info); @@ -3629,8 +3628,6 @@ static void slgt_cleanup(void) struct slgt_info *info; struct slgt_info *tmp; - printk(KERN_INFO "unload %s\n", driver_name); - if (serial_driver) { for (info=slgt_device_list ; info != NULL ; info=info->next_device) tty_unregister_device(serial_driver, info->line); @@ -3672,8 +3669,6 @@ static int __init slgt_init(void) { int rc; - printk(KERN_INFO "%s\n", driver_name); - serial_driver = tty_alloc_driver(MAX_DEVICES, TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV); if (IS_ERR(serial_driver)) { @@ -3683,7 +3678,7 @@ static int __init slgt_init(void) /* Initialize the tty_driver structure */ - serial_driver->driver_name = slgt_driver_name; + serial_driver->driver_name = "synclink_gt"; serial_driver->name = tty_dev_prefix; serial_driver->major = ttymajor; serial_driver->minor_start = 64; @@ -3702,9 +3697,6 @@ static int __init slgt_init(void) goto error; } - printk(KERN_INFO "%s, tty major#%d\n", - driver_name, serial_driver->major); - slgt_device_count = 0; if ((rc = pci_register_driver(&pci_driver)) < 0) { printk("%s pci_register_driver error=%d\n", driver_name, rc); @@ -3712,9 +3704,6 @@ static int __init slgt_init(void) } pci_registered = true; - if (!slgt_device_list) - printk("%s no devices found\n",driver_name); - return 0; error: @@ -3734,47 +3723,47 @@ module_exit(slgt_exit); * register access routines */ -#define CALC_REGADDR() \ - unsigned long reg_addr = ((unsigned long)info->reg_addr) + addr; \ - if (addr >= 0x80) \ - reg_addr += (info->port_num) * 32; \ - else if (addr >= 0x40) \ - reg_addr += (info->port_num) * 16; +static inline void __iomem *calc_regaddr(struct slgt_info *info, + unsigned int addr) +{ + void __iomem *reg_addr = info->reg_addr + addr; + + if (addr >= 0x80) + reg_addr += info->port_num * 32; + else if (addr >= 0x40) + reg_addr += info->port_num * 16; + + return reg_addr; +} static __u8 rd_reg8(struct slgt_info *info, unsigned int addr) { - CALC_REGADDR(); - return readb((void __iomem *)reg_addr); + return readb(calc_regaddr(info, addr)); } static void wr_reg8(struct slgt_info *info, unsigned int addr, __u8 value) { - CALC_REGADDR(); - writeb(value, (void __iomem *)reg_addr); + writeb(value, calc_regaddr(info, addr)); } static __u16 rd_reg16(struct slgt_info *info, unsigned int addr) { - CALC_REGADDR(); - return readw((void __iomem *)reg_addr); + return readw(calc_regaddr(info, addr)); } static void wr_reg16(struct slgt_info *info, unsigned int addr, __u16 value) { - CALC_REGADDR(); - writew(value, (void __iomem *)reg_addr); + writew(value, calc_regaddr(info, addr)); } static __u32 rd_reg32(struct slgt_info *info, unsigned int addr) { - CALC_REGADDR(); - return readl((void __iomem *)reg_addr); + return readl(calc_regaddr(info, addr)); } static void wr_reg32(struct slgt_info *info, unsigned int addr, __u32 value) { - CALC_REGADDR(); - writel(value, (void __iomem *)reg_addr); + writel(value, calc_regaddr(info, addr)); } static void rdma_reset(struct slgt_info *info) @@ -4777,7 +4766,7 @@ static unsigned int tbuf_bytes(struct slgt_info *info) * load data into transmit DMA buffer ring and start transmitter if needed * return true if data accepted, otherwise false (buffers full) */ -static bool tx_load(struct slgt_info *info, const char *buf, unsigned int size) +static bool tx_load(struct slgt_info *info, const u8 *buf, unsigned int size) { unsigned short count; unsigned int i; |