Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12d32064 authored by Lin Ming's avatar Lin Ming Committed by Len Brown
Browse files

ACPI: fix allowing to add/remove multiple _OSI strings



commit b0ed7a91(ACPICA/ACPI: Add new host interfaces for _OSI suppor)
introduced another regression that only one _OSI string can be added or
removed.

Now multiple _OSI strings can be added or removed, for example

acpi_osi=Linux acpi_osi=FreeBSD acpi_osi="!Windows 2006"

Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent d90aa92c
Loading
Loading
Loading
Loading
+50 −16
Original line number Original line Diff line number Diff line
@@ -110,9 +110,6 @@ struct acpi_ioremap {
static LIST_HEAD(acpi_ioremaps);
static LIST_HEAD(acpi_ioremaps);
static DEFINE_SPINLOCK(acpi_ioremap_lock);
static DEFINE_SPINLOCK(acpi_ioremap_lock);


#define	OSI_STRING_LENGTH_MAX 64	/* arbitrary */
static char osi_setup_string[OSI_STRING_LENGTH_MAX];

static void __init acpi_osi_setup_late(void);
static void __init acpi_osi_setup_late(void);


/*
/*
@@ -1054,16 +1051,47 @@ static int __init acpi_os_name_setup(char *str)


__setup("acpi_os_name=", acpi_os_name_setup);
__setup("acpi_os_name=", acpi_os_name_setup);


#define	OSI_STRING_LENGTH_MAX 64	/* arbitrary */
#define	OSI_STRING_ENTRIES_MAX 16	/* arbitrary */

struct osi_setup_entry {
	char string[OSI_STRING_LENGTH_MAX];
	bool enable;
};

static struct osi_setup_entry __initdata osi_setup_entries[OSI_STRING_ENTRIES_MAX];

void __init acpi_osi_setup(char *str)
void __init acpi_osi_setup(char *str)
{
{
	struct osi_setup_entry *osi;
	bool enable = true;
	int i;

	if (!acpi_gbl_create_osi_method)
	if (!acpi_gbl_create_osi_method)
		return;
		return;


	if (str == NULL || *str == '\0') {
	if (str == NULL || *str == '\0') {
		printk(KERN_INFO PREFIX "_OSI method disabled\n");
		printk(KERN_INFO PREFIX "_OSI method disabled\n");
		acpi_gbl_create_osi_method = FALSE;
		acpi_gbl_create_osi_method = FALSE;
	} else
		return;
		strncpy(osi_setup_string, str, OSI_STRING_LENGTH_MAX);
	}

	if (*str == '!') {
		str++;
		enable = false;
	}

	for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
		osi = &osi_setup_entries[i];
		if (!strcmp(osi->string, str)) {
			osi->enable = enable;
			break;
		} else if (osi->string[0] == '\0') {
			osi->enable = enable;
			strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
			break;
		}
	}
}
}


static void __init set_osi_linux(unsigned int enable)
static void __init set_osi_linux(unsigned int enable)
@@ -1110,22 +1138,28 @@ void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
 */
 */
static void __init acpi_osi_setup_late(void)
static void __init acpi_osi_setup_late(void)
{
{
	char *str = osi_setup_string;
	struct osi_setup_entry *osi;
	char *str;
	int i;
	acpi_status status;
	acpi_status status;


	if (*str == '\0')
	for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
		return;
		osi = &osi_setup_entries[i];
		str = osi->string;


	if (*str == '!') {
		if (*str == '\0')
		status = acpi_remove_interface(++str);
			break;
		if (osi->enable) {
			status = acpi_install_interface(str);


			if (ACPI_SUCCESS(status))
			if (ACPI_SUCCESS(status))
			printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
				printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
		} else {
		} else {
		status = acpi_install_interface(str);
			status = acpi_remove_interface(str);


			if (ACPI_SUCCESS(status))
			if (ACPI_SUCCESS(status))
			printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
				printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
		}
	}
	}
}
}