Skip to contentSkip to conversation

drivers/firmware: const-ify DMI API and internals

PATCH In review Jeff Garzik 7 participants 10 messages Sep 1, 2007 – Sep 11, 2007

Subsystems (15)
USB ACPI Framebuffer layer libata +11 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/firmware: const-ify DMI API and internals

commit 457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

Author: Jeff Garzik <[email protected]>
Date:   Sat Sep 1 10:16:45 2007 -0400

drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const, since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should, whenever possible, be marked const to ensure we never ever write to that data area.

3) const-ify DMI API, to enable marking tables const where possible in low-level drivers.

And if we're really lucky, this might enable some additional optimizations on the part of the compiler.

The bulk of the changes are #2 and #3, which are interrelated. #1 could have been a separate patch, but it was so small compared to the others, it was easier to roll it into this changeset.

 arch/i386/kernel/apm.c                      |   18 ++++----
 arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c |    4 -
 arch/i386/kernel/reboot.c                   |    2 
 arch/i386/mach-generic/bigsmp.c             |    4 -
 arch/i386/pci/common.c                      |    4 -
 arch/i386/pci/irq.c                         |    4 -
 drivers/acpi/osl.c                          |    2 
 drivers/acpi/processor_idle.c               |    2 
 drivers/acpi/sleep/main.c                   |    2 
 drivers/acpi/thermal.c                      |    8 +--
 drivers/ata/ata_piix.c                      |    4 -
 drivers/ata/pata_ali.c                      |    2 
 drivers/ata/pata_cs5530.c                   |    2 
 drivers/ata/pata_via.c                      |    2 
 drivers/char/i8k.c                          |    4 -
 drivers/char/ipmi/ipmi_si_intf.c            |    9 ++--
 drivers/firmware/dmi_scan.c                 |   57 +++++++++++++++-------------
 drivers/hwmon/abituguru.c                   |    2 
 drivers/hwmon/applesmc.c                    |    2 
 drivers/hwmon/hdaps.c                       |    4 -
 drivers/ide/pci/alim15x3.c                  |    2 
 drivers/ide/pci/via82cxxx.c                 |    2 
 drivers/input/misc/wistron_btns.c           |    2 
 drivers/input/mouse/lifebook.c              |    6 +-
 drivers/input/mouse/synaptics.c             |    2 
 drivers/misc/msi-laptop.c                   |    2 
 drivers/misc/sony-laptop.c                  |    4 -
 drivers/misc/thinkpad_acpi.c                |    2 
 drivers/pnp/pnpbios/core.c                  |    2 
 drivers/usb/host/uhci-hcd.c                 |    2 
 drivers/video/imacfb.c                      |    2 
 include/linux/dmi.h                         |   22 +++++-----
 32 files changed, 97 insertions(+), 91 deletions(-)

457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

