Exemplo n.º 1
0
static int __init acpi_system_init(void)
{
	struct proc_dir_entry *entry;
	int error = 0;
	char *name;

	ACPI_FUNCTION_TRACE("acpi_system_init");

	if (acpi_disabled)
		return_VALUE(0);

	/* 'info' [R] */
	name = ACPI_SYSTEM_FILE_INFO;
	entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
	if (!entry)
		goto Error;
	else {
		entry->proc_fops = &acpi_system_info_ops;
	}

	/* 'dsdt' [R] */
	name = ACPI_SYSTEM_FILE_DSDT;
	entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
	if (entry)
		entry->proc_fops = &acpi_system_dsdt_ops;
	else
		goto Error;

	/* 'fadt' [R] */
	name = ACPI_SYSTEM_FILE_FADT;
	entry = create_proc_entry(name, S_IRUSR, acpi_root_dir);
	if (entry)
		entry->proc_fops = &acpi_system_fadt_ops;
	else
		goto Error;

      Done:
	return_VALUE(error);

      Error:
	ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
			  "Unable to create '%s' proc fs entry\n", name));

	remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
	remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
	remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);

	error = -EFAULT;
	goto Done;
}
Exemplo n.º 2
0
u32
acpi_hw_get_mode (void)
{

	FUNCTION_TRACE ("Hw_get_mode");


	if (acpi_hw_register_bit_access (ACPI_READ, ACPI_MTX_LOCK, SCI_EN)) {
		return_VALUE (SYS_MODE_ACPI);
	}
	else {
		return_VALUE (SYS_MODE_LEGACY);
	}
}
Exemplo n.º 3
0
acpi_object_type
acpi_ns_get_type (
	struct acpi_namespace_node      *node)
{
	ACPI_FUNCTION_TRACE ("ns_get_type");


	if (!node) {
		ACPI_REPORT_WARNING (("ns_get_type: Null Node input pointer\n"));
		return_VALUE (ACPI_TYPE_ANY);
	}

	return_VALUE ((acpi_object_type) node->type);
}
Exemplo n.º 4
0
static int acpi_memory_device_remove(struct acpi_device *device, int type)
{
	struct acpi_memory_device *mem_device = NULL;

	ACPI_FUNCTION_TRACE("acpi_memory_device_remove");

	if (!device || !acpi_driver_data(device))
		return_VALUE(-EINVAL);

	mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
	kfree(mem_device);

	return_VALUE(0);
}
Exemplo n.º 5
0
static int
acpi_ec_write (
	struct acpi_ec		*ec,
	u8			address,
	u8			data)
{
	int			result = 0;
	acpi_status		status = AE_OK;
	unsigned long		flags = 0;
	u32			glk = 0;

	ACPI_FUNCTION_TRACE("acpi_ec_write");

	if (!ec)
		return_VALUE(-EINVAL);

	if (ec->global_lock) {
		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
		if (ACPI_FAILURE(status))
			return_VALUE(-ENODEV);
	}

	spin_lock_irqsave(&ec->lock, flags);

	acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE, &ec->command_addr);
	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
	if (result)
		goto end;

	acpi_hw_low_level_write(8, address, &ec->data_addr);
	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
	if (result)
		goto end;

	acpi_hw_low_level_write(8, data, &ec->data_addr);
	result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
	if (result)
		goto end;

	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n",
		data, address));

