11 #include <linux/export.h>
12 #include <linux/rtc.h>
72 #define FILEHASH (997)
73 #define DEVHASH (1009)
75 #define DEVSEED (7919)
77 static unsigned int dev_hash_value;
79 static int set_magic_time(
unsigned int user,
unsigned int file,
unsigned int device)
104 time.
tm_min = (n % 20) * 3;
110 static unsigned int read_magic_time(
void)
116 pr_info(
"RTC time: %2d:%02d:%02d, date: %02d/%02d/%02d\n",
122 val +=
time.tm_mon * 100;
123 val += (
time.tm_mday-1) * 100 * 12;
124 val +=
time.tm_hour * 100 * 12 * 28;
125 val += (
time.tm_min / 3) * 100 * 12 * 28 * 24;
133 static unsigned int hash_string(
unsigned int seed,
const char *
data,
unsigned int mod)
136 while ((c = *data++) != 0) {
137 seed = (seed << 16) + (seed << 6) - seed +
c;
159 unsigned short lineno = *(
unsigned short *)tracedata;
160 const char *
file = *(
const char **)(tracedata + 2);
161 unsigned int user_hash_value, file_hash_value;
164 file_hash_value = hash_string(lineno, file,
FILEHASH);
165 set_magic_time(user_hash_value, file_hash_value, dev_hash_value);
170 static int show_file_hash(
unsigned int value)
176 for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ;
177 tracedata += 2 +
sizeof(
unsigned long)) {
178 unsigned short lineno = *(
unsigned short *)tracedata;
179 const char *
file = *(
const char **)(tracedata + 2);
180 unsigned int hash = hash_string(lineno, file,
FILEHASH);
183 pr_info(
" hash matches %s:%u\n", file, lineno);
189 static int show_dev_hash(
unsigned int value)
195 entry = dpm_list.
prev;
196 while (entry != &dpm_list) {
209 static unsigned int hash_value_early_read;
222 entry = dpm_list.
prev;
223 while (size && entry != &dpm_list) {
225 unsigned int hash = hash_string(
DEVSEED, dev_name(dev),
242 static int early_resume_init(
void)
244 hash_value_early_read = read_magic_time();
248 static int late_resume_init(
void)
250 unsigned int val = hash_value_early_read;
259 pr_info(
" Magic number: %d:%d:%d\n", user, file, dev);
260 show_file_hash(file);