drivers/ipack/ipack.c
Source file repositories/reference/linux-study-clean/drivers/ipack/ipack.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ipack/ipack.c- Extension
.c- Size
- 11858 bytes
- Lines
- 504
- Domain
- Driver Families
- Bucket
- drivers/ipack
- 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.
- 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/slab.hlinux/idr.hlinux/io.hlinux/ipack.h
Detected Declarations
function ipack_device_releasefunction ipack_match_one_devicefunction ipack_match_idfunction ipack_bus_matchfunction ipack_bus_probefunction ipack_bus_removefunction ipack_ueventfunction id_showfunction id_vendor_showfunction id_device_showfunction modalias_showfunction ipack_unregister_bus_memberfunction ipack_bus_unregisterfunction ipack_driver_registerfunction ipack_driver_unregisterfunction ipack_crc_bytefunction ipack_calc_crc1function ipack_calc_crc2function ipack_parse_id1function ipack_parse_id2function ipack_device_read_idfunction ipack_device_initfunction ipack_device_addfunction ipack_device_delfunction ipack_get_devicefunction ipack_put_devicefunction ipack_initfunction ipack_exitmodule init ipack_initexport ipack_bus_registerexport ipack_bus_unregisterexport ipack_driver_registerexport ipack_driver_unregisterexport ipack_device_initexport ipack_device_addexport ipack_device_delexport ipack_get_deviceexport ipack_put_device
Annotated Snippet
static int ipack_bus_match(struct device *dev, const struct device_driver *drv)
{
struct ipack_device *idev = to_ipack_dev(dev);
const struct ipack_driver *idrv = to_ipack_driver(drv);
const struct ipack_device_id *found_id;
found_id = ipack_match_id(idrv->id_table, idev);
return found_id ? 1 : 0;
}
static int ipack_bus_probe(struct device *device)
{
struct ipack_device *dev = to_ipack_dev(device);
struct ipack_driver *drv = to_ipack_driver(device->driver);
return drv->ops->probe(dev);
}
static void ipack_bus_remove(struct device *device)
{
struct ipack_device *dev = to_ipack_dev(device);
struct ipack_driver *drv = to_ipack_driver(device->driver);
if (drv->ops->remove)
drv->ops->remove(dev);
}
static int ipack_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct ipack_device *idev;
if (!dev)
return -ENODEV;
idev = to_ipack_dev(dev);
if (add_uevent_var(env,
"MODALIAS=ipack:f%02Xv%08Xd%08X", idev->id_format,
idev->id_vendor, idev->id_device))
return -ENOMEM;
return 0;
}
#define ipack_device_attr(field, format_string) \
static ssize_t \
field##_show(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
struct ipack_device *idev = to_ipack_dev(dev); \
return sprintf(buf, format_string, idev->field); \
}
static ssize_t id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
unsigned int i, c, l, s;
struct ipack_device *idev = to_ipack_dev(dev);
switch (idev->id_format) {
case IPACK_ID_VERSION_1:
l = 0x7; s = 1; break;
case IPACK_ID_VERSION_2:
l = 0xf; s = 2; break;
default:
return -EIO;
}
c = 0;
for (i = 0; i < idev->id_avail; i++) {
if (i > 0) {
if ((i & l) == 0)
buf[c++] = '\n';
else if ((i & s) == 0)
buf[c++] = ' ';
}
sprintf(&buf[c], "%02x", idev->id[i]);
c += 2;
}
buf[c++] = '\n';
return c;
}
static ssize_t
id_vendor_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct ipack_device *idev = to_ipack_dev(dev);
switch (idev->id_format) {
case IPACK_ID_VERSION_1:
return sprintf(buf, "0x%02x\n", idev->id_vendor);
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/idr.h`, `linux/io.h`, `linux/ipack.h`.
- Detected declarations: `function ipack_device_release`, `function ipack_match_one_device`, `function ipack_match_id`, `function ipack_bus_match`, `function ipack_bus_probe`, `function ipack_bus_remove`, `function ipack_uevent`, `function id_show`, `function id_vendor_show`, `function id_device_show`.
- Atlas domain: Driver Families / drivers/ipack.
- Implementation status: pattern implementation candidate.
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.