arch/i386/kernel/apm.c +9 -9
index f02a8ac..32f2365 100644
@@ -1869,7 +1869,7 @@ static struct miscdevice apm_device = {
 
 
 /* Simple "print if true" callback */
-static int __init print_if_true(struct dmi_system_id *d)
+static int __init print_if_true(const struct dmi_system_id *d)
 {
 	printk("%s\n", d->ident);
 	return 0;
@@ -1879,14 +1879,14 @@ static int __init print_if_true(struct dmi_system_id *d)
  * Some Bioses enable the PS/2 mouse (touchpad) at resume, even if it was
  * disabled before the suspend. Linux used to get terribly confused by that.
  */
-static int __init broken_ps2_resume(struct dmi_system_id *d)
+static int __init broken_ps2_resume(const struct dmi_system_id *d)
 {
 	printk(KERN_INFO "%s machine detected. Mousepad Resume Bug workaround hopefully not needed.\n", d->ident);
 	return 0;
 }
 
 /* Some bioses have a broken protected mode poweroff and need to use realmode */
-static int __init set_realmode_power_off(struct dmi_system_id *d)
+static int __init set_realmode_power_off(const struct dmi_system_id *d)
 {
 	if (apm_info.realmode_power_off = 0) {
 		apm_info.realmode_power_off = 1;
@@ -1896,7 +1896,7 @@ static int __init set_realmode_power_off(struct dmi_system_id *d)
 }
 
 /* Some laptops require interrupts to be enabled during APM calls */
-static int __init set_apm_ints(struct dmi_system_id *d)
+static int __init set_apm_ints(const struct dmi_system_id *d)
 {
 	if (apm_info.allow_ints = 0) {
 		apm_info.allow_ints = 1;
@@ -1906,7 +1906,7 @@ static int __init set_apm_ints(struct dmi_system_id *d)
 }
 
 /* Some APM bioses corrupt memory or just plain do not work */
-static int __init apm_is_horked(struct dmi_system_id *d)
+static int __init apm_is_horked(const struct dmi_system_id *d)
 {
 	if (apm_info.disabled = 0) {
 		apm_info.disabled = 1;
@@ -1915,7 +1915,7 @@ static int __init apm_is_horked(struct dmi_system_id *d)
 	return 0;
 }
 
-static int __init apm_is_horked_d850md(struct dmi_system_id *d)
+static int __init apm_is_horked_d850md(const struct dmi_system_id *d)
 {
 	if (apm_info.disabled = 0) {
 		apm_info.disabled = 1;
@@ -1927,7 +1927,7 @@ static int __init apm_is_horked_d850md(struct dmi_system_id *d)
 }
 
 /* Some APM bioses hang on APM idle calls */
-static int __init apm_likes_to_melt(struct dmi_system_id *d)
+static int __init apm_likes_to_melt(const struct dmi_system_id *d)
 {
 	if (apm_info.forbid_idle = 0) {
 		apm_info.forbid_idle = 1;
@@ -1951,7 +1951,7 @@ static int __init apm_likes_to_melt(struct dmi_system_id *d)
  *	Phoenix A04  08/24/2000 is known bad (Dell Inspiron 5000e)
  *	Phoenix A07  09/29/2000 is known good (Dell Inspiron 5000)
  */
-static int __init broken_apm_power(struct dmi_system_id *d)
+static int __init broken_apm_power(const struct dmi_system_id *d)
 {
 	apm_info.get_power_status_broken = 1;
 	printk(KERN_WARNING "BIOS strings suggest APM bugs, disabling power status reporting.\n");
@@ -1962,7 +1962,7 @@ static int __init broken_apm_power(struct dmi_system_id *d)
  * This bios swaps the APM minute reporting bytes over (Many sony laptops
  * have this problem).
  */
-static int __init swab_apm_power_in_minutes(struct dmi_system_id *d)
+static int __init swab_apm_power_in_minutes(const struct dmi_system_id *d)
 {
 	apm_info.get_power_status_swabinminutes = 1;
 	printk(KERN_WARNING "BIOS strings suggest APM reports battery life in minutes and wrong byte order.\n");
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +2 -2
index 705e13a..b6434a7 100644
@@ -533,13 +533,13 @@ static int __init acpi_cpufreq_early_init(void)
  */
 static int bios_with_sw_any_bug;
 
-static int sw_any_bug_found(struct dmi_system_id *d)
+static int sw_any_bug_found(const struct dmi_system_id *d)
 {
 	bios_with_sw_any_bug = 1;
 	return 0;
 }
 
-static struct dmi_system_id sw_any_bug_dmi_table[] = {
+static const struct dmi_system_id sw_any_bug_dmi_table[] = {
 	{
 		.callback = sw_any_bug_found,
 		.ident = "Supermicro Server X6DLP",
arch/i386/kernel/reboot.c +1 -1
index 0d79624..b37ed22 100644
@@ -79,7 +79,7 @@ __setup("reboot=", reboot_setup);
 /*
  * Some machines require the "reboot=b"  commandline option, this quirk makes that automatic.
  */
-static int __init set_bios_reboot(struct dmi_system_id *d)
+static int __init set_bios_reboot(const struct dmi_system_id *d)
 {
 	if (!reboot_thru_bios) {
 		reboot_thru_bios = 1;
arch/i386/mach-generic/bigsmp.c +2 -2
index 58a477b..292a225 100644
@@ -21,7 +21,7 @@
 
 static int dmi_bigsmp; /* can be set by dmi scanners */
 
-static int hp_ht_bigsmp(struct dmi_system_id *d)
+static int hp_ht_bigsmp(const struct dmi_system_id *d)
 {
 #ifdef CONFIG_X86_GENERICARCH
 	printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
@@ -31,7 +31,7 @@ static int hp_ht_bigsmp(struct dmi_system_id *d)
 }
 
 
-static struct dmi_system_id bigsmp_dmi_table[] = {
+static const struct dmi_system_id bigsmp_dmi_table[] = {
 	{ hp_ht_bigsmp, "HP ProLiant DL760 G2", {
 		DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
 		DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
arch/i386/pci/common.c +2 -2
index ebc6f3c..07d5223 100644
@@ -123,7 +123,7 @@ void __devinit  pcibios_fixup_bus(struct pci_bus *b)
  * on the kernel command line (which was parsed earlier).
  */
 
-static int __devinit set_bf_sort(struct dmi_system_id *d)
+static int __devinit set_bf_sort(const struct dmi_system_id *d)
 {
 	if (pci_bf_sort = pci_bf_sort_default) {
 		pci_bf_sort = pci_dmi_bf;
@@ -136,7 +136,7 @@ static int __devinit set_bf_sort(struct dmi_system_id *d)
  * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
  */
 #ifdef __i386__
-static int __devinit assign_all_busses(struct dmi_system_id *d)
+static int __devinit assign_all_busses(const struct dmi_system_id *d)
 {
 	pci_probe |= PCI_ASSIGN_ALL_BUSSES;
 	printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
arch/i386/pci/irq.c +2 -2
index 665db06..3eee103 100644
@@ -1009,7 +1009,7 @@ static void __init pcibios_fixup_irqs(void)
  * Work around broken HP Pavilion Notebooks which assign USB to
  * IRQ 9 even though it is actually wired to IRQ 11
  */
-static int __init fix_broken_hp_bios_irq9(struct dmi_system_id *d)
+static int __init fix_broken_hp_bios_irq9(const struct dmi_system_id *d)
 {
 	if (!broken_hp_bios_irq9) {
 		broken_hp_bios_irq9 = 1;
@@ -1022,7 +1022,7 @@ static int __init fix_broken_hp_bios_irq9(struct dmi_system_id *d)
  * Work around broken Acer TravelMate 360 Notebooks which assign
  * Cardbus to IRQ 11 even though it is actually wired to IRQ 10
  */
-static int __init fix_acer_tm360_irqrouting(struct dmi_system_id *d)
+static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
 {
 	if (!acer_tm360_irqrouting) {
 		acer_tm360_irqrouting = 1;
drivers/acpi/osl.c +1 -1
index 12c09fa..352cf81 100644
@@ -1214,7 +1214,7 @@ acpi_os_validate_address (
 }
 
 #ifdef CONFIG_DMI
-static int dmi_osi_linux(struct dmi_system_id *d)
+static int dmi_osi_linux(const struct dmi_system_id *d)
 {
 	printk(KERN_NOTICE "%s detected: enabling _OSI(Linux)\n", d->ident);
 	enable_osi_linux(1);
drivers/acpi/processor_idle.c +1 -1
index d9b8af7..fde7b22 100644
@@ -92,7 +92,7 @@ module_param(bm_history, uint, 0644);
  *
  * To skip this limit, boot/load with a large max_cstate limit.
  */
-static int set_max_cstate(struct dmi_system_id *id)
+static int set_max_cstate(const struct dmi_system_id *id)
 {
 	if (max_cstate > ACPI_PROCESSOR_MAX_POWER)
 		return 0;
drivers/acpi/sleep/main.c +1 -1
index c52ade8..68825d9 100644
@@ -189,7 +189,7 @@ static struct pm_ops acpi_pm_ops = {
  * Toshiba fails to preserve interrupts over S1, reinitialization
  * of 8259 is needed after S1 resume.
  */
-static int __init init_ints_after_s1(struct dmi_system_id *d)
+static int __init init_ints_after_s1(const struct dmi_system_id *d)
 {
 	printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident);
 	init_8259A_after_S1 = 1;
drivers/acpi/thermal.c +4 -4
index bc6d586..ad898e1 100644
@@ -1360,7 +1360,7 @@ static int acpi_thermal_resume(struct acpi_device *device)
 }
 
 #ifdef CONFIG_DMI
-static int thermal_act(struct dmi_system_id *d) {
+static int thermal_act(const struct dmi_system_id *d) {
 
 	if (act = 0) {
 		printk(KERN_NOTICE "ACPI: %s detected: "
@@ -1369,14 +1369,14 @@ static int thermal_act(struct dmi_system_id *d) {
 	}
 	return 0;
 }
-static int thermal_nocrt(struct dmi_system_id *d) {
+static int thermal_nocrt(const struct dmi_system_id *d) {
 
 	printk(KERN_NOTICE "ACPI: %s detected: "
 		"disabling all critical thermal trip point actions.\n", d->ident);
 	nocrt = 1;
 	return 0;
 }
-static int thermal_tzp(struct dmi_system_id *d) {
+static int thermal_tzp(const struct dmi_system_id *d) {
 
 	if (tzp = 0) {
 		printk(KERN_NOTICE "ACPI: %s detected: "
@@ -1385,7 +1385,7 @@ static int thermal_tzp(struct dmi_system_id *d) {
 	}
 	return 0;
 }
-static int thermal_psv(struct dmi_system_id *d) {
+static int thermal_psv(const struct dmi_system_id *d) {
 
 	if (psv = 0) {
 		printk(KERN_NOTICE "ACPI: %s detected: "
drivers/ata/ata_piix.c +2 -2
index e40c94f..a0861e7 100644
@@ -919,7 +919,7 @@ static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev)
 #ifdef CONFIG_PM
 static int piix_broken_suspend(void)
 {
-	static struct dmi_system_id sysids[] = {
+	static const struct dmi_system_id sysids[] = {
 		{
 			.ident = "TECRA M5",
 			.matches = {
@@ -1175,7 +1175,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
 
 static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
 {
-	static struct dmi_system_id sysids[] = {
+	static const struct dmi_system_id sysids[] = {
 		{
 			/* Clevo M570U sets IOCFG bit 18 if the cdrom
 			 * isn't used to boot the system which
drivers/ata/pata_ali.c +1 -1
index 94e5edc..e3ab690 100644
@@ -40,7 +40,7 @@
  *	Cable special cases
  */
 
-static struct dmi_system_id cable_dmi_table[] = {
+static const struct dmi_system_id cable_dmi_table[] = {
 	{
 		.ident = "HP Pavilion N5430",
 		.matches = {
drivers/ata/pata_cs5530.c +1 -1
index c6066aa..eaaea84 100644
@@ -214,7 +214,7 @@ static struct ata_port_operations cs5530_port_ops = {
 	.port_start	= ata_port_start,
 };
 
-static struct dmi_system_id palmax_dmi_table[] = {
+static const struct dmi_system_id palmax_dmi_table[] = {
 	{
 		.ident = "Palmax PD1100",
 		.matches = {
drivers/ata/pata_via.c +1 -1
index ea18e33..8e7cd0b 100644
@@ -128,7 +128,7 @@ static const struct via_isa_bridge {
  *	Cable special cases
  */
 
-static struct dmi_system_id cable_dmi_table[] = {
+static const struct dmi_system_id cable_dmi_table[] = {
 	{
 		.ident = "Acer Ferrari 3400",
 		.matches = {
drivers/char/i8k.c +2 -2
index 0289705..cd40641 100644
@@ -98,9 +98,9 @@ struct smm_regs {
 	unsigned int edi __attribute__ ((packed));
 };
 
-static inline char *i8k_get_dmi_data(int field)
+static inline const char *i8k_get_dmi_data(int field)
 {
-	char *dmi_data = dmi_get_system_info(field);
+	const char *dmi_data = dmi_get_system_info(field);
 
 	return dmi_data && *dmi_data ? dmi_data : "?";
 }
drivers/char/ipmi/ipmi_si_intf.c +5 -4
index 9b07f78..046f456 100644
@@ -1965,10 +1965,10 @@ struct dmi_ipmi_data
 	u8              slave_addr;
 };
 
-static int __devinit decode_dmi(struct dmi_header *dm,
+static int __devinit decode_dmi(const struct dmi_header *dm,
 				struct dmi_ipmi_data *dmi)
 {
-	u8              *data = (u8 *)dm;
+	const u8	*data = (const u8 *)dm;
 	unsigned long  	base_addr;
 	u8		reg_spacing;
 	u8              len = dm->length;
@@ -2091,13 +2091,14 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
 
 static void __devinit dmi_find_bmc(void)
 {
-	struct dmi_device    *dev = NULL;
+	const struct dmi_device *dev = NULL;
 	struct dmi_ipmi_data data;
 	int                  rv;
 
 	while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) {
 		memset(&data, 0, sizeof(data));
-		rv = decode_dmi((struct dmi_header *) dev->device_data, &data);
+		rv = decode_dmi((const struct dmi_header *) dev->device_data,
+				&data);
 		if (!rv)
 			try_init_dmi(&data);
 	}
drivers/firmware/dmi_scan.c +30 -26

174 lines not on this page · raw message

drivers/hwmon/abituguru.c +1 -1
index d575ee9..2317f4b 100644
@@ -1449,7 +1449,7 @@ static int __init abituguru_init(void)
 	struct resource res = { .flags = IORESOURCE_IO };
 
 #ifdef CONFIG_DMI
-	char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
+	const char *board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
 
 	/* safety check, refuse to load on non Abit motherboards */
 	if (!force && (!board_vendor ||
drivers/hwmon/applesmc.c +1 -1
index 941729a..56213b7 100644
@@ -1071,7 +1071,7 @@ static const struct attribute_group temperature_attributes_group  /*
  * applesmc_dmi_match - found a match.  return one, short-circuiting the hunt.
  */
-static int applesmc_dmi_match(struct dmi_system_id *id)
+static int applesmc_dmi_match(const struct dmi_system_id *id)
 {
 	int i = 0;
 	struct dmi_match_data* dmi_data = id->driver_data;
drivers/hwmon/hdaps.c +2 -2
index e0cf5e6..a7c6d40 100644
@@ -480,14 +480,14 @@ static struct attribute_group hdaps_attribute_group = {
 /* Module stuff */
 
 /* hdaps_dmi_match - found a match.  return one, short-circuiting the hunt. */
-static int __init hdaps_dmi_match(struct dmi_system_id *id)
+static int __init hdaps_dmi_match(const struct dmi_system_id *id)
 {
 	printk(KERN_INFO "hdaps: %s detected.\n", id->ident);
 	return 1;
 }
 
 /* hdaps_dmi_match_invert - found an inverted match. */
-static int __init hdaps_dmi_match_invert(struct dmi_system_id *id)
+static int __init hdaps_dmi_match_invert(const struct dmi_system_id *id)
 {
 	hdaps_invert = 1;
 	printk(KERN_INFO "hdaps: inverting axis readings.\n");
drivers/ide/pci/alim15x3.c +1 -1
index 025689d..46d17b4 100644
@@ -588,7 +588,7 @@ out:
  *	Cable special cases
  */
 
-static struct dmi_system_id cable_dmi_table[] = {
+static const struct dmi_system_id cable_dmi_table[] = {
 	{
 		.ident = "HP Pavilion N5430",
 		.matches = {
drivers/ide/pci/via82cxxx.c +1 -1
index 581316f..92d4ea6 100644
@@ -418,7 +418,7 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
  *	Cable special cases
  */
 
-static struct dmi_system_id cable_dmi_table[] = {
+static const struct dmi_system_id cable_dmi_table[] = {
 	{
 		.ident = "Acer Ferrari 3400",
 		.matches = {
drivers/input/misc/wistron_btns.c +1 -1
index 60121f1..b438d99 100644
@@ -247,7 +247,7 @@ static int have_wifi;
 static int have_bluetooth;
 static int have_leds;
 
-static int __init dmi_matched(struct dmi_system_id *dmi)
+static int __init dmi_matched(const struct dmi_system_id *dmi)
 {
 	const struct key_entry *key;
 
drivers/input/mouse/lifebook.c +3 -3
index 91109b4..608674d 100644
@@ -27,7 +27,7 @@ struct lifebook_data {
 
 static const char *desired_serio_phys;
 
-static int lifebook_set_serio_phys(struct dmi_system_id *d)
+static int lifebook_set_serio_phys(const struct dmi_system_id *d)
 {
 	desired_serio_phys = d->driver_data;
 	return 0;
@@ -35,13 +35,13 @@ static int lifebook_set_serio_phys(struct dmi_system_id *d)
 
 static unsigned char lifebook_use_6byte_proto;
 
-static int lifebook_set_6byte_proto(struct dmi_system_id *d)
+static int lifebook_set_6byte_proto(const struct dmi_system_id *d)
 {
 	lifebook_use_6byte_proto = 1;
 	return 0;
 }
 
-static struct dmi_system_id lifebook_dmi_table[] = {
+static const struct dmi_system_id lifebook_dmi_table[] = {
 	{
 		.ident = "FLORA-ie 55mi",
 		.matches = {
drivers/input/mouse/synaptics.c +1 -1
index 666ad3a..d349c4a 100644
@@ -602,7 +602,7 @@ static int synaptics_reconnect(struct psmouse *psmouse)
 
 #if defined(__i386__)
 #include <linux/dmi.h>
-static struct dmi_system_id toshiba_dmi_table[] = {
+static const struct dmi_system_id toshiba_dmi_table[] = {
 	{
 		.ident = "Toshiba Satellite",
 		.matches = {
drivers/misc/msi-laptop.c +1 -1
index 932a415..b5365e3 100644
@@ -283,7 +283,7 @@ static struct platform_device *msipf_device;
 
 /* Initialization */
 
-static int dmi_check_cb(struct dmi_system_id *id)
+static int dmi_check_cb(const struct dmi_system_id *id)
 {
         printk("msi-laptop: Identified laptop model '%s'.\n", id->ident);
         return 0;
drivers/misc/sony-laptop.c +2 -2
index d38ddce..e73a71f 100644
@@ -807,7 +807,7 @@ static struct sony_nc_event *sony_nc_events;
 /* Vaio C* --maybe also FE*, N* and AR* ?-- special init sequence
  * for Fn keys
  */
-static int sony_nc_C_enable(struct dmi_system_id *id)
+static int sony_nc_C_enable(const struct dmi_system_id *id)
 {
 	int result = 0;
 
@@ -845,7 +845,7 @@ static struct sony_nc_event sony_C_events[] = {
 };
 
 /* SNC-only model map */
-static struct dmi_system_id sony_nc_ids[] = {
+static const struct dmi_system_id sony_nc_ids[] = {
 		{
 			.ident = "Sony Vaio FE Series",
 			.callback = sony_nc_C_enable,
drivers/misc/thinkpad_acpi.c +1 -1
index bb8956d..6baa995 100644
@@ -4425,7 +4425,7 @@ static void ibm_exit(struct ibm_struct *ibm)
 
 static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp)
 {
-	struct dmi_device *dev = NULL;
+	const struct dmi_device *dev = NULL;
 	char ec_fw_string[18];
 
 	if (!tp)
drivers/pnp/pnpbios/core.c +1 -1
index 0691f47..4e9fd37 100644
@@ -500,7 +500,7 @@ static int __init pnpbios_probe_system(void)
 	return 0;
 }
 
-static int __init exploding_pnp_bios(struct dmi_system_id *d)
+static int __init exploding_pnp_bios(const struct dmi_system_id *d)
 {
 	printk(KERN_WARNING "%s detected. Disabling PnPBIOS\n", d->ident);
 	return 0;
drivers/usb/host/uhci-hcd.c +1 -1
index 805e5fc..4db17f7 100644
@@ -237,7 +237,7 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
 static int remote_wakeup_is_broken(struct uhci_hcd *uhci)
 {
 	int port;
-	char *sys_info;
+	const char *sys_info;
 	static char bad_Asus_board[] = "A7V8X";
 
 	/* One of Asus's motherboards has a bug which causes it to
drivers/video/imacfb.c +1 -1
index 18ea4a5..6455fd2 100644
@@ -58,7 +58,7 @@ static int model		= M_UNKNOWN;
 static int manual_height;
 static int manual_width;
 
-static int set_system(struct dmi_system_id *id)
+static int set_system(const struct dmi_system_id *id)
 {
 	printk(KERN_INFO "imacfb: %s detected - set system to %ld\n",
 		id->ident, (long)id->driver_data);
include/linux/dmi.h +11 -11
index b8ac7b0..00fc7a9 100644
@@ -54,7 +54,7 @@ struct dmi_strmatch {
 };
 
 struct dmi_system_id {
-	int (*callback)(struct dmi_system_id *);
+	int (*callback)(const struct dmi_system_id *);
 	const char *ident;
 	struct dmi_strmatch matches[4];
 	void *driver_data;
@@ -71,22 +71,22 @@ struct dmi_device {
 
 #ifdef CONFIG_DMI
 
-extern int dmi_check_system(struct dmi_system_id *list);
-extern char * dmi_get_system_info(int field);
-extern struct dmi_device * dmi_find_device(int type, const char *name,
-	struct dmi_device *from);
+extern int dmi_check_system(const struct dmi_system_id *list);
+extern const char * dmi_get_system_info(int field);
+extern const struct dmi_device * dmi_find_device(int type, const char *name,
+	const struct dmi_device *from);
 extern void dmi_scan_machine(void);
 extern int dmi_get_year(int field);
-extern int dmi_name_in_vendors(char *str);
+extern int dmi_name_in_vendors(const char *str);
 
 #else
 
-static inline int dmi_check_system(struct dmi_system_id *list) { return 0; }
-static inline char * dmi_get_system_info(int field) { return NULL; }
-static inline struct dmi_device * dmi_find_device(int type, const char *name,
-	struct dmi_device *from) { return NULL; }
+static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
+static inline const char * dmi_get_system_info(int field) { return NULL; }
+static inline const struct dmi_device * dmi_find_device(int type, const char *name,
+	const struct dmi_device *from) { return NULL; }
 static inline int dmi_get_year(int year) { return 0; }
-static inline int dmi_name_in_vendors(char *s) { return 0; }
+static inline int dmi_name_in_vendors(const char *s) { return 0; }
 
 #endif
 

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw
Quoted 19 lines · Jeff Garzik

commit 457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

Author: Jeff Garzik <[email protected]>
Date:   Sat Sep 1 10:16:45 2007 -0400

drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const, since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should, whenever possible, be marked const to ensure we never ever write to that data area.

3) const-ify DMI API, to enable marking tables const where possible in low-level drivers.

Quoted 6 lines

And if we're really lucky, this might enable some additional optimizations on the part of the compiler.

The bulk of the changes are #2 and #3, which are interrelated. #1 could have been a separate patch, but it was so small compared to the others, it was easier to roll it into this changeset.

Looks great to me, do you want me to take this through my driver tree? I'd be glad to do so.

thanks for doing this,

greg k-h

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
Quoted 22 lines · Greg KH
Quoted 21 lines · Jeff Garzik

commit 457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

Author: Jeff Garzik <[email protected]>
Date:   Sat Sep 1 10:16:45 2007 -0400

drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const, since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should, whenever possible, be marked const to ensure we never ever write to that data area.

3) const-ify DMI API, to enable marking tables const where possible in low-level drivers.

And if we're really lucky, this might enable some additional optimizations on the part of the compiler.

Quoted 7 lines
Quoted 3 lines

The bulk of the changes are #2 and #3, which are interrelated. #1 could have been a separate patch, but it was so small compared to the others, it was easier to roll it into this changeset.

Looks great to me, do you want me to take this through my driver tree? I'd be glad to do so.

I was just going to push it myself, but have no strong feelings on the matter.

Jeff

#7 lore raw
Quoted 6 lines · Andi Kleen
Quoted 3 lines

And if we're really lucky, this might enable some additional optimizations on the part of the compiler.

Only if the kernel was compiled C++. C compilers generally ignore constness for optimization purposes because it can be so easily casted away.

???

I can't speak for the exact const-ification that Jeff did in this particular patch, but if you intended your comment up there to be a blanket statement, then you're totally and horribly wrong. There's a whole plethora of optimizations that gcc does when dealing with const- marked data. If you've seen / experienced otherwise, please post some testcases.

#8 lore raw
In reply to Jeff Garzik
Quoted 19 lines · Jeff Garzik

commit 457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

Author: Jeff Garzik <[email protected]>
Date:   Sat Sep 1 10:16:45 2007 -0400

drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const, since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should, whenever possible, be marked const to ensure we never ever write to that data area.

3) const-ify DMI API, to enable marking tables const where possible in low-level drivers.

Quoted 8 lines

And if we're really lucky, this might enable some additional optimizations on the part of the compiler.

The bulk of the changes are #2 and #3, which are interrelated. #1 could have been a separate patch, but it was so small compared to the others, it was easier to roll it into this changeset.

Looks alright to me, thanks Jeff.

Signature · 1 line
Jean Delvare
#3 lore raw
In reply to Jeff Garzik
Quoted 25 lines · Jeff Garzik
Quoted 24 lines · Greg KH
Quoted 23 lines · Jeff Garzik

commit 457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

Author: Jeff Garzik <[email protected]>
Date:   Sat Sep 1 10:16:45 2007 -0400

drivers/firmware: const-ify DMI API and internals
Three main sets of changes:
1) dmi_get_system_info() return value should have been marked
const,
since callers should not be changing that data.
2) const-ify DMI internals, since DMI firmware tables should,
whenever possible, be marked const to ensure we never ever write
to
that data area.
3) const-ify DMI API, to enable marking tables const where
possible
in low-level drivers.
And if we're really lucky, this might enable some additional
optimizations on the part of the compiler.
The bulk of the changes are #2 and #3, which are interrelated.
#1 could
have been a separate patch, but it was so small compared to the
others,
it was easier to roll it into this changeset.

Quoted 5 lines
Quoted 2 lines

Looks great to me, do you want me to take this through my driver tree? I'd be glad to do so.

I was just going to push it myself, but have no strong feelings on the matter.

Ok, you can push it, that's fine with me. Feel free to add my:

if you want.

thanks,

greg k-h

#4 lore raw
Quoted 8 lines
Quoted 3 lines

I was just going to push it myself, but have no strong feelings on the matter.

Ok, you can push it, that's fine with me. Feel free to add my:

if you want.

That should be "Acked-by:" since the patch does not pass via you but you acknowledge it is OK by your Ack.

Sam

#5 lore raw
Quoted 10 lines · Sam Ravnborg
Quoted 8 lines
Quoted 3 lines

I was just going to push it myself, but have no strong feelings on the matter.

Ok, you can push it, that's fine with me. Feel free to add my:

if you want.

That should be "Acked-by:" since the patch does not pass via you but you acknowledge it is OK by your Ack.

Well, as I am the maintainer for that subsystem, and I did review the patch and it looks good, that is a bit more than just an "ack" :)

But whatever you want, I'm not going to get technical here with "reviewed-by" and such right now...

thanks,

greg k-h

Acked-by on v1 1/1
#9 lore raw
In reply to Jeff Garzik
Quoted 19 lines · Jeff Garzik

commit 457b6eb3bf3341d2e143518a0bb99ffbb8d754c4

Author: Jeff Garzik <[email protected]>
Date:   Sat Sep 1 10:16:45 2007 -0400

drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const, since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should, whenever possible, be marked const to ensure we never ever write to that data area.

3) const-ify DMI API, to enable marking tables const where possible in low-level drivers.

Quoted 8 lines

And if we're really lucky, this might enable some additional optimizations on the part of the compiler.

The bulk of the changes are #2 and #3, which are interrelated. #1 could have been a separate patch, but it was so small compared to the others, it was easier to roll it into this changeset.

[ a bit late ]