drivers/gpib/gpio/gpib_bitbang.c
Source file repositories/reference/linux-study-clean/drivers/gpib/gpio/gpib_bitbang.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpib/gpio/gpib_bitbang.c- Extension
.c- Size
- 40865 bytes
- Lines
- 1471
- Domain
- Driver Families
- Bucket
- drivers/gpib
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
gpibP.hgpib_state_machines.hlinux/sched.hlinux/module.hlinux/slab.hlinux/string.hlinux/init.hlinux/delay.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/gpio/machine.hlinux/gpio.hlinux/irq.h
Detected Declarations
struct bb_privenum lines_tfunction printablefunction bb_readfunction routinefunction bb_writefunction routinefunction routinefunction bb_SRQ_interruptfunction bb_commandfunction bb_buffer_printfunction set_atnfunction bb_take_controlfunction bb_go_to_standbyfunction bb_request_system_controlfunction bb_interface_clearfunction bb_remote_enablefunction bb_enable_eosfunction bb_disable_eosfunction bb_update_statusfunction bb_primary_addressfunction bb_secondary_addressfunction bb_parallel_pollfunction bb_parallel_poll_configurefunction bb_t1_delayfunction bb_return_to_localfunction allocate_privatefunction free_privatefunction bb_get_irqfunction bb_free_irqfunction release_gpiosfunction allocate_gpiosfunction bb_detachfunction bb_attachfunction bb_init_modulefunction bb_exit_modulefunction usec_difffunction check_for_eosfunction set_data_lines_outputfunction set_data_linesfunction get_data_linesfunction set_data_lines_inputfunction SET_DIR_WRITEfunction SET_DIR_READmodule init bb_init_module
Annotated Snippet
module_init(bb_init_module);
module_exit(bb_exit_module);
/***************************************************************************
* *
* UTILITY Functions *
* *
***************************************************************************/
inline long usec_diff(struct timespec64 *a, struct timespec64 *b)
{
return ((a->tv_sec - b->tv_sec) * 1000000 +
(a->tv_nsec - b->tv_nsec) / 1000);
}
static inline int check_for_eos(struct bb_priv *priv, u8 byte)
{
if (priv->eos_check)
return 0;
if (priv->eos_check_8) {
if (priv->eos == byte)
return 1;
} else {
if (priv->eos_mask_7 == (byte & 0x7f))
return 1;
}
return 0;
}
static void set_data_lines_output(void)
{
gpiod_direction_output(D01, 1);
gpiod_direction_output(D02, 1);
gpiod_direction_output(D03, 1);
gpiod_direction_output(D04, 1);
gpiod_direction_output(D05, 1);
gpiod_direction_output(D06, 1);
gpiod_direction_output(D07, 1);
gpiod_direction_output(D08, 1);
}
static void set_data_lines(u8 byte)
{
gpiod_set_value(D01, !(byte & 0x01));
gpiod_set_value(D02, !(byte & 0x02));
gpiod_set_value(D03, !(byte & 0x04));
gpiod_set_value(D04, !(byte & 0x08));
gpiod_set_value(D05, !(byte & 0x10));
gpiod_set_value(D06, !(byte & 0x20));
gpiod_set_value(D07, !(byte & 0x40));
gpiod_set_value(D08, !(byte & 0x80));
}
static u8 get_data_lines(void)
{
u8 ret;
ret = gpiod_get_value(D01);
ret |= gpiod_get_value(D02) << 1;
ret |= gpiod_get_value(D03) << 2;
ret |= gpiod_get_value(D04) << 3;
ret |= gpiod_get_value(D05) << 4;
ret |= gpiod_get_value(D06) << 5;
ret |= gpiod_get_value(D07) << 6;
ret |= gpiod_get_value(D08) << 7;
return ~ret;
}
static void set_data_lines_input(void)
{
gpiod_direction_input(D01);
gpiod_direction_input(D02);
gpiod_direction_input(D03);
gpiod_direction_input(D04);
gpiod_direction_input(D05);
gpiod_direction_input(D06);
gpiod_direction_input(D07);
gpiod_direction_input(D08);
}
static inline void SET_DIR_WRITE(struct bb_priv *priv)
{
if (priv->direction == DIR_WRITE)
return;
gpiod_direction_input(NRFD);
gpiod_direction_input(NDAC);
set_data_lines_output();
gpiod_direction_output(DAV, 1);
gpiod_direction_output(EOI, 1);
Annotation
- Immediate include surface: `gpibP.h`, `gpib_state_machines.h`, `linux/sched.h`, `linux/module.h`, `linux/slab.h`, `linux/string.h`, `linux/init.h`, `linux/delay.h`.
- Detected declarations: `struct bb_priv`, `enum lines_t`, `function printable`, `function bb_read`, `function routine`, `function bb_write`, `function routine`, `function routine`, `function bb_SRQ_interrupt`, `function bb_command`.
- Atlas domain: Driver Families / drivers/gpib.
- Implementation status: integration 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.