drivers/char/ipmi/kcs_bmc.c
Source file repositories/reference/linux-study-clean/drivers/char/ipmi/kcs_bmc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/ipmi/kcs_bmc.c- Extension
.c- Size
- 4812 bytes
- Lines
- 191
- Domain
- Driver Families
- Bucket
- drivers/char
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/list.hlinux/module.hlinux/mutex.hkcs_bmc.hkcs_bmc_device.hkcs_bmc_client.h
Detected Declarations
function kcs_bmc_read_datafunction kcs_bmc_write_datafunction kcs_bmc_read_statusfunction kcs_bmc_write_statusfunction kcs_bmc_update_statusfunction kcs_bmc_handle_eventfunction kcs_bmc_enable_devicefunction kcs_bmc_disable_devicefunction kcs_bmc_add_devicefunction kcs_bmc_remove_devicefunction kcs_bmc_register_driverfunction kcs_bmc_unregister_driverfunction kcs_bmc_update_event_maskexport kcs_bmc_read_dataexport kcs_bmc_write_dataexport kcs_bmc_read_statusexport kcs_bmc_write_statusexport kcs_bmc_update_statusexport kcs_bmc_handle_eventexport kcs_bmc_enable_deviceexport kcs_bmc_disable_deviceexport kcs_bmc_add_deviceexport kcs_bmc_remove_deviceexport kcs_bmc_register_driverexport kcs_bmc_unregister_driverexport kcs_bmc_update_event_mask
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2015-2018, Intel Corporation.
* Copyright (c) 2021, IBM Corp.
*/
#include <linux/device.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include "kcs_bmc.h"
/* Implement both the device and client interfaces here */
#include "kcs_bmc_device.h"
#include "kcs_bmc_client.h"
/* Record registered devices and drivers */
static DEFINE_MUTEX(kcs_bmc_lock);
static LIST_HEAD(kcs_bmc_devices);
static LIST_HEAD(kcs_bmc_drivers);
/* Consumer data access */
u8 kcs_bmc_read_data(struct kcs_bmc_device *kcs_bmc)
{
return kcs_bmc->ops->io_inputb(kcs_bmc, kcs_bmc->ioreg.idr);
}
EXPORT_SYMBOL(kcs_bmc_read_data);
void kcs_bmc_write_data(struct kcs_bmc_device *kcs_bmc, u8 data)
{
kcs_bmc->ops->io_outputb(kcs_bmc, kcs_bmc->ioreg.odr, data);
}
EXPORT_SYMBOL(kcs_bmc_write_data);
u8 kcs_bmc_read_status(struct kcs_bmc_device *kcs_bmc)
{
return kcs_bmc->ops->io_inputb(kcs_bmc, kcs_bmc->ioreg.str);
}
EXPORT_SYMBOL(kcs_bmc_read_status);
void kcs_bmc_write_status(struct kcs_bmc_device *kcs_bmc, u8 data)
{
kcs_bmc->ops->io_outputb(kcs_bmc, kcs_bmc->ioreg.str, data);
}
EXPORT_SYMBOL(kcs_bmc_write_status);
void kcs_bmc_update_status(struct kcs_bmc_device *kcs_bmc, u8 mask, u8 val)
{
kcs_bmc->ops->io_updateb(kcs_bmc, kcs_bmc->ioreg.str, mask, val);
}
EXPORT_SYMBOL(kcs_bmc_update_status);
irqreturn_t kcs_bmc_handle_event(struct kcs_bmc_device *kcs_bmc)
{
struct kcs_bmc_client *client;
irqreturn_t rc = IRQ_NONE;
unsigned long flags;
spin_lock_irqsave(&kcs_bmc->lock, flags);
client = kcs_bmc->client;
if (client)
rc = client->ops->event(client);
spin_unlock_irqrestore(&kcs_bmc->lock, flags);
return rc;
}
EXPORT_SYMBOL(kcs_bmc_handle_event);
int kcs_bmc_enable_device(struct kcs_bmc_device *kcs_bmc, struct kcs_bmc_client *client)
{
int rc;
spin_lock_irq(&kcs_bmc->lock);
if (kcs_bmc->client) {
rc = -EBUSY;
} else {
u8 mask = KCS_BMC_EVENT_TYPE_IBF;
kcs_bmc->client = client;
kcs_bmc_update_event_mask(kcs_bmc, mask, mask);
rc = 0;
}
spin_unlock_irq(&kcs_bmc->lock);
return rc;
}
EXPORT_SYMBOL(kcs_bmc_enable_device);
Annotation
- Immediate include surface: `linux/device.h`, `linux/list.h`, `linux/module.h`, `linux/mutex.h`, `kcs_bmc.h`, `kcs_bmc_device.h`, `kcs_bmc_client.h`.
- Detected declarations: `function kcs_bmc_read_data`, `function kcs_bmc_write_data`, `function kcs_bmc_read_status`, `function kcs_bmc_write_status`, `function kcs_bmc_update_status`, `function kcs_bmc_handle_event`, `function kcs_bmc_enable_device`, `function kcs_bmc_disable_device`, `function kcs_bmc_add_device`, `function kcs_bmc_remove_device`.
- Atlas domain: Driver Families / drivers/char.
- 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.