end:
	spin_unlock_irqrestore(&ec->lock, flags);

	if (ec->global_lock)
		acpi_release_global_lock(glk);

	return_VALUE(result);
}
Exemplo n.º 6
0
int
acpi_thermal_init (void)
{
	int			result = 0;

	ACPI_FUNCTION_TRACE("acpi_thermal_init");

	result = acpi_bus_register_driver(&acpi_thermal_driver);
	if (result < 0) {
		return_VALUE(-ENODEV);
	}

	return_VALUE(0);
}
Exemplo n.º 7
0
UINT64
AcpiUtExplicitStrtoul64 (
    char                    *String)
{
    UINT64                  ConvertedInteger = 0;
    UINT32                  Base = 10;          /* Default is decimal */


    ACPI_FUNCTION_TRACE_STR (UtExplicitStrtoul64, String);


    if (!AcpiUtRemoveWhitespace (&String))
    {
        return_VALUE (0);
    }

    /*
     * Only Hex and Decimal are supported, as per the ACPI specification.
     * A "0x" prefix indicates hex; otherwise decimal is assumed.
     */
    if (AcpiUtDetectHexPrefix (&String))
    {
        Base = 16;
    }

    if (!AcpiUtRemoveLeadingZeros (&String))
    {
        return_VALUE (0);
    }

    /*
     * Ignore overflow as per the ACPI specification. This is implemented by
     * ignoring the return status from the conversion functions called below.
     * On overflow, the input string is simply truncated.
     */
    switch (Base)
    {
    case 10:
    default:
        AcpiUtConvertDecimalString (String, &ConvertedInteger);
        break;

    case 16:
        AcpiUtConvertHexString (String, &ConvertedInteger);
        break;
    }

    return_VALUE (ConvertedInteger);
}
Exemplo n.º 8
0
static int is_processor_present(acpi_handle handle)
{
	acpi_status status;
	unsigned long sta = 0;

	ACPI_FUNCTION_TRACE("is_processor_present");

	status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
				  "Processor Device is not present\n"));
		return_VALUE(0);
	}
	return_VALUE(1);
}
Exemplo n.º 9
0
ACPI_OBJECT_TYPE
AcpiNsGetType (
    ACPI_NAMESPACE_NODE     *Node)
{
    ACPI_FUNCTION_TRACE (NsGetType);


    if (!Node)
    {
        ACPI_WARNING ((AE_INFO, "Null Node parameter"));
        return_VALUE (ACPI_TYPE_ANY);
    }

    return_VALUE (Node->Type);
}
Exemplo n.º 10
0
static ssize_t
acpi_system_read_event (
	struct file		*file,
	char			*buffer,
	size_t			count,
	loff_t			*ppos)
{
	int			result = 0;
	struct acpi_bus_event	event;
	static char		str[ACPI_MAX_STRING];
	static int		chars_remaining = 0;
	static char		*ptr;


	ACPI_FUNCTION_TRACE("acpi_system_read_event");

	if (!chars_remaining) {
		memset(&event, 0, sizeof(struct acpi_bus_event));

		if ((file->f_flags & O_NONBLOCK)
		    && (list_empty(&acpi_bus_event_list)))
			return_VALUE(-EAGAIN);

		result = acpi_bus_receive_event(&event);
		if (result) {
			return_VALUE(-EIO);
		}

		chars_remaining = sprintf(str, "%s %s %08x %08x\n", 
			event.device_class?event.device_class:"<unknown>",
			event.bus_id?event.bus_id:"<unknown>", 
			event.type, event.data);
		ptr = str;
	}

	if (chars_remaining < count) {
		count = chars_remaining;
	}

	if (copy_to_user(buffer, ptr, count))
		return_VALUE(-EFAULT);

	*ppos += count;
	chars_remaining -= count;
	ptr += count;

	return_VALUE(count);
}
Exemplo n.º 11
0
static int
acpi_thermal_set_polling (
	struct acpi_thermal	*tz,
	int			seconds)
{
	ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");

	if (!tz)
		return_VALUE(-EINVAL);

	tz->polling_frequency = seconds * 10;	/* Convert value to deci-seconds */

	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency set to %lu seconds\n", tz->polling_frequency));

	return_VALUE(0);
}
Exemplo n.º 12
0
static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
{
	int result;
	u64 start = mem_device->start_addr;
	u64 len = mem_device->end_addr - start + 1;
	unsigned long attr = mem_device->read_write_attribute;

	ACPI_FUNCTION_TRACE("acpi_memory_disable_device");

	/*
	 * Ask the VM to offline this memory range.
	 * Note: Assume that this function returns zero on success
	 */
	result = remove_memory(start, len, attr);
	if (result) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Hot-Remove failed.\n"));
		return_VALUE(result);
	}

	/* Power-off and eject the device */
	result = acpi_memory_powerdown_device(mem_device);
	if (result) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
				  "Device Power Down failed.\n"));
		/* Set the status of the device to invalid */
		mem_device->state = MEMORY_INVALID_STATE;
		return result;
	}

	mem_device->state = MEMORY_POWER_OFF_STATE;
	return result;
}
Exemplo n.º 13
0
static int
acpi_button_read_info (
	char			*page,
	char			**start,
	off_t			off,
	int 			count,
	int 			*eof,
	void			*data)
{
	struct acpi_button	*button = (struct acpi_button *) data;
	char			*p = page;
	int			len = 0;

	ACPI_FUNCTION_TRACE("acpi_button_read_info");

	if (!button || !button->device || (off != 0))
		goto end;

	p += sprintf(p, "type:                    %s\n", 
		acpi_device_name(button->device));

end:
	len = (p - page);
	if (len <= off+count) *eof = 1;
	*start = page + off;
	len -= off;
	if (len>count) len = count;
	if (len<0) len = 0;

	return_VALUE(len);
}
Exemplo n.º 14
0
static int acpi_system_read_info(struct seq_file *seq, void *offset)
{
	ACPI_FUNCTION_TRACE("acpi_system_read_info");

	seq_printf(seq, "version:                 %x\n", ACPI_CA_VERSION);
	return_VALUE(0);
}
Exemplo n.º 15
0
static UINT32 ACPI_SYSTEM_XFACE
AcpiEvSciXruptHandler (
    void                    *Context)
{
    ACPI_GPE_XRUPT_INFO     *GpeXruptList = Context;
    UINT32                  InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;


    ACPI_FUNCTION_TRACE (EvSciXruptHandler);


    /*
     * We are guaranteed by the ACPI CA initialization/shutdown code that
     * if this interrupt handler is installed, ACPI is enabled.
     */

    /*
     * Fixed Events:
     * Check for and dispatch any Fixed Events that have occurred
     */
    InterruptHandled |= AcpiEvFixedEventDetect ();

    /*
     * General Purpose Events:
     * Check for and dispatch any GPEs that have occurred
     */
    InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);

    AcpiSciCount++;
    return_VALUE (InterruptHandled);
}
Exemplo n.º 16
0
static int
acpi_battery_read_alarm (struct seq_file *seq, void *offset)
{
	struct acpi_battery	*battery = (struct acpi_battery *) seq->private;
	char			*units = "?";

	ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");

	if (!battery)
		goto end;

	if (!battery->flags.present) {
		seq_printf(seq, "present:                 no\n");
		goto end;
	}

	/* Battery Units */
	
	units = battery->flags.power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;

	/* Battery Alarm */

	seq_printf(seq, "alarm:                   ");
	if (!battery->alarm)
		seq_printf(seq, "unsupported\n");
	else
		seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);

