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. Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
This commit is contained in:
@@ -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 : "?";
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user