drivers/tty/serial/max3100.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/max3100.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/max3100.c- Extension
.c- Size
- 19851 bytes
- Lines
- 841
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/container_of.hlinux/delay.hlinux/device.hlinux/freezer.hlinux/mod_devicetable.hlinux/module.hlinux/pm.hlinux/property.hlinux/serial_core.hlinux/serial.hlinux/slab.hlinux/spi/spi.hlinux/tty_flip.hlinux/tty.hlinux/types.hlinux/unaligned.h
Detected Declarations
struct max3100_portfunction max3100_do_parityfunction max3100_check_parityfunction max3100_calc_parityfunction max3100_srfunction max3100_handlerx_unlockedfunction max3100_handlerxfunction max3100_workfunction uart_fifo_getfunction max3100_doworkfunction max3100_timeoutfunction max3100_irqfunction max3100_enable_msfunction max3100_start_txfunction max3100_stop_rxfunction max3100_tx_emptyfunction max3100_get_mctrlfunction max3100_set_mctrlfunction max3100_set_termiosfunction max3100_shutdownfunction max3100_startupfunction max3100_release_portfunction max3100_config_portfunction max3100_verify_portfunction max3100_stop_txfunction max3100_request_portfunction max3100_break_ctlfunction max3100_probefunction max3100_removefunction max3100_suspendfunction max3100_resume
Annotated Snippet
struct max3100_port {
struct uart_port port;
struct spi_device *spi;
int cts; /* last CTS received for flow ctrl */
int tx_empty; /* last TX empty bit */
spinlock_t conf_lock; /* shared data */
int conf_commit; /* need to make changes */
int conf; /* configuration for the MAX31000
* (bits 0-7, bits 8-11 are irqs) */
int rts_commit; /* need to change rts */
int rts; /* rts status */
int baud; /* current baud rate */
int parity; /* keeps track if we should send parity */
#define MAX3100_PARITY_ON 1
#define MAX3100_PARITY_ODD 2
#define MAX3100_7BIT 4
int rx_enabled; /* if we should rx chars */
int minor; /* minor number */
int loopback_commit; /* need to change loopback */
int loopback; /* 1 if we are in loopback mode */
/* for handling irqs: need workqueue since we do spi_sync */
struct workqueue_struct *workqueue;
struct work_struct work;
/* set to 1 to make the workhandler exit as soon as possible */
int force_end_work;
/* need to know we are suspending to avoid deadlock on workqueue */
int suspending;
struct timer_list timer;
};
static inline struct max3100_port *to_max3100_port(struct uart_port *port)
{
return container_of(port, struct max3100_port, port);
}
static struct max3100_port *max3100s[MAX_MAX3100]; /* the chips */
static DEFINE_MUTEX(max3100s_lock); /* race on probe */
static int max3100_do_parity(struct max3100_port *s, u16 c)
{
int parity;
if (s->parity & MAX3100_PARITY_ODD)
parity = 1;
else
parity = 0;
if (s->parity & MAX3100_7BIT)
c &= 0x7f;
else
c &= 0xff;
parity = parity ^ parity8(c);
return parity;
}
static int max3100_check_parity(struct max3100_port *s, u16 c)
{
return max3100_do_parity(s, c) == ((c >> 8) & 1);
}
static void max3100_calc_parity(struct max3100_port *s, u16 *c)
{
if (s->parity & MAX3100_7BIT)
*c &= 0x7f;
else
*c &= 0xff;
if (s->parity & MAX3100_PARITY_ON)
*c |= max3100_do_parity(s, *c) << 8;
}
static int max3100_sr(struct max3100_port *s, u16 tx, u16 *rx)
{
struct spi_message message;
__be16 etx, erx;
int status;
struct spi_transfer tran = {
.tx_buf = &etx,
.rx_buf = &erx,
.len = 2,
};
etx = cpu_to_be16(tx);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/container_of.h`, `linux/delay.h`, `linux/device.h`, `linux/freezer.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pm.h`.
- Detected declarations: `struct max3100_port`, `function max3100_do_parity`, `function max3100_check_parity`, `function max3100_calc_parity`, `function max3100_sr`, `function max3100_handlerx_unlocked`, `function max3100_handlerx`, `function max3100_work`, `function uart_fifo_get`, `function max3100_dowork`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.