end:
	return_VALUE(0);
}
Exemplo n.º 17
0
static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
{
	struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
	u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;

	ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");

	/*
	 * We are guaranteed by the ACPI CA initialization/shutdown code that
	 * if this interrupt handler is installed, ACPI is enabled.
	 */

	/*
	 * Fixed Events:
	 * Check for and dispatch any Fixed Events that have occurred
	 */
	interrupt_handled |= acpi_ev_fixed_event_detect();

	/*
	 * General Purpose Events:
	 * Check for and dispatch any GPEs that have occurred
	 */
	interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);

	return_VALUE(interrupt_handled);
}
Exemplo n.º 18
0
static int __init acpi_init (void)
{
	int			result = 0;

	ACPI_FUNCTION_TRACE("acpi_init");

	printk(KERN_INFO PREFIX "Subsystem revision %08x\n",
		ACPI_CA_VERSION);

	if (acpi_disabled) {
		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
		return -ENODEV;
	}

	firmware_register(&acpi_subsys);

	result = acpi_bus_init();

	if (!result) {
#ifdef CONFIG_PM
		if (!PM_IS_ACTIVE())
			pm_active = 1;
		else {
			printk(KERN_INFO PREFIX "APM is already active, exiting\n");
			disable_acpi();
			result = -ENODEV;
		}
#endif
	} else
		disable_acpi();

	return_VALUE(result);
}
Exemplo n.º 19
0
static int
acpi_fan_read_state (
	char			*page,
	char			**start,
	off_t			off,
	int 			count,
	int 			*eof,
	void			*data)
{
	struct acpi_fan		*fan = (struct acpi_fan *) data;
	char			*p = page;
	int			len = 0;
	int			state = 0;

	ACPI_FUNCTION_TRACE("acpi_fan_read_state");

	if (!fan || (off != 0))
		goto end;

	if (acpi_bus_get_power(fan->handle, &state))
		goto end;

	p += sprintf(p, "status:                  %s\n",
		!state?"on":"off");

end:
	len = (p - page);
	if (len <= off+count) *eof = 1;
	*start = page + off;
	len -= off;
	if (len>count) len = count;
	if (len<0) len = 0;

	return_VALUE(len);
}
Exemplo n.º 20
0
static int
acpi_system_remove (
	struct acpi_device	*device,
	int			type)
{
	struct acpi_system	*system = NULL;

	ACPI_FUNCTION_TRACE("acpi_system_remove");

	if (!device || !acpi_driver_data(device))
		return_VALUE(-EINVAL);

	system = (struct acpi_system *) acpi_driver_data(device);

#ifdef CONFIG_PM
	/* Remove the soft-off (S5) handler. */
	if (system->states[ACPI_STATE_S5]) {
		unregister_sysrq_key('o', &sysrq_acpi_poweroff_op);
		pm_power_off = NULL;
	}
#endif

	acpi_system_remove_fs(device);

	kfree(system);

	return 0;
}
Exemplo n.º 21
0
u32
acpi_ns_opens_scope (
	acpi_object_type8       type)
{
	FUNCTION_TRACE_U32 ("Ns_opens_scope", type);


	if (!acpi_ut_valid_object_type (type)) {
		/* type code out of range  */

		REPORT_WARNING (("Ns_opens_scope: Invalid Object Type\n"));
		return_VALUE (NSP_NORMAL);
	}

	return_VALUE (((u32) acpi_gbl_ns_properties[type]) & NSP_NEWSCOPE);
}
Exemplo n.º 22
0
u32
acpi_ns_local (
	acpi_object_type8       type)
{
	FUNCTION_TRACE ("Ns_local");


	if (!acpi_ut_valid_object_type (type)) {
		/* Type code out of range  */

		REPORT_WARNING (("Ns_local: Invalid Object Type\n"));
		return_VALUE (NSP_NORMAL);
	}

	return_VALUE ((u32) acpi_gbl_ns_properties[type] & NSP_LOCAL);
}
Exemplo n.º 23
0
static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
{
	struct acpi_processor *pr = (struct acpi_processor *)seq->private;

	ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");

	if (!pr)
		goto end;

	seq_printf(seq, "processor id:            %d\n"
		   "acpi id:                 %d\n"
		   "bus mastering control:   %s\n"
		   "power management:        %s\n"
		   "throttling control:      %s\n"
		   "limit interface:         %s\n",
		   pr->id,
		   pr->acpi_id,
		   pr->flags.bm_control ? "yes" : "no",
		   pr->flags.power ? "yes" : "no",
		   pr->flags.throttling ? "yes" : "no",
		   pr->flags.limit ? "yes" : "no");

      end:
	return_VALUE(0);
}
Exemplo n.º 24
0
int acpi_processor_set_pdc(struct acpi_processor *pr,
			   struct acpi_object_list *pdc_in)
{
	acpi_status status = AE_OK;
	u32 arg0_buf[3];
	union acpi_object arg0 = { ACPI_TYPE_BUFFER };
	struct acpi_object_list no_object = { 1, &arg0 };
	struct acpi_object_list *pdc;

	ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");

