diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/bsr.c | 2 | ||||
-rw-r--r-- | drivers/char/dsp56k.c | 2 | ||||
-rw-r--r-- | drivers/char/hangcheck-timer.c | 33 | ||||
-rw-r--r-- | drivers/char/hw_random/core.c | 46 | ||||
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 10 | ||||
-rw-r--r-- | drivers/char/i8k.c | 123 | ||||
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 4 | ||||
-rw-r--r-- | drivers/char/random.c | 17 | ||||
-rw-r--r-- | drivers/char/tpm/tpm-interface.c | 73 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_eventlog.c | 4 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_i2c_stm_st33.c | 1 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_tis.c | 31 | ||||
-rw-r--r-- | drivers/char/xilinx_hwicap/xilinx_hwicap.c | 1 |
13 files changed, 232 insertions, 115 deletions
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c index 8fedbc250414..a6cef548e01e 100644 --- a/drivers/char/bsr.c +++ b/drivers/char/bsr.c | |||
@@ -259,7 +259,7 @@ static int bsr_add_node(struct device_node *bn) | |||
259 | } | 259 | } |
260 | 260 | ||
261 | cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, | 261 | cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, |
262 | cur, cur->bsr_name); | 262 | cur, "%s", cur->bsr_name); |
263 | if (IS_ERR(cur->bsr_device)) { | 263 | if (IS_ERR(cur->bsr_device)) { |
264 | printk(KERN_ERR "device_create failed for %s\n", | 264 | printk(KERN_ERR "device_create failed for %s\n", |
265 | cur->bsr_name); | 265 | cur->bsr_name); |
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index 01a5ca7425d7..8bf70e8c3f79 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c | |||
@@ -383,7 +383,7 @@ static long dsp56k_ioctl(struct file *file, unsigned int cmd, | |||
383 | return put_user(status, &hf->status); | 383 | return put_user(status, &hf->status); |
384 | } | 384 | } |
385 | case DSP56K_HOST_CMD: | 385 | case DSP56K_HOST_CMD: |
386 | if (arg > 31 || arg < 0) | 386 | if (arg > 31) |
387 | return -EINVAL; | 387 | return -EINVAL; |
388 | mutex_lock(&dsp56k_mutex); | 388 | mutex_lock(&dsp56k_mutex); |
389 | dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | | 389 | dsp56k_host_interface.cvr = (u_char)((arg & DSP56K_CVR_HV_MASK) | |
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index f953c96efc86..ebc4c73d8ca4 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
50 | #include <linux/sysrq.h> | 50 | #include <linux/sysrq.h> |
51 | #include <linux/timer.h> | 51 | #include <linux/timer.h> |
52 | #include <linux/time.h> | 52 | #include <linux/hrtimer.h> |
53 | 53 | ||
54 | #define VERSION_STR "0.9.1" | 54 | #define VERSION_STR "0.9.1" |
55 | 55 | ||
@@ -117,24 +117,7 @@ __setup("hcheck_reboot", hangcheck_parse_reboot); | |||
117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); | 117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); |
118 | #endif /* not MODULE */ | 118 | #endif /* not MODULE */ |
119 | 119 | ||
120 | #if defined(CONFIG_S390) | 120 | #define TIMER_FREQ 1000000000ULL |
121 | # define HAVE_MONOTONIC | ||
122 | # define TIMER_FREQ 1000000000ULL | ||
123 | #else | ||
124 | # define TIMER_FREQ 1000000000ULL | ||
125 | #endif | ||
126 | |||
127 | #ifdef HAVE_MONOTONIC | ||
128 | extern unsigned long long monotonic_clock(void); | ||
129 | #else | ||
130 | static inline unsigned long long monotonic_clock(void) | ||
131 | { | ||
132 | struct timespec ts; | ||
133 | getrawmonotonic(&ts); | ||
134 | return timespec_to_ns(&ts); | ||
135 | } | ||
136 | #endif /* HAVE_MONOTONIC */ | ||
137 | |||
138 | 121 | ||
139 | /* Last time scheduled */ | 122 | /* Last time scheduled */ |
140 | static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; | 123 | static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; |
@@ -143,12 +126,11 @@ static void hangcheck_fire(unsigned long); | |||
143 | 126 | ||
144 | static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); | 127 | static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); |
145 | 128 | ||
146 | |||
147 | static void hangcheck_fire(unsigned long data) | 129 | static void hangcheck_fire(unsigned long data) |
148 | { | 130 | { |
149 | unsigned long long cur_tsc, tsc_diff; | 131 | unsigned long long cur_tsc, tsc_diff; |
150 | 132 | ||
151 | cur_tsc = monotonic_clock(); | 133 | cur_tsc = ktime_get_ns(); |
152 | 134 | ||
153 | if (cur_tsc > hangcheck_tsc) | 135 | if (cur_tsc > hangcheck_tsc) |
154 | tsc_diff = cur_tsc - hangcheck_tsc; | 136 | tsc_diff = cur_tsc - hangcheck_tsc; |
@@ -177,7 +159,7 @@ static void hangcheck_fire(unsigned long data) | |||
177 | tsc_diff, tsc_diff - hangcheck_tick*TIMER_FREQ); | 159 | tsc_diff, tsc_diff - hangcheck_tick*TIMER_FREQ); |
178 | #endif | 160 | #endif |
179 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); | 161 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); |
180 | hangcheck_tsc = monotonic_clock(); | 162 | hangcheck_tsc = ktime_get_ns(); |
181 | } | 163 | } |
182 | 164 | ||
183 | 165 | ||
@@ -185,16 +167,11 @@ static int __init hangcheck_init(void) | |||
185 | { | 167 | { |
186 | printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", | 168 | printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", |
187 | VERSION_STR, hangcheck_tick, hangcheck_margin); | 169 | VERSION_STR, hangcheck_tick, hangcheck_margin); |
188 | #if defined (HAVE_MONOTONIC) | ||
189 | printk("Hangcheck: Using monotonic_clock().\n"); | ||
190 | #else | ||
191 | printk("Hangcheck: Using getrawmonotonic().\n"); | ||
192 | #endif /* HAVE_MONOTONIC */ | ||
193 | hangcheck_tsc_margin = | 170 | hangcheck_tsc_margin = |
194 | (unsigned long long)(hangcheck_margin + hangcheck_tick); | 171 | (unsigned long long)(hangcheck_margin + hangcheck_tick); |
195 | hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ; | 172 | hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ; |
196 | 173 | ||
197 | hangcheck_tsc = monotonic_clock(); | 174 | hangcheck_tsc = ktime_get_ns(); |
198 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); | 175 | mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); |
199 | 176 | ||
200 | return 0; | 177 | return 0; |
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 33fd6633586d..6e02ec103cc7 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c | |||
@@ -68,20 +68,40 @@ MODULE_PARM_DESC(default_quality, | |||
68 | 68 | ||
69 | static void start_khwrngd(void); | 69 | static void start_khwrngd(void); |
70 | 70 | ||
71 | static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size, | ||
72 | int wait); | ||
73 | |||
71 | static size_t rng_buffer_size(void) | 74 | static size_t rng_buffer_size(void) |
72 | { | 75 | { |
73 | return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES; | 76 | return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES; |
74 | } | 77 | } |
75 | 78 | ||
76 | static inline int hwrng_init(struct hwrng *rng) | 79 | static void add_early_randomness(struct hwrng *rng) |
77 | { | 80 | { |
78 | int err; | 81 | unsigned char bytes[16]; |
82 | int bytes_read; | ||
83 | |||
84 | /* | ||
85 | * Currently only virtio-rng cannot return data during device | ||
86 | * probe, and that's handled in virtio-rng.c itself. If there | ||
87 | * are more such devices, this call to rng_get_data can be | ||
88 | * made conditional here instead of doing it per-device. | ||
89 | */ | ||
90 | bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1); | ||
91 | if (bytes_read > 0) | ||
92 | add_device_randomness(bytes, bytes_read); | ||
93 | } | ||
79 | 94 | ||
95 | static inline int hwrng_init(struct hwrng *rng) | ||
96 | { | ||
80 | if (rng->init) { | 97 | if (rng->init) { |
81 | err = rng->init(rng); | 98 | int ret; |
82 | if (err) | 99 | |
83 | return err; | 100 | ret = rng->init(rng); |
101 | if (ret) | ||
102 | return ret; | ||
84 | } | 103 | } |
104 | add_early_randomness(rng); | ||
85 | 105 | ||
86 | current_quality = rng->quality ? : default_quality; | 106 | current_quality = rng->quality ? : default_quality; |
87 | current_quality &= 1023; | 107 | current_quality &= 1023; |
@@ -361,8 +381,6 @@ int hwrng_register(struct hwrng *rng) | |||
361 | { | 381 | { |
362 | int err = -EINVAL; | 382 | int err = -EINVAL; |
363 | struct hwrng *old_rng, *tmp; | 383 | struct hwrng *old_rng, *tmp; |
364 | unsigned char bytes[16]; | ||
365 | int bytes_read; | ||
366 | 384 | ||
367 | if (rng->name == NULL || | 385 | if (rng->name == NULL || |
368 | (rng->data_read == NULL && rng->read == NULL)) | 386 | (rng->data_read == NULL && rng->read == NULL)) |
@@ -411,9 +429,17 @@ int hwrng_register(struct hwrng *rng) | |||
411 | INIT_LIST_HEAD(&rng->list); | 429 | INIT_LIST_HEAD(&rng->list); |
412 | list_add_tail(&rng->list, &rng_list); | 430 | list_add_tail(&rng->list, &rng_list); |
413 | 431 | ||
414 | bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1); | 432 | if (old_rng && !rng->init) { |
415 | if (bytes_read > 0) | 433 | /* |
416 | add_device_randomness(bytes, bytes_read); | 434 | * Use a new device's input to add some randomness to |
435 | * the system. If this rng device isn't going to be | ||
436 | * used right away, its init function hasn't been | ||
437 | * called yet; so only use the randomness from devices | ||
438 | * that don't need an init callback. | ||
439 | */ | ||
440 | add_early_randomness(rng); | ||
441 | } | ||
442 | |||
417 | out_unlock: | 443 | out_unlock: |
418 | mutex_unlock(&rng_mutex); | 444 | mutex_unlock(&rng_mutex); |
419 | out: | 445 | out: |
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index f3e71501de54..e9b15bc18b4d 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c | |||
@@ -38,6 +38,8 @@ struct virtrng_info { | |||
38 | int index; | 38 | int index; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static bool probe_done; | ||
42 | |||
41 | static void random_recv_done(struct virtqueue *vq) | 43 | static void random_recv_done(struct virtqueue *vq) |
42 | { | 44 | { |
43 | struct virtrng_info *vi = vq->vdev->priv; | 45 | struct virtrng_info *vi = vq->vdev->priv; |
@@ -67,6 +69,13 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait) | |||
67 | int ret; | 69 | int ret; |
68 | struct virtrng_info *vi = (struct virtrng_info *)rng->priv; | 70 | struct virtrng_info *vi = (struct virtrng_info *)rng->priv; |
69 | 71 | ||
72 | /* | ||
73 | * Don't ask host for data till we're setup. This call can | ||
74 | * happen during hwrng_register(), after commit d9e7972619. | ||
75 | */ | ||
76 | if (unlikely(!probe_done)) | ||
77 | return 0; | ||
78 | |||
70 | if (!vi->busy) { | 79 | if (!vi->busy) { |
71 | vi->busy = true; | 80 | vi->busy = true; |
72 | init_completion(&vi->have_data); | 81 | init_completion(&vi->have_data); |
@@ -137,6 +146,7 @@ static int probe_common(struct virtio_device *vdev) | |||
137 | return err; | 146 | return err; |
138 | } | 147 | } |
139 | 148 | ||
149 | probe_done = true; | ||
140 | return 0; | 150 | return 0; |
141 | } | 151 | } |
142 | 152 | ||
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index 93dcad0c1cbe..65525c7e903c 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
@@ -65,6 +65,8 @@ static char bios_version[4]; | |||
65 | static struct device *i8k_hwmon_dev; | 65 | static struct device *i8k_hwmon_dev; |
66 | static u32 i8k_hwmon_flags; | 66 | static u32 i8k_hwmon_flags; |
67 | static int i8k_fan_mult; | 67 | static int i8k_fan_mult; |
68 | static int i8k_pwm_mult; | ||
69 | static int i8k_fan_max = I8K_FAN_HIGH; | ||
68 | 70 | ||
69 | #define I8K_HWMON_HAVE_TEMP1 (1 << 0) | 71 | #define I8K_HWMON_HAVE_TEMP1 (1 << 0) |
70 | #define I8K_HWMON_HAVE_TEMP2 (1 << 1) | 72 | #define I8K_HWMON_HAVE_TEMP2 (1 << 1) |
@@ -97,6 +99,10 @@ static int fan_mult = I8K_FAN_MULT; | |||
97 | module_param(fan_mult, int, 0); | 99 | module_param(fan_mult, int, 0); |
98 | MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with"); | 100 | MODULE_PARM_DESC(fan_mult, "Factor to multiply fan speed with"); |
99 | 101 | ||
102 | static int fan_max = I8K_FAN_HIGH; | ||
103 | module_param(fan_max, int, 0); | ||
104 | MODULE_PARM_DESC(fan_max, "Maximum configurable fan speed"); | ||
105 | |||
100 | static int i8k_open_fs(struct inode *inode, struct file *file); | 106 | static int i8k_open_fs(struct inode *inode, struct file *file); |
101 | static long i8k_ioctl(struct file *, unsigned int, unsigned long); | 107 | static long i8k_ioctl(struct file *, unsigned int, unsigned long); |
102 | 108 | ||
@@ -276,7 +282,7 @@ static int i8k_set_fan(int fan, int speed) | |||
276 | { | 282 | { |
277 | struct smm_regs regs = { .eax = I8K_SMM_SET_FAN, }; | 283 | struct smm_regs regs = { .eax = I8K_SMM_SET_FAN, }; |
278 | 284 | ||
279 | speed = (speed < 0) ? 0 : ((speed > I8K_FAN_MAX) ? I8K_FAN_MAX : speed); | 285 | speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : speed); |
280 | regs.ebx = (fan & 0xff) | (speed << 8); | 286 | regs.ebx = (fan & 0xff) | (speed << 8); |
281 | 287 | ||
282 | return i8k_smm(®s) ? : i8k_get_fan_status(fan); | 288 | return i8k_smm(®s) ? : i8k_get_fan_status(fan); |
@@ -521,7 +527,7 @@ static ssize_t i8k_hwmon_show_pwm(struct device *dev, | |||
521 | status = i8k_get_fan_status(index); | 527 | status = i8k_get_fan_status(index); |
522 | if (status < 0) | 528 | if (status < 0) |
523 | return -EIO; | 529 | return -EIO; |
524 | return sprintf(buf, "%d\n", clamp_val(status * 128, 0, 255)); | 530 | return sprintf(buf, "%d\n", clamp_val(status * i8k_pwm_mult, 0, 255)); |
525 | } | 531 | } |
526 | 532 | ||
527 | static ssize_t i8k_hwmon_set_pwm(struct device *dev, | 533 | static ssize_t i8k_hwmon_set_pwm(struct device *dev, |
@@ -535,7 +541,7 @@ static ssize_t i8k_hwmon_set_pwm(struct device *dev, | |||
535 | err = kstrtoul(buf, 10, &val); | 541 | err = kstrtoul(buf, 10, &val); |
536 | if (err) | 542 | if (err) |
537 | return err; | 543 | return err; |
538 | val = clamp_val(DIV_ROUND_CLOSEST(val, 128), 0, 2); | 544 | val = clamp_val(DIV_ROUND_CLOSEST(val, i8k_pwm_mult), 0, i8k_fan_max); |
539 | 545 | ||
540 | mutex_lock(&i8k_mutex); | 546 | mutex_lock(&i8k_mutex); |
541 | err = i8k_set_fan(index, val); | 547 | err = i8k_set_fan(index, val); |
@@ -544,20 +550,6 @@ static ssize_t i8k_hwmon_set_pwm(struct device *dev, | |||
544 | return err < 0 ? -EIO : count; | 550 | return err < 0 ? -EIO : count; |
545 | } | 551 | } |
546 | 552 | ||
547 | static ssize_t i8k_hwmon_show_label(struct device *dev, | ||
548 | struct device_attribute *devattr, | ||
549 | char *buf) | ||
550 | { | ||
551 | static const char *labels[3] = { | ||
552 | "CPU", | ||
553 | "Left Fan", | ||
554 | "Right Fan", | ||
555 | }; | ||
556 | int index = to_sensor_dev_attr(devattr)->index; | ||
557 | |||
558 | return sprintf(buf, "%s\n", labels[index]); | ||
559 | } | ||
560 | |||
561 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0); | 553 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0); |
562 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1); | 554 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1); |
563 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2); | 555 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2); |
@@ -570,41 +562,34 @@ static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, i8k_hwmon_show_fan, NULL, | |||
570 | I8K_FAN_RIGHT); | 562 | I8K_FAN_RIGHT); |
571 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, | 563 | static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm, |
572 | i8k_hwmon_set_pwm, I8K_FAN_RIGHT); | 564 | i8k_hwmon_set_pwm, I8K_FAN_RIGHT); |
573 | static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, i8k_hwmon_show_label, NULL, 0); | ||
574 | static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, i8k_hwmon_show_label, NULL, 1); | ||
575 | static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_label, NULL, 2); | ||
576 | 565 | ||
577 | static struct attribute *i8k_attrs[] = { | 566 | static struct attribute *i8k_attrs[] = { |
578 | &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */ | 567 | &sensor_dev_attr_temp1_input.dev_attr.attr, /* 0 */ |
579 | &sensor_dev_attr_temp1_label.dev_attr.attr, /* 1 */ | 568 | &sensor_dev_attr_temp2_input.dev_attr.attr, /* 1 */ |
580 | &sensor_dev_attr_temp2_input.dev_attr.attr, /* 2 */ | 569 | &sensor_dev_attr_temp3_input.dev_attr.attr, /* 2 */ |
581 | &sensor_dev_attr_temp3_input.dev_attr.attr, /* 3 */ | 570 | &sensor_dev_attr_temp4_input.dev_attr.attr, /* 3 */ |
582 | &sensor_dev_attr_temp4_input.dev_attr.attr, /* 4 */ | 571 | &sensor_dev_attr_fan1_input.dev_attr.attr, /* 4 */ |
583 | &sensor_dev_attr_fan1_input.dev_attr.attr, /* 5 */ | 572 | &sensor_dev_attr_pwm1.dev_attr.attr, /* 5 */ |
584 | &sensor_dev_attr_pwm1.dev_attr.attr, /* 6 */ | 573 | &sensor_dev_attr_fan2_input.dev_attr.attr, /* 6 */ |
585 | &sensor_dev_attr_fan1_label.dev_attr.attr, /* 7 */ | 574 | &sensor_dev_attr_pwm2.dev_attr.attr, /* 7 */ |
586 | &sensor_dev_attr_fan2_input.dev_attr.attr, /* 8 */ | ||
587 | &sensor_dev_attr_pwm2.dev_attr.attr, /* 9 */ | ||
588 | &sensor_dev_attr_fan2_label.dev_attr.attr, /* 10 */ | ||
589 | NULL | 575 | NULL |
590 | }; | 576 | }; |
591 | 577 | ||
592 | static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, | 578 | static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, |
593 | int index) | 579 | int index) |
594 | { | 580 | { |
595 | if ((index == 0 || index == 1) && | 581 | if (index == 0 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) |
596 | !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) | ||
597 | return 0; | 582 | return 0; |
598 | if (index == 2 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) | 583 | if (index == 1 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP2)) |
599 | return 0; | 584 | return 0; |
600 | if (index == 3 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) | 585 | if (index == 2 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP3)) |
601 | return 0; | 586 | return 0; |
602 | if (index == 4 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) | 587 | if (index == 3 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) |
603 | return 0; | 588 | return 0; |
604 | if (index >= 5 && index <= 7 && | 589 | if (index >= 4 && index <= 5 && |
605 | !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) | 590 | !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) |
606 | return 0; | 591 | return 0; |
607 | if (index >= 8 && index <= 10 && | 592 | if (index >= 6 && index <= 7 && |
608 | !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) | 593 | !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN2)) |
609 | return 0; | 594 | return 0; |
610 | 595 | ||
@@ -659,6 +644,37 @@ static int __init i8k_init_hwmon(void) | |||
659 | return 0; | 644 | return 0; |
660 | } | 645 | } |
661 | 646 | ||
647 | struct i8k_config_data { | ||
648 | int fan_mult; | ||
649 | int fan_max; | ||
650 | }; | ||
651 | |||
652 | enum i8k_configs { | ||
653 | DELL_LATITUDE_D520, | ||
654 | DELL_PRECISION_490, | ||
655 | DELL_STUDIO, | ||
656 | DELL_XPS_M140, | ||
657 | }; | ||
658 | |||
659 | static const struct i8k_config_data i8k_config_data[] = { | ||
660 | [DELL_LATITUDE_D520] = { | ||
661 | .fan_mult = 1, | ||
662 | .fan_max = I8K_FAN_TURBO, | ||
663 | }, | ||
664 | [DELL_PRECISION_490] = { | ||
665 | .fan_mult = 1, | ||
666 | .fan_max = I8K_FAN_TURBO, | ||
667 | }, | ||
668 | [DELL_STUDIO] = { | ||
669 | .fan_mult = 1, | ||
670 | .fan_max = I8K_FAN_HIGH, | ||
671 | }, | ||
672 | [DELL_XPS_M140] = { | ||
673 | .fan_mult = 1, | ||
674 | .fan_max = I8K_FAN_HIGH, | ||
675 | }, | ||
676 | }; | ||
677 | |||
662 | static struct dmi_system_id i8k_dmi_table[] __initdata = { | 678 | static struct dmi_system_id i8k_dmi_table[] __initdata = { |
663 | { | 679 | { |
664 | .ident = "Dell Inspiron", | 680 | .ident = "Dell Inspiron", |
@@ -682,6 +698,14 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { | |||
682 | }, | 698 | }, |
683 | }, | 699 | }, |
684 | { | 700 | { |
701 | .ident = "Dell Latitude D520", | ||
702 | .matches = { | ||
703 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
704 | DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D520"), | ||
705 | }, | ||
706 | .driver_data = (void *)&i8k_config_data[DELL_LATITUDE_D520], | ||
707 | }, | ||
708 | { | ||
685 | .ident = "Dell Latitude 2", | 709 | .ident = "Dell Latitude 2", |
686 | .matches = { | 710 | .matches = { |
687 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 711 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
@@ -703,6 +727,15 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { | |||
703 | }, | 727 | }, |
704 | }, | 728 | }, |
705 | { | 729 | { |
730 | .ident = "Dell Precision 490", | ||
731 | .matches = { | ||
732 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
733 | DMI_MATCH(DMI_PRODUCT_NAME, | ||
734 | "Precision WorkStation 490"), | ||
735 | }, | ||
736 | .driver_data = (void *)&i8k_config_data[DELL_PRECISION_490], | ||
737 | }, | ||
738 | { | ||
706 | .ident = "Dell Precision", | 739 | .ident = "Dell Precision", |
707 | .matches = { | 740 | .matches = { |
708 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 741 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
@@ -729,7 +762,7 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { | |||
729 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 762 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
730 | DMI_MATCH(DMI_PRODUCT_NAME, "Studio"), | 763 | DMI_MATCH(DMI_PRODUCT_NAME, "Studio"), |
731 | }, | 764 | }, |
732 | .driver_data = (void *)1, /* fan multiplier override */ | 765 | .driver_data = (void *)&i8k_config_data[DELL_STUDIO], |
733 | }, | 766 | }, |
734 | { | 767 | { |
735 | .ident = "Dell XPS M140", | 768 | .ident = "Dell XPS M140", |
@@ -737,7 +770,7 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { | |||
737 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | 770 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
738 | DMI_MATCH(DMI_PRODUCT_NAME, "MXC051"), | 771 | DMI_MATCH(DMI_PRODUCT_NAME, "MXC051"), |
739 | }, | 772 | }, |
740 | .driver_data = (void *)1, /* fan multiplier override */ | 773 | .driver_data = (void *)&i8k_config_data[DELL_XPS_M140], |
741 | }, | 774 | }, |
742 | { } | 775 | { } |
743 | }; | 776 | }; |
@@ -777,9 +810,17 @@ static int __init i8k_probe(void) | |||
777 | } | 810 | } |
778 | 811 | ||
779 | i8k_fan_mult = fan_mult; | 812 | i8k_fan_mult = fan_mult; |
813 | i8k_fan_max = fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */ | ||
780 | id = dmi_first_match(i8k_dmi_table); | 814 | id = dmi_first_match(i8k_dmi_table); |
781 | if (id && fan_mult == I8K_FAN_MULT && id->driver_data) | 815 | if (id && id->driver_data) { |
782 | i8k_fan_mult = (unsigned long)id->driver_data; | 816 | const struct i8k_config_data *conf = id->driver_data; |
817 | |||
818 | if (fan_mult == I8K_FAN_MULT && conf->fan_mult) | ||
819 | i8k_fan_mult = conf->fan_mult; | ||
820 | if (fan_max == I8K_FAN_HIGH && conf->fan_max) | ||
821 | i8k_fan_max = conf->fan_max; | ||
822 | } | ||
823 | i8k_pwm_mult = DIV_ROUND_UP(255, i8k_fan_max); | ||
783 | 824 | ||
784 | return 0; | 825 | return 0; |
785 | } | 826 | } |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 8320abd1ef14..0ea9986059af 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -2347,8 +2347,6 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) | |||
2347 | printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", | 2347 | printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", |
2348 | __FILE__, __LINE__, info->device_name, port->count); | 2348 | __FILE__, __LINE__, info->device_name, port->count); |
2349 | 2349 | ||
2350 | WARN_ON(!port->count); | ||
2351 | |||
2352 | if (tty_port_close_start(port, tty, filp) == 0) | 2350 | if (tty_port_close_start(port, tty, filp) == 0) |
2353 | goto cleanup; | 2351 | goto cleanup; |
2354 | 2352 | ||
@@ -2510,7 +2508,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) | |||
2510 | __FILE__, __LINE__, tty->driver->name, port->count); | 2508 | __FILE__, __LINE__, tty->driver->name, port->count); |
2511 | 2509 | ||
2512 | /* If port is closing, signal caller to try again */ | 2510 | /* If port is closing, signal caller to try again */ |
2513 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){ | 2511 | if (port->flags & ASYNC_CLOSING){ |
2514 | wait_event_interruptible_tty(tty, port->close_wait, | 2512 | wait_event_interruptible_tty(tty, port->close_wait, |
2515 | !(port->flags & ASYNC_CLOSING)); | 2513 | !(port->flags & ASYNC_CLOSING)); |
2516 | retval = ((port->flags & ASYNC_HUP_NOTIFY) ? | 2514 | retval = ((port->flags & ASYNC_HUP_NOTIFY) ? |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 6e455bc4a39e..c18d41db83d8 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -644,7 +644,7 @@ retry: | |||
644 | } while (unlikely(entropy_count < pool_size-2 && pnfrac)); | 644 | } while (unlikely(entropy_count < pool_size-2 && pnfrac)); |
645 | } | 645 | } |
646 | 646 | ||
647 | if (entropy_count < 0) { | 647 | if (unlikely(entropy_count < 0)) { |
648 | pr_warn("random: negative entropy/overflow: pool %s count %d\n", | 648 | pr_warn("random: negative entropy/overflow: pool %s count %d\n", |
649 | r->name, entropy_count); | 649 | r->name, entropy_count); |
650 | WARN_ON(1); | 650 | WARN_ON(1); |
@@ -1017,7 +1017,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
1017 | int reserved) | 1017 | int reserved) |
1018 | { | 1018 | { |
1019 | int entropy_count, orig; | 1019 | int entropy_count, orig; |
1020 | size_t ibytes; | 1020 | size_t ibytes, nfrac; |
1021 | 1021 | ||
1022 | BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); | 1022 | BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); |
1023 | 1023 | ||
@@ -1035,7 +1035,17 @@ retry: | |||
1035 | } | 1035 | } |
1036 | if (ibytes < min) | 1036 | if (ibytes < min) |
1037 | ibytes = 0; | 1037 | ibytes = 0; |
1038 | if ((entropy_count -= ibytes << (ENTROPY_SHIFT + 3)) < 0) | 1038 | |
1039 | if (unlikely(entropy_count < 0)) { | ||
1040 | pr_warn("random: negative entropy count: pool %s count %d\n", | ||
1041 | r->name, entropy_count); | ||
1042 | WARN_ON(1); | ||
1043 | entropy_count = 0; | ||
1044 | } | ||
1045 | nfrac = ibytes << (ENTROPY_SHIFT + 3); | ||
1046 | if ((size_t) entropy_count > nfrac) | ||
1047 | entropy_count -= nfrac; | ||
1048 | else | ||
1039 | entropy_count = 0; | 1049 | entropy_count = 0; |
1040 | 1050 | ||
1041 | if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) | 1051 | if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) |
@@ -1376,6 +1386,7 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | |||
1376 | "with %d bits of entropy available\n", | 1386 | "with %d bits of entropy available\n", |
1377 | current->comm, nonblocking_pool.entropy_total); | 1387 | current->comm, nonblocking_pool.entropy_total); |
1378 | 1388 | ||
1389 | nbytes = min_t(size_t, nbytes, INT_MAX >> (ENTROPY_SHIFT + 3)); | ||
1379 | ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); | 1390 | ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); |
1380 | 1391 | ||
1381 | trace_urandom_read(8 * nbytes, ENTROPY_BITS(&nonblocking_pool), | 1392 | trace_urandom_read(8 * nbytes, ENTROPY_BITS(&nonblocking_pool), |
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index 62e10fd1e1cb..6af17002a115 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c | |||
@@ -491,11 +491,10 @@ static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) | |||
491 | int tpm_get_timeouts(struct tpm_chip *chip) | 491 | int tpm_get_timeouts(struct tpm_chip *chip) |
492 | { | 492 | { |
493 | struct tpm_cmd_t tpm_cmd; | 493 | struct tpm_cmd_t tpm_cmd; |
494 | struct timeout_t *timeout_cap; | 494 | unsigned long new_timeout[4]; |
495 | unsigned long old_timeout[4]; | ||
495 | struct duration_t *duration_cap; | 496 | struct duration_t *duration_cap; |
496 | ssize_t rc; | 497 | ssize_t rc; |
497 | u32 timeout; | ||
498 | unsigned int scale = 1; | ||
499 | 498 | ||
500 | tpm_cmd.header.in = tpm_getcap_header; | 499 | tpm_cmd.header.in = tpm_getcap_header; |
501 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; | 500 | tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP; |
@@ -529,25 +528,46 @@ int tpm_get_timeouts(struct tpm_chip *chip) | |||
529 | != sizeof(tpm_cmd.header.out) + sizeof(u32) + 4 * sizeof(u32)) | 528 | != sizeof(tpm_cmd.header.out) + sizeof(u32) + 4 * sizeof(u32)) |
530 | return -EINVAL; | 529 | return -EINVAL; |
531 | 530 | ||
532 | timeout_cap = &tpm_cmd.params.getcap_out.cap.timeout; | 531 | old_timeout[0] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.a); |
533 | /* Don't overwrite default if value is 0 */ | 532 | old_timeout[1] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.b); |
534 | timeout = be32_to_cpu(timeout_cap->a); | 533 | old_timeout[2] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.c); |
535 | if (timeout && timeout < 1000) { | 534 | old_timeout[3] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.d); |
536 | /* timeouts in msec rather usec */ | 535 | memcpy(new_timeout, old_timeout, sizeof(new_timeout)); |
537 | scale = 1000; | 536 | |
538 | chip->vendor.timeout_adjusted = true; | 537 | /* |
538 | * Provide ability for vendor overrides of timeout values in case | ||
539 | * of misreporting. | ||
540 | */ | ||
541 | if (chip->ops->update_timeouts != NULL) | ||
542 | chip->vendor.timeout_adjusted = | ||
543 | chip->ops->update_timeouts(chip, new_timeout); | ||
544 | |||
545 | if (!chip->vendor.timeout_adjusted) { | ||
546 | /* Don't overwrite default if value is 0 */ | ||
547 | if (new_timeout[0] != 0 && new_timeout[0] < 1000) { | ||
548 | int i; | ||
549 | |||
550 | /* timeouts in msec rather usec */ | ||
551 | for (i = 0; i != ARRAY_SIZE(new_timeout); i++) | ||
552 | new_timeout[i] *= 1000; | ||
553 | chip->vendor.timeout_adjusted = true; | ||
554 | } | ||
555 | } | ||
556 | |||
557 | /* Report adjusted timeouts */ | ||
558 | if (chip->vendor.timeout_adjusted) { | ||
559 | dev_info(chip->dev, | ||
560 | HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D %lu->%luus\n", | ||
561 | old_timeout[0], new_timeout[0], | ||
562 | old_timeout[1], new_timeout[1], | ||
563 | old_timeout[2], new_timeout[2], | ||
564 | old_timeout[3], new_timeout[3]); | ||
539 | } | 565 | } |
540 | if (timeout) | 566 | |
541 | chip->vendor.timeout_a = usecs_to_jiffies(timeout * scale); | 567 | chip->vendor.timeout_a = usecs_to_jiffies(new_timeout[0]); |
542 | timeout = be32_to_cpu(timeout_cap->b); | 568 | chip->vendor.timeout_b = usecs_to_jiffies(new_timeout[1]); |
543 | if (timeout) | 569 | chip->vendor.timeout_c = usecs_to_jiffies(new_timeout[2]); |
544 | chip->vendor.timeout_b = usecs_to_jiffies(timeout * scale); | 570 | chip->vendor.timeout_d = usecs_to_jiffies(new_timeout[3]); |
545 | timeout = be32_to_cpu(timeout_cap->c); | ||
546 | if (timeout) | ||
547 | chip->vendor.timeout_c = usecs_to_jiffies(timeout * scale); | ||
548 | timeout = be32_to_cpu(timeout_cap->d); | ||
549 | if (timeout) | ||
550 | chip->vendor.timeout_d = usecs_to_jiffies(timeout * scale); | ||
551 | 571 | ||
552 | duration: | 572 | duration: |
553 | tpm_cmd.header.in = tpm_getcap_header; | 573 | tpm_cmd.header.in = tpm_getcap_header; |
@@ -991,13 +1011,13 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max) | |||
991 | int err, total = 0, retries = 5; | 1011 | int err, total = 0, retries = 5; |
992 | u8 *dest = out; | 1012 | u8 *dest = out; |
993 | 1013 | ||
1014 | if (!out || !num_bytes || max > TPM_MAX_RNG_DATA) | ||
1015 | return -EINVAL; | ||
1016 | |||
994 | chip = tpm_chip_find_get(chip_num); | 1017 | chip = tpm_chip_find_get(chip_num); |
995 | if (chip == NULL) | 1018 | if (chip == NULL) |
996 | return -ENODEV; | 1019 | return -ENODEV; |
997 | 1020 | ||
998 | if (!out || !num_bytes || max > TPM_MAX_RNG_DATA) | ||
999 | return -EINVAL; | ||
1000 | |||
1001 | do { | 1021 | do { |
1002 | tpm_cmd.header.in = tpm_getrandom_header; | 1022 | tpm_cmd.header.in = tpm_getrandom_header; |
1003 | tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes); | 1023 | tpm_cmd.params.getrandom_in.num_bytes = cpu_to_be32(num_bytes); |
@@ -1016,6 +1036,7 @@ int tpm_get_random(u32 chip_num, u8 *out, size_t max) | |||
1016 | num_bytes -= recd; | 1036 | num_bytes -= recd; |
1017 | } while (retries-- && total < max); | 1037 | } while (retries-- && total < max); |
1018 | 1038 | ||
1039 | tpm_chip_put(chip); | ||
1019 | return total ? total : -EIO; | 1040 | return total ? total : -EIO; |
1020 | } | 1041 | } |
1021 | EXPORT_SYMBOL_GPL(tpm_get_random); | 1042 | EXPORT_SYMBOL_GPL(tpm_get_random); |
@@ -1095,7 +1116,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, | |||
1095 | goto del_misc; | 1116 | goto del_misc; |
1096 | 1117 | ||
1097 | if (tpm_add_ppi(&dev->kobj)) | 1118 | if (tpm_add_ppi(&dev->kobj)) |
1098 | goto del_misc; | 1119 | goto del_sysfs; |
1099 | 1120 | ||
1100 | chip->bios_dir = tpm_bios_log_setup(chip->devname); | 1121 | chip->bios_dir = tpm_bios_log_setup(chip->devname); |
1101 | 1122 | ||
@@ -1106,6 +1127,8 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, | |||
1106 | 1127 | ||
1107 | return chip; | 1128 | return chip; |
1108 | 1129 | ||
1130 | del_sysfs: | ||
1131 | tpm_sysfs_del_device(chip); | ||
1109 | del_misc: | 1132 | del_misc: |
1110 | tpm_dev_del_device(chip); | 1133 | tpm_dev_del_device(chip); |
1111 | put_device: | 1134 | put_device: |
diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c index 59f7cb28260b..3a56a131586c 100644 --- a/drivers/char/tpm/tpm_eventlog.c +++ b/drivers/char/tpm/tpm_eventlog.c | |||
@@ -235,7 +235,6 @@ static int tpm_bios_measurements_release(struct inode *inode, | |||
235 | static int tpm_ascii_bios_measurements_show(struct seq_file *m, void *v) | 235 | static int tpm_ascii_bios_measurements_show(struct seq_file *m, void *v) |
236 | { | 236 | { |
237 | int len = 0; | 237 | int len = 0; |
238 | int i; | ||
239 | char *eventname; | 238 | char *eventname; |
240 | struct tcpa_event *event = v; | 239 | struct tcpa_event *event = v; |
241 | unsigned char *event_entry = | 240 | unsigned char *event_entry = |
@@ -251,8 +250,7 @@ static int tpm_ascii_bios_measurements_show(struct seq_file *m, void *v) | |||
251 | seq_printf(m, "%2d ", event->pcr_index); | 250 | seq_printf(m, "%2d ", event->pcr_index); |
252 | 251 | ||
253 | /* 2nd: SHA1 */ | 252 | /* 2nd: SHA1 */ |
254 | for (i = 0; i < 20; i++) | 253 | seq_printf(m, "%20phN", event->pcr_value); |
255 | seq_printf(m, "%02x", event->pcr_value[i]); | ||
256 | 254 | ||
257 | /* 3rd: event type identifier */ | 255 | /* 3rd: event type identifier */ |
258 | seq_printf(m, " %02x", event->event_type); | 256 | seq_printf(m, " %02x", event->event_type); |
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index 3b7bf2162898..4669e3713428 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c | |||
@@ -714,6 +714,7 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
714 | } | 714 | } |
715 | 715 | ||
716 | tpm_get_timeouts(chip); | 716 | tpm_get_timeouts(chip); |
717 | tpm_do_selftest(chip); | ||
717 | 718 | ||
718 | dev_info(chip->dev, "TPM I2C Initialized\n"); | 719 | dev_info(chip->dev, "TPM I2C Initialized\n"); |
719 | return 0; | 720 | return 0; |
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index a9ed2270c25d..2c46734b266d 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c | |||
@@ -373,6 +373,36 @@ out_err: | |||
373 | return rc; | 373 | return rc; |
374 | } | 374 | } |
375 | 375 | ||
376 | struct tis_vendor_timeout_override { | ||
377 | u32 did_vid; | ||
378 | unsigned long timeout_us[4]; | ||
379 | }; | ||
380 | |||
381 | static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = { | ||
382 | /* Atmel 3204 */ | ||
383 | { 0x32041114, { (TIS_SHORT_TIMEOUT*1000), (TIS_LONG_TIMEOUT*1000), | ||
384 | (TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } }, | ||
385 | }; | ||
386 | |||
387 | static bool tpm_tis_update_timeouts(struct tpm_chip *chip, | ||
388 | unsigned long *timeout_cap) | ||
389 | { | ||
390 | int i; | ||
391 | u32 did_vid; | ||
392 | |||
393 | did_vid = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); | ||
394 | |||
395 | for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) { | ||
396 | if (vendor_timeout_overrides[i].did_vid != did_vid) | ||
397 | continue; | ||
398 | memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us, | ||
399 | sizeof(vendor_timeout_overrides[i].timeout_us)); | ||
400 | return true; | ||
401 | } | ||
402 | |||
403 | return false; | ||
404 | } | ||
405 | |||
376 | /* | 406 | /* |
377 | * Early probing for iTPM with STS_DATA_EXPECT flaw. | 407 | * Early probing for iTPM with STS_DATA_EXPECT flaw. |
378 | * Try sending command without itpm flag set and if that | 408 | * Try sending command without itpm flag set and if that |
@@ -437,6 +467,7 @@ static const struct tpm_class_ops tpm_tis = { | |||
437 | .recv = tpm_tis_recv, | 467 | .recv = tpm_tis_recv, |
438 | .send = tpm_tis_send, | 468 | .send = tpm_tis_send, |
439 | .cancel = tpm_tis_ready, | 469 | .cancel = tpm_tis_ready, |
470 | .update_timeouts = tpm_tis_update_timeouts, | ||
440 | .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, | 471 | .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, |
441 | .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, | 472 | .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, |
442 | .req_canceled = tpm_tis_req_canceled, | 473 | .req_canceled = tpm_tis_req_canceled, |
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index f6345f932e46..9b1a5ac4881d 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -661,6 +661,7 @@ static int hwicap_setup(struct device *dev, int id, | |||
661 | drvdata->base_address = ioremap(drvdata->mem_start, drvdata->mem_size); | 661 | drvdata->base_address = ioremap(drvdata->mem_start, drvdata->mem_size); |
662 | if (!drvdata->base_address) { | 662 | if (!drvdata->base_address) { |
663 | dev_err(dev, "ioremap() failed\n"); | 663 | dev_err(dev, "ioremap() failed\n"); |
664 | retval = -ENOMEM; | ||
664 | goto failed2; | 665 | goto failed2; |
665 | } | 666 | } |
666 | 667 | ||