Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158514
b: refs/heads/master
c: 3e5cd1f
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Sep 9, 2009
1 parent a90f0b0 commit 36a77e0
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 02c24fa87724bb3af969463cd74dc3b3feb24740
refs/heads/master: 3e5cd1f2576c720f1d0705fdd7ba64f27e8836b7
5 changes: 3 additions & 2 deletions trunk/arch/x86/pci/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,14 @@ struct pci_raw_ops pci_direct_conf2 = {
static int __init pci_sanity_check(struct pci_raw_ops *o)
{
u32 x = 0;
int devfn;
int year, devfn;

if (pci_probe & PCI_NO_CHECKS)
return 1;
/* Assume Type 1 works for newer systems.
This handles machines that don't have anything on PCI Bus 0. */
if (dmi_get_year(DMI_BIOS_DATE) >= 2001)
dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL);
if (year >= 2001)
return 1;

for (devfn = 0; devfn < 0x100; devfn++) {
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/acpi/blacklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ static struct acpi_blacklist_item acpi_blacklist[] __initdata = {

static int __init blacklist_by_year(void)
{
int year = dmi_get_year(DMI_BIOS_DATE);
int year;

/* Doesn't exist? Likely an old system */
if (year == -1) {
if (!dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL)) {
printk(KERN_ERR PREFIX "no DMI BIOS year, "
"acpi=force is required to enable ACPI\n" );
return 1;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2679,7 +2679,7 @@ static bool ahci_asus_m2a_vm_32bit_only(struct pci_dev *pdev)
* different versions.
*/
date = dmi_get_system_info(DMI_BIOS_DATE);
year = dmi_get_year(DMI_BIOS_DATE);
dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL);
if (date && strlen(date) >= 10 && date[2] == '/' && date[5] == '/' &&
(year > 2007 ||
(year == 2007 && strncmp(date, cutoff_mmdd, 5) >= 0)))
Expand Down
76 changes: 58 additions & 18 deletions trunk/drivers/firmware/dmi_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,36 +568,76 @@ const struct dmi_device * dmi_find_device(int type, const char *name,
EXPORT_SYMBOL(dmi_find_device);

/**
* dmi_get_year - Return year of a DMI date
* @field: data index (like dmi_get_system_info)
* dmi_get_date - parse a DMI date
* @field: data index (see enum dmi_field)
* @yearp: optional out parameter for the year
* @monthp: optional out parameter for the month
* @dayp: optional out parameter for the day
*
* Returns -1 when the field doesn't exist. 0 when it is broken.
* The date field is assumed to be in the form resembling
* [mm[/dd]]/yy[yy] and the result is stored in the out
* parameters any or all of which can be omitted.
*
* If the field doesn't exist, all out parameters are set to zero
* and false is returned. Otherwise, true is returned with any
* invalid part of date set to zero.
*
* On return, year, month and day are guaranteed to be in the
* range of [0,9999], [0,12] and [0,31] respectively.
*/
int dmi_get_year(int field)
bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
{
int year;
const char *s = dmi_get_system_info(field);
int year = 0, month = 0, day = 0;
bool exists;
const char *s, *y;
char *e;

if (!s)
return -1;
if (*s == '\0')
return 0;
s = strrchr(s, '/');
if (!s)
return 0;
s = dmi_get_system_info(field);
exists = s;
if (!exists)
goto out;

s += 1;
year = simple_strtoul(s, &e, 10);
if (s != e && year < 100) { /* 2-digit year */
/*
* Determine year first. We assume the date string resembles
* mm/dd/yy[yy] but the original code extracted only the year
* from the end. Keep the behavior in the spirit of no
* surprises.
*/
y = strrchr(s, '/');
if (!y)
goto out;

y++;
year = simple_strtoul(y, &e, 10);
if (y != e && year < 100) { /* 2-digit year */
year += 1900;
if (year < 1996) /* no dates < spec 1.0 */
year += 100;
}
if (year > 9999) /* year should fit in %04d */
year = 0;

/* parse the mm and dd */
month = simple_strtoul(s, &e, 10);
if (s == e || *e != '/' || !month || month > 12) {
month = 0;
goto out;
}

return year;
s = e + 1;
day = simple_strtoul(s, &e, 10);
if (s == y || s == e || *e != '/' || day > 31)
day = 0;
out:
if (yearp)
*yearp = year;
if (monthp)
*monthp = month;
if (dayp)
*dayp = day;
return exists;
}
EXPORT_SYMBOL(dmi_get_year);
EXPORT_SYMBOL(dmi_get_date);

/**
* dmi_walk - Walk the DMI table and get called back for every record
Expand Down
13 changes: 11 additions & 2 deletions trunk/include/linux/dmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ 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 bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp);
extern int dmi_name_in_vendors(const char *str);
extern int dmi_name_in_serial(const char *str);
extern int dmi_available;
Expand All @@ -58,7 +58,16 @@ 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 void dmi_scan_machine(void) { return; }
static inline int dmi_get_year(int year) { return 0; }
static inline bool dmi_get_date(int field, int *yearp, int *monthp, int *dayp)
{
if (yearp)
*yearp = 0;
if (monthp)
*monthp = 0;
if (dayp)
*dayp = 0;
return false;
}
static inline int dmi_name_in_vendors(const char *s) { return 0; }
static inline int dmi_name_in_serial(const char *s) { return 0; }
#define dmi_available 0
Expand Down

0 comments on commit 36a77e0

Please sign in to comment.