drivers/ps3/ps3stor_lib.c
Source file repositories/reference/linux-study-clean/drivers/ps3/ps3stor_lib.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ps3/ps3stor_lib.c- Extension
.c- Size
- 9258 bytes
- Lines
- 352
- Domain
- Driver Families
- Bucket
- drivers/ps3
- 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.
- 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/dma-mapping.hlinux/module.hlinux/string_choices.hasm/lv1call.hasm/ps3stor.h
Detected Declarations
function ps3stor_open_hv_devicefunction ps3stor_close_hv_devicefunction ps3stor_probe_accessfunction ps3stor_setupfunction ps3stor_teardownfunction ps3stor_read_write_sectorsfunction ps3stor_send_commandexport ps3stor_setupexport ps3stor_teardownexport ps3stor_read_write_sectorsexport ps3stor_send_command
Annotated Snippet
if (ps3_flash_workaround.disk_sbd) {
ps3_close_hv_device(ps3_flash_workaround.disk_sbd);
ps3_flash_workaround.disk_open = 0;
ps3_flash_workaround.disk_sbd = NULL;
}
}
return 0;
}
static int ps3stor_probe_access(struct ps3_storage_device *dev)
{
int res, error;
unsigned int i;
unsigned long n;
if (dev->sbd.match_id == PS3_MATCH_ID_STOR_ROM) {
/* special case: CD-ROM is assumed always accessible */
dev->accessible_regions = 1;
return 0;
}
error = -EPERM;
for (i = 0; i < dev->num_regions; i++) {
dev_dbg(&dev->sbd.core,
"%s:%u: checking accessibility of region %u\n",
__func__, __LINE__, i);
dev->region_idx = i;
res = ps3stor_read_write_sectors(dev, dev->bounce_lpar, 0, 1,
0);
if (res) {
dev_dbg(&dev->sbd.core, "%s:%u: read failed, "
"region %u is not accessible\n", __func__,
__LINE__, i);
continue;
}
dev_dbg(&dev->sbd.core, "%s:%u: region %u is accessible\n",
__func__, __LINE__, i);
set_bit(i, &dev->accessible_regions);
/* We can access at least one region */
error = 0;
}
if (error)
return error;
n = hweight_long(dev->accessible_regions);
if (n > 1)
dev_info(&dev->sbd.core,
"%s:%u: %lu accessible regions found. Only the first "
"one will be used\n",
__func__, __LINE__, n);
dev->region_idx = __ffs(dev->accessible_regions);
dev_info(&dev->sbd.core,
"First accessible region has index %u start %llu size %llu\n",
dev->region_idx, dev->regions[dev->region_idx].start,
dev->regions[dev->region_idx].size);
return 0;
}
/**
* ps3stor_setup - Setup a storage device before use
* @dev: Pointer to a struct ps3_storage_device
* @handler: Pointer to an interrupt handler
*
* Returns 0 for success, or an error code
*/
int ps3stor_setup(struct ps3_storage_device *dev, irq_handler_t handler)
{
int error, res, alignment;
enum ps3_dma_page_size page_size;
error = ps3stor_open_hv_device(&dev->sbd);
if (error) {
dev_err(&dev->sbd.core,
"%s:%u: ps3_open_hv_device failed %d\n", __func__,
__LINE__, error);
goto fail;
}
error = ps3_sb_event_receive_port_setup(&dev->sbd, PS3_BINDING_CPU_ANY,
&dev->irq);
if (error) {
dev_err(&dev->sbd.core,
"%s:%u: ps3_sb_event_receive_port_setup failed %d\n",
__func__, __LINE__, error);
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/module.h`, `linux/string_choices.h`, `asm/lv1call.h`, `asm/ps3stor.h`.
- Detected declarations: `function ps3stor_open_hv_device`, `function ps3stor_close_hv_device`, `function ps3stor_probe_access`, `function ps3stor_setup`, `function ps3stor_teardown`, `function ps3stor_read_write_sectors`, `function ps3stor_send_command`, `export ps3stor_setup`, `export ps3stor_teardown`, `export ps3stor_read_write_sectors`.
- Atlas domain: Driver Families / drivers/ps3.
- Implementation status: integration 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.