drivers/platform/x86/toshiba_haps.c
Source file repositories/reference/linux-study-clean/drivers/platform/x86/toshiba_haps.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/x86/toshiba_haps.c- Extension
.c- Size
- 6336 bytes
- Lines
- 284
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- 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/kernel.hlinux/module.hlinux/init.hlinux/types.hlinux/acpi.hlinux/platform_device.h
Detected Declarations
struct toshiba_haps_devfunction toshiba_haps_reset_protectionfunction toshiba_haps_protection_levelfunction protection_level_showfunction protection_level_storefunction reset_protection_storefunction toshiba_haps_notifyfunction toshiba_haps_removefunction toshiba_haps_availablefunction toshiba_haps_probefunction toshiba_haps_suspendfunction toshiba_haps_resume
Annotated Snippet
struct toshiba_haps_dev {
struct acpi_device *acpi_dev;
int protection_level;
};
static struct toshiba_haps_dev *toshiba_haps;
/* HAPS functions */
static int toshiba_haps_reset_protection(acpi_handle handle)
{
acpi_status status;
status = acpi_evaluate_object(handle, "RSSS", NULL, NULL);
if (ACPI_FAILURE(status)) {
pr_err("Unable to reset the HDD protection\n");
return -EIO;
}
return 0;
}
static int toshiba_haps_protection_level(acpi_handle handle, int level)
{
acpi_status status;
status = acpi_execute_simple_method(handle, "PTLV", level);
if (ACPI_FAILURE(status)) {
pr_err("Error while setting the protection level\n");
return -EIO;
}
pr_debug("HDD protection level set to: %d\n", level);
return 0;
}
/* sysfs files */
static ssize_t protection_level_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct toshiba_haps_dev *haps = dev_get_drvdata(dev);
return sprintf(buf, "%i\n", haps->protection_level);
}
static ssize_t protection_level_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct toshiba_haps_dev *haps = dev_get_drvdata(dev);
int level;
int ret;
ret = kstrtoint(buf, 0, &level);
if (ret)
return ret;
/*
* Check for supported levels, which can be:
* 0 - Disabled | 1 - Low | 2 - Medium | 3 - High
*/
if (level < 0 || level > 3)
return -EINVAL;
/* Set the sensor level */
ret = toshiba_haps_protection_level(haps->acpi_dev->handle, level);
if (ret != 0)
return ret;
haps->protection_level = level;
return count;
}
static DEVICE_ATTR_RW(protection_level);
static ssize_t reset_protection_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct toshiba_haps_dev *haps = dev_get_drvdata(dev);
int reset;
int ret;
ret = kstrtoint(buf, 0, &reset);
if (ret)
return ret;
/* The only accepted value is 1 */
if (reset != 1)
return -EINVAL;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/acpi.h`, `linux/platform_device.h`.
- Detected declarations: `struct toshiba_haps_dev`, `function toshiba_haps_reset_protection`, `function toshiba_haps_protection_level`, `function protection_level_show`, `function protection_level_store`, `function reset_protection_store`, `function toshiba_haps_notify`, `function toshiba_haps_remove`, `function toshiba_haps_available`, `function toshiba_haps_probe`.
- Atlas domain: Driver Families / drivers/platform.
- 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.