	arg0.buffer.length = 12;
	arg0.buffer.pointer = (u8 *) arg0_buf;
	arg0_buf[0] = ACPI_PDC_REVISION_ID;
	arg0_buf[1] = 0;
	arg0_buf[2] = 0;

	pdc = (pdc_in) ? pdc_in : &no_object;

	status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);

	if ((ACPI_FAILURE(status)) && (pdc_in))
		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
				  "Error evaluating _PDC, using legacy perf. control...\n"));

	return_VALUE(status);
}
Exemplo n.º 25
0
static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
{
	struct acpi_processor *pr = (struct acpi_processor *)seq->private;
	int i;

	ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");

	if (!pr)
		goto end;

	if (!pr->performance) {
		seq_puts(seq, "<not supported>\n");
		goto end;
	}

	seq_printf(seq, "state count:             %d\n"
		   "active state:            P%d\n",
		   pr->performance->state_count, pr->performance->state);

	seq_puts(seq, "states:\n");
	for (i = 0; i < pr->performance->state_count; i++)
		seq_printf(seq,
			   "   %cP%d:                  %d MHz, %d mW, %d uS\n",
			   (i == pr->performance->state ? '*' : ' '), i,
			   (u32) pr->performance->states[i].core_frequency,
			   (u32) pr->performance->states[i].power,
			   (u32) pr->performance->states[i].transition_latency);

      end:
	return_VALUE(0);
}
Exemplo n.º 26
0
u32
acpi_ns_opens_scope (
	acpi_object_type                type)
{
	ACPI_FUNCTION_TRACE_STR ("ns_opens_scope", acpi_ut_get_type_name (type));


	if (!acpi_ut_valid_object_type (type)) {
		/* type code out of range  */

		ACPI_REPORT_WARNING (("ns_opens_scope: Invalid Object Type %X\n", type));
		return_VALUE (ACPI_NS_NORMAL);
	}

	return_VALUE (((u32) acpi_gbl_ns_properties[type]) & ACPI_NS_NEWSCOPE);
}
Exemplo n.º 27
0
static int
acpi_ec_query (
	struct acpi_ec		*ec,
	u32			*data)
{
	int			result = 0;
	acpi_status		status = AE_OK;
	unsigned long		flags = 0;
	u32			glk = 0;

	ACPI_FUNCTION_TRACE("acpi_ec_query");

	if (!ec || !data)
		return_VALUE(-EINVAL);

	*data = 0;

	if (ec->global_lock) {
		status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
		if (ACPI_FAILURE(status))
			return_VALUE(-ENODEV);
	}

	/*
	 * Query the EC to find out which _Qxx method we need to evaluate.
	 * Note that successful completion of the query causes the ACPI_EC_SCI
	 * bit to be cleared (and thus clearing the interrupt source).
	 */
	spin_lock_irqsave(&ec->lock, flags);

	acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY, &ec->command_addr);
	result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
	if (result)
		goto end;
	
	acpi_hw_low_level_read(8, data, &ec->data_addr);
	if (!*data)
		result = -ENODATA;

