drivers/power/reset/pwr-mlxbf.c
Source file repositories/reference/linux-study-clean/drivers/power/reset/pwr-mlxbf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/power/reset/pwr-mlxbf.c- Extension
.c- Size
- 2274 bytes
- Lines
- 98
- Domain
- Driver Families
- Bucket
- drivers/power
- 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.
- 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/acpi.hlinux/device.hlinux/devm-helpers.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pm.hlinux/reboot.hlinux/types.h
Detected Declarations
struct pwr_mlxbffunction pwr_mlxbf_reboot_workfunction pwr_mlxbf_irqfunction pwr_mlxbf_probe
Annotated Snippet
struct pwr_mlxbf {
struct work_struct reboot_work;
const char *hid;
};
static void pwr_mlxbf_reboot_work(struct work_struct *work)
{
acpi_bus_generate_netlink_event("button/reboot.*", "Reboot Button", 0x80, 1);
}
static irqreturn_t pwr_mlxbf_irq(int irq, void *ptr)
{
const char *rst_pwr_hid = "MLNXBF24";
const char *shutdown_hid = "MLNXBF29";
struct pwr_mlxbf *priv = ptr;
if (!strncmp(priv->hid, rst_pwr_hid, 8))
schedule_work(&priv->reboot_work);
if (!strncmp(priv->hid, shutdown_hid, 8))
orderly_poweroff(true);
return IRQ_HANDLED;
}
static int pwr_mlxbf_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct acpi_device *adev;
struct pwr_mlxbf *priv;
const char *hid;
int irq, err;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
adev = ACPI_COMPANION(dev);
if (!adev)
return -ENXIO;
hid = acpi_device_hid(adev);
priv->hid = hid;
irq = acpi_dev_gpio_irq_get(ACPI_COMPANION(dev), 0);
if (irq < 0)
return dev_err_probe(dev, irq, "Error getting %s irq.\n", priv->hid);
err = devm_work_autocancel(dev, &priv->reboot_work, pwr_mlxbf_reboot_work);
if (err)
return err;
err = devm_request_irq(dev, irq, pwr_mlxbf_irq, 0, hid, priv);
if (err)
dev_err(dev, "Failed request of %s irq\n", priv->hid);
return err;
}
static const struct acpi_device_id __maybe_unused pwr_mlxbf_acpi_match[] = {
{ "MLNXBF24", 0 },
{ "MLNXBF29", 0 },
{},
};
MODULE_DEVICE_TABLE(acpi, pwr_mlxbf_acpi_match);
static struct platform_driver pwr_mlxbf_driver = {
.driver = {
.name = "pwr_mlxbf",
.acpi_match_table = pwr_mlxbf_acpi_match,
},
.probe = pwr_mlxbf_probe,
};
module_platform_driver(pwr_mlxbf_driver);
MODULE_DESCRIPTION("Mellanox BlueField power driver");
MODULE_AUTHOR("Asmaa Mnebhi <asmaa@nvidia.com>");
MODULE_LICENSE("Dual BSD/GPL");
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/device.h`, `linux/devm-helpers.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct pwr_mlxbf`, `function pwr_mlxbf_reboot_work`, `function pwr_mlxbf_irq`, `function pwr_mlxbf_probe`.
- Atlas domain: Driver Families / drivers/power.
- Implementation status: source implementation candidate.
- 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.