drivers/parport/share.c
Source file repositories/reference/linux-study-clean/drivers/parport/share.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/parport/share.c- Extension
.c- Size
- 33943 bytes
- Lines
- 1222
- Domain
- Driver Families
- Bucket
- drivers/parport
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/module.hlinux/string.hlinux/threads.hlinux/parport.hlinux/delay.hlinux/errno.hlinux/interrupt.hlinux/ioport.hlinux/kernel.hlinux/slab.hlinux/sched/signal.hlinux/kmod.hlinux/device.hlinux/spinlock.hlinux/mutex.hasm/irq.h
Detected Declarations
function dead_write_linesfunction dead_frob_linesfunction dead_oneargfunction dead_readfunction is_parportfunction parport_probefunction parport_bus_initfunction parport_bus_exitfunction driver_checkfunction attach_driver_chainfunction driver_detachfunction detach_driver_chainfunction get_lowlevel_driverfunction port_checkfunction port_detectfunction parport_unregister_driverfunction port_detachfunction parport_register_driverfunction free_portfunction parport_put_portfunction parport_del_portfunction parport_get_portfunction parport_announce_portfunction parport_announce_portfunction parport_register_driverfunction free_pardevicefunction parport_enable_irqfunction parport_register_devicefunction parport_find_numberfunction parport_find_basefunction failfunction parport_claim_or_blockfunction parport_claim_or_blockfunction parport_releasefunction parport_releasefunction parport_irq_handlerexport __parport_register_driverexport parport_unregister_driverexport parport_get_portexport parport_del_portexport parport_put_portexport parport_register_portexport parport_announce_portexport parport_remove_portexport parport_register_dev_modelexport parport_unregister_deviceexport parport_find_numberexport parport_find_base
Annotated Snippet
static const struct bus_type parport_bus_type = {
.name = "parport",
.probe = parport_probe,
};
int parport_bus_init(void)
{
return bus_register(&parport_bus_type);
}
void parport_bus_exit(void)
{
bus_unregister(&parport_bus_type);
}
/*
* iterates through all the drivers registered with the bus and sends the port
* details to the match_port callback of the driver, so that the driver can
* know about the new port that just registered with the bus and decide if it
* wants to use this new port.
*/
static int driver_check(struct device_driver *dev_drv, void *_port)
{
struct parport *port = _port;
struct parport_driver *drv = to_parport_driver(dev_drv);
if (drv->match_port)
drv->match_port(port);
return 0;
}
/* Call attach(port) for each registered driver. */
static void attach_driver_chain(struct parport *port)
{
/* caller has exclusive registration_lock */
/*
* call the driver_check function of the drivers registered in
* new device model
*/
bus_for_each_drv(&parport_bus_type, NULL, port, driver_check);
}
static int driver_detach(struct device_driver *_drv, void *_port)
{
struct parport *port = _port;
struct parport_driver *drv = to_parport_driver(_drv);
if (drv->detach)
drv->detach(port);
return 0;
}
/* Call detach(port) for each registered driver. */
static void detach_driver_chain(struct parport *port)
{
/* caller has exclusive registration_lock */
/*
* call the detach function of the drivers registered in
* new device model
*/
bus_for_each_drv(&parport_bus_type, NULL, port, driver_detach);
}
/* Ask kmod for some lowlevel drivers. */
static void get_lowlevel_driver(void)
{
/*
* There is no actual module called this: you should set
* up an alias for modutils.
*/
request_module("parport_lowlevel");
}
/*
* iterates through all the devices connected to the bus and sends the device
* details to the match_port callback of the driver, so that the driver can
* know what are all the ports that are connected to the bus and choose the
* port to which it wants to register its device.
*/
static int port_check(struct device *dev, void *dev_drv)
{
struct parport_driver *drv = dev_drv;
struct parport *port;
/* only send ports, do not send other devices connected to bus */
if (is_parport(dev)) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/string.h`, `linux/threads.h`, `linux/parport.h`, `linux/delay.h`, `linux/errno.h`, `linux/interrupt.h`, `linux/ioport.h`.
- Detected declarations: `function dead_write_lines`, `function dead_frob_lines`, `function dead_onearg`, `function dead_read`, `function is_parport`, `function parport_probe`, `function parport_bus_init`, `function parport_bus_exit`, `function driver_check`, `function attach_driver_chain`.
- Atlas domain: Driver Families / drivers/parport.
- Implementation status: pattern 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.