drivers/media/pci/mgb4/mgb4_sysfs_pci.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/mgb4/mgb4_sysfs_pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/mgb4/mgb4_sysfs_pci.c- Extension
.c- Size
- 1941 bytes
- Lines
- 72
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hmgb4_core.hmgb4_sysfs.h
Detected Declarations
function Copyrightfunction module_type_showfunction fw_version_showfunction fw_type_showfunction serial_number_show
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021-2022 Digiteq Automotive
* author: Martin Tuma <martin.tuma@digiteqautomotive.com>
*
* This module handles all the sysfs info/configuration that is related to the
* PCI card device.
*/
#include <linux/device.h>
#include "mgb4_core.h"
#include "mgb4_sysfs.h"
static ssize_t module_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
return sprintf(buf, "%u\n", mgbdev->module_version & 0x0F);
}
static ssize_t module_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
return sprintf(buf, "%u\n", mgbdev->module_version >> 4);
}
static ssize_t fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
u32 config = mgb4_read_reg(&mgbdev->video, 0xC4);
return sprintf(buf, "%u\n", config & 0xFFFF);
}
static ssize_t fw_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
u32 config = mgb4_read_reg(&mgbdev->video, 0xC4);
return sprintf(buf, "%u\n", config >> 24);
}
static ssize_t serial_number_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct mgb4_dev *mgbdev = dev_get_drvdata(dev);
u32 sn = mgbdev->serial_number;
return sprintf(buf, "%03d-%03d-%03d-%03d\n", sn >> 24, (sn >> 16) & 0xFF,
(sn >> 8) & 0xFF, sn & 0xFF);
}
static DEVICE_ATTR_RO(module_version);
static DEVICE_ATTR_RO(module_type);
static DEVICE_ATTR_RO(fw_version);
static DEVICE_ATTR_RO(fw_type);
static DEVICE_ATTR_RO(serial_number);
struct attribute *mgb4_pci_attrs[] = {
&dev_attr_module_type.attr,
&dev_attr_module_version.attr,
&dev_attr_fw_type.attr,
&dev_attr_fw_version.attr,
&dev_attr_serial_number.attr,
NULL
};
Annotation
- Immediate include surface: `linux/device.h`, `mgb4_core.h`, `mgb4_sysfs.h`.
- Detected declarations: `function Copyright`, `function module_type_show`, `function fw_version_show`, `function fw_type_show`, `function serial_number_show`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.