drivers/scsi/scsi_pm.c
Source file repositories/reference/linux-study-clean/drivers/scsi/scsi_pm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/scsi_pm.c- Extension
.c- Size
- 6090 bytes
- Lines
- 273
- Domain
- Driver Families
- Bucket
- drivers/scsi
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pm_runtime.hlinux/export.hlinux/blk-pm.hscsi/scsi.hscsi/scsi_device.hscsi/scsi_driver.hscsi/scsi_host.hscsi_priv.h
Detected Declarations
function do_scsi_suspendfunction do_scsi_freezefunction do_scsi_powerofffunction do_scsi_resumefunction do_scsi_thawfunction do_scsi_restorefunction scsi_dev_type_suspendfunction scsi_bus_suspend_commonfunction scsi_bus_resume_commonfunction scsi_bus_preparefunction scsi_bus_suspendfunction scsi_bus_resumefunction scsi_bus_freezefunction scsi_bus_thawfunction scsi_bus_powerofffunction scsi_bus_restorefunction sdev_runtime_suspendfunction scsi_runtime_suspendfunction sdev_runtime_resumefunction scsi_runtime_resumefunction scsi_runtime_idlefunction scsi_autopm_get_devicefunction scsi_autopm_put_devicefunction scsi_autopm_get_targetfunction scsi_autopm_put_targetfunction scsi_autopm_get_hostfunction scsi_autopm_put_hostexport scsi_autopm_get_deviceexport scsi_autopm_put_device
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* scsi_pm.c Copyright (C) 2010 Alan Stern
*
* SCSI dynamic Power Management
* Initial version: Alan Stern <stern@rowland.harvard.edu>
*/
#include <linux/pm_runtime.h>
#include <linux/export.h>
#include <linux/blk-pm.h>
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_driver.h>
#include <scsi/scsi_host.h>
#include "scsi_priv.h"
#ifdef CONFIG_PM_SLEEP
static int do_scsi_suspend(struct device *dev, const struct dev_pm_ops *pm)
{
return pm && pm->suspend ? pm->suspend(dev) : 0;
}
static int do_scsi_freeze(struct device *dev, const struct dev_pm_ops *pm)
{
return pm && pm->freeze ? pm->freeze(dev) : 0;
}
static int do_scsi_poweroff(struct device *dev, const struct dev_pm_ops *pm)
{
return pm && pm->poweroff ? pm->poweroff(dev) : 0;
}
static int do_scsi_resume(struct device *dev, const struct dev_pm_ops *pm)
{
return pm && pm->resume ? pm->resume(dev) : 0;
}
static int do_scsi_thaw(struct device *dev, const struct dev_pm_ops *pm)
{
return pm && pm->thaw ? pm->thaw(dev) : 0;
}
static int do_scsi_restore(struct device *dev, const struct dev_pm_ops *pm)
{
return pm && pm->restore ? pm->restore(dev) : 0;
}
static int scsi_dev_type_suspend(struct device *dev,
int (*cb)(struct device *, const struct dev_pm_ops *))
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int err;
err = scsi_device_quiesce(to_scsi_device(dev));
if (err == 0) {
err = cb(dev, pm);
if (err)
scsi_device_resume(to_scsi_device(dev));
}
dev_dbg(dev, "scsi suspend: %d\n", err);
return err;
}
static int
scsi_bus_suspend_common(struct device *dev,
int (*cb)(struct device *, const struct dev_pm_ops *))
{
if (!scsi_is_sdev_device(dev))
return 0;
return scsi_dev_type_suspend(dev, cb);
}
static int scsi_bus_resume_common(struct device *dev,
int (*cb)(struct device *, const struct dev_pm_ops *))
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int err;
if (!scsi_is_sdev_device(dev))
return 0;
err = cb(dev, pm);
scsi_device_resume(to_scsi_device(dev));
dev_dbg(dev, "scsi resume: %d\n", err);
Annotation
- Immediate include surface: `linux/pm_runtime.h`, `linux/export.h`, `linux/blk-pm.h`, `scsi/scsi.h`, `scsi/scsi_device.h`, `scsi/scsi_driver.h`, `scsi/scsi_host.h`, `scsi_priv.h`.
- Detected declarations: `function do_scsi_suspend`, `function do_scsi_freeze`, `function do_scsi_poweroff`, `function do_scsi_resume`, `function do_scsi_thaw`, `function do_scsi_restore`, `function scsi_dev_type_suspend`, `function scsi_bus_suspend_common`, `function scsi_bus_resume_common`, `function scsi_bus_prepare`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: integration 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.