drivers/pcmcia/socket_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/pcmcia/socket_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pcmcia/socket_sysfs.c- Extension
.c- Size
- 5801 bytes
- Lines
- 230
- Domain
- Driver Families
- Bucket
- drivers/pcmcia
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/moduleparam.hlinux/init.hlinux/kernel.hlinux/string.hlinux/string_choices.hlinux/major.hlinux/errno.hlinux/mm.hlinux/interrupt.hlinux/timer.hlinux/ioport.hlinux/delay.hlinux/pm.hlinux/device.hlinux/mutex.hasm/irq.hpcmcia/ss.hpcmcia/cistpl.hpcmcia/cisreg.hpcmcia/ds.hcs_internal.h
Detected Declarations
function pccard_show_typefunction pccard_show_voltagefunction pccard_show_vppfunction pccard_show_vccfunction pccard_store_insertfunction pccard_show_card_pm_statefunction pccard_store_card_pm_statefunction pccard_store_ejectfunction pccard_show_irq_maskfunction pccard_store_irq_maskfunction pccard_show_resourcefunction pccard_store_resourcefunction pccard_sysfs_add_socketfunction pccard_sysfs_remove_socket
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* socket_sysfs.c -- most of socket-related sysfs output
*
* (C) 2003 - 2004 Dominik Brodowski
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/string_choices.h>
#include <linux/major.h>
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/device.h>
#include <linux/mutex.h>
#include <asm/irq.h>
#include <pcmcia/ss.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/ds.h>
#include "cs_internal.h"
#define to_socket(_dev) container_of(_dev, struct pcmcia_socket, dev)
static ssize_t pccard_show_type(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pcmcia_socket *s = to_socket(dev);
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
if (s->state & SOCKET_CARDBUS)
return sysfs_emit(buf, "32-bit\n");
return sysfs_emit(buf, "16-bit\n");
}
static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
static ssize_t pccard_show_voltage(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pcmcia_socket *s = to_socket(dev);
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
if (s->socket.Vcc)
return sysfs_emit(buf, "%d.%dV\n", s->socket.Vcc / 10,
s->socket.Vcc % 10);
return sysfs_emit(buf, "X.XV\n");
}
static DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
static ssize_t pccard_show_vpp(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pcmcia_socket *s = to_socket(dev);
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
return sysfs_emit(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
}
static DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
static ssize_t pccard_show_vcc(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pcmcia_socket *s = to_socket(dev);
if (!(s->state & SOCKET_PRESENT))
return -ENODEV;
return sysfs_emit(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
}
static DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
static ssize_t pccard_store_insert(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct pcmcia_socket *s = to_socket(dev);
if (!count)
return -EINVAL;
pcmcia_parse_uevents(s, PCMCIA_UEVENT_INSERT);
Annotation
- Immediate include surface: `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/kernel.h`, `linux/string.h`, `linux/string_choices.h`, `linux/major.h`, `linux/errno.h`.
- Detected declarations: `function pccard_show_type`, `function pccard_show_voltage`, `function pccard_show_vpp`, `function pccard_show_vcc`, `function pccard_store_insert`, `function pccard_show_card_pm_state`, `function pccard_store_card_pm_state`, `function pccard_store_eject`, `function pccard_show_irq_mask`, `function pccard_store_irq_mask`.
- Atlas domain: Driver Families / drivers/pcmcia.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.