end:
	spin_unlock_irqrestore(&ec->lock, flags);

	if (ec->global_lock)
		acpi_release_global_lock(glk);

	return_VALUE(result);
}
Exemplo n.º 28
0
static int
acpi_button_attach(device_t dev)
{
    struct acpi_prw_data	prw;
    struct acpi_button_softc	*sc;
    ACPI_STATUS			status;
    int event;

    ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);

    sc = device_get_softc(dev);
    sc->button_dev = dev;
    sc->button_handle = acpi_get_handle(dev);
    event = (sc->button_type == ACPI_SLEEP_BUTTON) ?
	    ACPI_EVENT_SLEEP_BUTTON : ACPI_EVENT_POWER_BUTTON;

    /* 
     * Install the new handler.  We could remove any fixed handlers added
     * from the FADT once we have a duplicate from the AML but some systems
     * only return events on one or the other so we have to keep both.
     */
    if (sc->fixed) {
	AcpiClearEvent(event);
	status = AcpiInstallFixedEventHandler(event,
			acpi_button_fixed_handler, sc);
    } else {
	/*
	 * If a system does not get lid events, it may make sense to change
	 * the type to ACPI_ALL_NOTIFY.  Some systems generate both a wake
	 * and runtime notify in that case though.
	 */
	status = AcpiInstallNotifyHandler(sc->button_handle,
			ACPI_DEVICE_NOTIFY, acpi_button_notify_handler, sc);
    }
    if (ACPI_FAILURE(status)) {
	device_printf(sc->button_dev, "couldn't install notify handler - %s\n",
		      AcpiFormatException(status));
	return_VALUE (ENXIO);
    }

    /* Enable the GPE for wake/runtime */
    acpi_wake_set_enable(dev, 1);
    if (acpi_parse_prw(sc->button_handle, &prw) == 0)
	AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit);
    
    return_VALUE (0);
}
Exemplo n.º 29
0
static int
acpi_memory_get_device(acpi_handle handle,
		       struct acpi_memory_device **mem_device)
{
	acpi_status status;
	acpi_handle phandle;
	struct acpi_device *device = NULL;
	struct acpi_device *pdevice = NULL;

