drivers/platform/x86/hp/hp_accel.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/hp/hp_accel.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/hp/hp_accel.c
Extension
.c
Size
11902 bytes
Lines
390
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct delayed_led_classdev {
	struct led_classdev led_classdev;
	struct work_struct work;
	enum led_brightness new_brightness;

	unsigned int led;		/* For driver */
	void (*set_brightness)(struct delayed_led_classdev *data, enum led_brightness value);
};

static inline void delayed_set_status_worker(struct work_struct *work)
{
	struct delayed_led_classdev *data =
			container_of(work, struct delayed_led_classdev, work);

	data->set_brightness(data, data->new_brightness);
}

static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
			      enum led_brightness brightness)
{
	struct delayed_led_classdev *data = container_of(led_cdev,
			     struct delayed_led_classdev, led_classdev);
	data->new_brightness = brightness;
	schedule_work(&data->work);
}

/* HP-specific accelerometer driver ------------------------------------ */

/* e0 25, e0 26, e0 27, e0 28 are scan codes that the accelerometer with acpi id
 * HPQ6000 sends through the keyboard bus */
#define ACCEL_1 0x25
#define ACCEL_2 0x26
#define ACCEL_3 0x27
#define ACCEL_4 0x28

/* For automatic insertion of the module */
static const struct acpi_device_id lis3lv02d_device_ids[] = {
	{"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
	{"HPQ6000", 0}, /* HP Mobile Data Protection System PNP */
	{"HPQ6007", 0}, /* HP Mobile Data Protection System PNP */
	{"", 0},
};
MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);

/**
 * lis3lv02d_acpi_init - initialize the device for ACPI
 * @lis3: pointer to the device struct
 *
 * Returns 0 on success.
 */
static int lis3lv02d_acpi_init(struct lis3lv02d *lis3)
{
	return 0;
}

/**
 * lis3lv02d_acpi_read - ACPI ALRD method: read a register
 * @lis3: pointer to the device struct
 * @reg:    the register to read
 * @ret:    result of the operation
 *
 * Returns 0 on success.
 */
static int lis3lv02d_acpi_read(struct lis3lv02d *lis3, int reg, u8 *ret)
{
	struct acpi_device *dev = lis3->bus_priv;
	union acpi_object arg0 = { ACPI_TYPE_INTEGER };
	struct acpi_object_list args = { 1, &arg0 };
	unsigned long long lret;
	acpi_status status;

	arg0.integer.value = reg;

	status = acpi_evaluate_integer(dev->handle, "ALRD", &args, &lret);
	if (ACPI_FAILURE(status))
		return -EINVAL;
	*ret = lret;
	return 0;
}

/**
 * lis3lv02d_acpi_write - ACPI ALWR method: write to a register
 * @lis3: pointer to the device struct
 * @reg:    the register to write to
 * @val:    the value to write
 *
 * Returns 0 on success.
 */
static int lis3lv02d_acpi_write(struct lis3lv02d *lis3, int reg, u8 val)
{

Annotation

Implementation Notes