drivers/misc/tifm_core.c
Source file repositories/reference/linux-study-clean/drivers/misc/tifm_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/tifm_core.c- Extension
.c- Size
- 8299 bytes
- Lines
- 367
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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/tifm.hlinux/slab.hlinux/init.hlinux/idr.hlinux/module.h
Detected Declarations
function tifm_dev_matchfunction tifm_bus_matchfunction tifm_ueventfunction tifm_device_probefunction tifm_dummy_eventfunction tifm_device_removefunction tifm_device_suspendfunction tifm_device_resumefunction type_showfunction tifm_freefunction tifm_add_adapterfunction tifm_remove_adapterfunction tifm_free_adapterfunction tifm_free_devicefunction tifm_ejectfunction tifm_has_ms_piffunction tifm_map_sgfunction tifm_unmap_sgfunction tifm_queue_workfunction tifm_register_driverfunction tifm_unregister_driverfunction tifm_initfunction tifm_exitmodule init tifm_initexport tifm_alloc_adapterexport tifm_add_adapterexport tifm_remove_adapterexport tifm_free_adapterexport tifm_free_deviceexport tifm_alloc_deviceexport tifm_ejectexport tifm_has_ms_pifexport tifm_map_sgexport tifm_unmap_sgexport tifm_queue_workexport tifm_register_driverexport tifm_unregister_driver
Annotated Snippet
static int tifm_bus_match(struct device *dev, const struct device_driver *drv)
{
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
const struct tifm_driver *fm_drv = container_of_const(drv, struct tifm_driver,
driver);
const struct tifm_device_id *ids = fm_drv->id_table;
if (ids) {
while (ids->type) {
if (tifm_dev_match(sock, ids))
return 1;
++ids;
}
}
return 0;
}
static int tifm_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct tifm_dev *sock = container_of_const(dev, struct tifm_dev, dev);
if (add_uevent_var(env, "TIFM_CARD_TYPE=%s", tifm_media_type_name(sock->type, 1)))
return -ENOMEM;
return 0;
}
static int tifm_device_probe(struct device *dev)
{
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
driver);
int rc = -ENODEV;
get_device(dev);
if (dev->driver && drv->probe) {
rc = drv->probe(sock);
if (!rc)
return 0;
}
put_device(dev);
return rc;
}
static void tifm_dummy_event(struct tifm_dev *sock)
{
return;
}
static void tifm_device_remove(struct device *dev)
{
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
driver);
if (dev->driver && drv->remove) {
sock->card_event = tifm_dummy_event;
sock->data_event = tifm_dummy_event;
drv->remove(sock);
sock->dev.driver = NULL;
}
put_device(dev);
}
#ifdef CONFIG_PM
static int tifm_device_suspend(struct device *dev, pm_message_t state)
{
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
driver);
if (dev->driver && drv->suspend)
return drv->suspend(sock, state);
return 0;
}
static int tifm_device_resume(struct device *dev)
{
struct tifm_dev *sock = container_of(dev, struct tifm_dev, dev);
struct tifm_driver *drv = container_of(dev->driver, struct tifm_driver,
driver);
if (dev->driver && drv->resume)
return drv->resume(sock);
return 0;
}
#else
Annotation
- Immediate include surface: `linux/tifm.h`, `linux/slab.h`, `linux/init.h`, `linux/idr.h`, `linux/module.h`.
- Detected declarations: `function tifm_dev_match`, `function tifm_bus_match`, `function tifm_uevent`, `function tifm_device_probe`, `function tifm_dummy_event`, `function tifm_device_remove`, `function tifm_device_suspend`, `function tifm_device_resume`, `function type_show`, `function tifm_free`.
- Atlas domain: Driver Families / drivers/misc.
- 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.