	ACPI_FUNCTION_TRACE("acpi_memory_get_device");

	if (!acpi_bus_get_device(handle, &device) && device)
		goto end;

	status = acpi_get_parent(handle, &phandle);
	if (ACPI_FAILURE(status)) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n"));
		return_VALUE(-EINVAL);
	}

	/* Get the parent device */
	status = acpi_bus_get_device(phandle, &pdevice);
	if (ACPI_FAILURE(status)) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
				  "Error in acpi_bus_get_device\n"));
		return_VALUE(-EINVAL);
	}

	/*
	 * Now add the notified device.  This creates the acpi_device
	 * and invokes .add function
	 */
	status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
	if (ACPI_FAILURE(status)) {
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n"));
		return_VALUE(-EINVAL);
	}

      end:
	*mem_device = acpi_driver_data(device);
	if (!(*mem_device)) {
		printk(KERN_ERR "\n driver data not found");
		return_VALUE(-ENODEV);
	}

	return_VALUE(0);
}
Exemplo n.º 30
0
int acpi_bus_get_power(acpi_handle handle, int *state)
{
    int result = 0;
    acpi_status status = 0;
    struct acpi_device *device = NULL;
    unsigned long psc = 0;

    ACPI_FUNCTION_TRACE("acpi_bus_get_power");

    result = acpi_bus_get_device(handle, &device);
    if (result)
        return_VALUE(result);

    *state = ACPI_STATE_UNKNOWN;

    if (!device->flags.power_manageable) {
        /* TBD: Non-recursive algorithm for walking up hierarchy */
        if (device->parent)
            *state = device->parent->power.state;
        else
            *state = ACPI_STATE_D0;
    } else {
        /*
         * Get the device's power state either directly (via _PSC) or
         * indirectly (via power resources).
         */
        if (device->power.flags.explicit_get) {
            status = acpi_evaluate_integer(device->handle, "_PSC",
                                           NULL, &psc);
            if (ACPI_FAILURE(status))
                return_VALUE(-ENODEV);
            device->power.state = (int)psc;
        } else if (device->power.flags.power_resources) {
            result = acpi_power_get_inferred_state(device);
            if (result)
                return_VALUE(result);
        }

        *state = device->power.state;
    }

    ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
                      device->pnp.bus_id, device->power.state));

    return_VALUE(0);
}