aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/bsr.c18
-rw-r--r--drivers/char/hw_random/Kconfig6
-rw-r--r--drivers/char/hw_random/mxc-rnga.c4
-rw-r--r--drivers/char/hw_random/omap-rng.c386
-rw-r--r--drivers/char/hw_random/picoxcell-rng.c2
-rw-r--r--drivers/char/hw_random/tx4939-rng.c4
-rw-r--r--drivers/char/hw_random/via-rng.c7
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c1
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c2
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c77
-rw-r--r--drivers/char/pcmcia/synclink_cs.c26
-rw-r--r--drivers/char/random.c5
-rw-r--r--drivers/char/sonypi.c5
-rw-r--r--drivers/char/tile-srom.c30
-rw-r--r--drivers/char/tpm/tpm_tis.c60
-rw-r--r--drivers/char/virtio_console.c27
16 files changed, 491 insertions, 169 deletions
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 97467053a01b..0671e45daa57 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -95,6 +95,7 @@ bsr_size_show(struct device *dev, struct device_attribute *attr, char *buf)
95 struct bsr_dev *bsr_dev = dev_get_drvdata(dev); 95 struct bsr_dev *bsr_dev = dev_get_drvdata(dev);
96 return sprintf(buf, "%u\n", bsr_dev->bsr_bytes); 96 return sprintf(buf, "%u\n", bsr_dev->bsr_bytes);
97} 97}
98static DEVICE_ATTR_RO(bsr_size);
98 99
99static ssize_t 100static ssize_t
100bsr_stride_show(struct device *dev, struct device_attribute *attr, char *buf) 101bsr_stride_show(struct device *dev, struct device_attribute *attr, char *buf)
@@ -102,20 +103,23 @@ bsr_stride_show(struct device *dev, struct device_attribute *attr, char *buf)
102 struct bsr_dev *bsr_dev = dev_get_drvdata(dev); 103 struct bsr_dev *bsr_dev = dev_get_drvdata(dev);
103 return sprintf(buf, "%u\n", bsr_dev->bsr_stride); 104 return sprintf(buf, "%u\n", bsr_dev->bsr_stride);
104} 105}
106static DEVICE_ATTR_RO(bsr_stride);
105 107
106static ssize_t 108static ssize_t
107bsr_len_show(struct device *dev, struct device_attribute *attr, char *buf) 109bsr_length_show(struct device *dev, struct device_attribute *attr, char *buf)
108{ 110{
109 struct bsr_dev *bsr_dev = dev_get_drvdata(dev); 111 struct bsr_dev *bsr_dev = dev_get_drvdata(dev);
110 return sprintf(buf, "%llu\n", bsr_dev->bsr_len); 112 return sprintf(buf, "%llu\n", bsr_dev->bsr_len);
111} 113}
114static DEVICE_ATTR_RO(bsr_length);
112 115
113static struct device_attribute bsr_dev_attrs[] = { 116static struct attribute *bsr_dev_attrs[] = {
114 __ATTR(bsr_size, S_IRUGO, bsr_size_show, NULL), 117 &dev_attr_bsr_size.attr,
115 __ATTR(bsr_stride, S_IRUGO, bsr_stride_show, NULL), 118 &dev_attr_bsr_stride.attr,
116 __ATTR(bsr_length, S_IRUGO, bsr_len_show, NULL), 119 &dev_attr_bsr_length.attr,
117 __ATTR_NULL 120 NULL,
118}; 121};
122ATTRIBUTE_GROUPS(bsr_dev);
119 123
120static int bsr_mmap(struct file *filp, struct vm_area_struct *vma) 124static int bsr_mmap(struct file *filp, struct vm_area_struct *vma)
121{ 125{
@@ -308,7 +312,7 @@ static int __init bsr_init(void)
308 ret = PTR_ERR(bsr_class); 312 ret = PTR_ERR(bsr_class);
309 goto out_err_1; 313 goto out_err_1;
310 } 314 }
311 bsr_class->dev_attrs = bsr_dev_attrs; 315 bsr_class->dev_groups = bsr_dev_groups;
312 316
313 ret = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr"); 317 ret = alloc_chrdev_region(&bsr_dev, 0, BSR_MAX_DEVS, "bsr");
314 bsr_major = MAJOR(bsr_dev); 318 bsr_major = MAJOR(bsr_dev);
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 40a865449f35..0aa9d91daef5 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -153,12 +153,12 @@ config HW_RANDOM_IXP4XX
153 153
154config HW_RANDOM_OMAP 154config HW_RANDOM_OMAP
155 tristate "OMAP Random Number Generator support" 155 tristate "OMAP Random Number Generator support"
156 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP2) 156 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP2PLUS)
157 default HW_RANDOM 157 default HW_RANDOM
158 ---help--- 158 ---help---
159 This driver provides kernel-side support for the Random Number 159 This driver provides kernel-side support for the Random Number
160 Generator hardware found on OMAP16xx and OMAP24xx multimedia 160 Generator hardware found on OMAP16xx, OMAP2/3/4/5 and AM33xx/AM43xx
161 processors. 161 multimedia processors.
162 162
163 To compile this driver as a module, choose M here: the 163 To compile this driver as a module, choose M here: the
164 module will be called omap-rng. 164 module will be called omap-rng.
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c
index 19a12ac64a9e..6a86b6f56af2 100644
--- a/drivers/char/hw_random/mxc-rnga.c
+++ b/drivers/char/hw_random/mxc-rnga.c
@@ -164,7 +164,9 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
164 goto out; 164 goto out;
165 } 165 }
166 166
167 clk_prepare_enable(mxc_rng->clk); 167 err = clk_prepare_enable(mxc_rng->clk);
168 if (err)
169 goto out;
168 170
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 171 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
170 mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res); 172 mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res);
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 6843ec87b98b..9b89ff4881de 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -24,57 +24,131 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pm_runtime.h> 26#include <linux/pm_runtime.h>
27#include <linux/of.h>
28#include <linux/of_device.h>
29#include <linux/of_address.h>
30#include <linux/interrupt.h>
27 31
28#include <asm/io.h> 32#include <asm/io.h>
29 33
30#define RNG_OUT_REG 0x00 /* Output register */ 34#define RNG_REG_STATUS_RDY (1 << 0)
31#define RNG_STAT_REG 0x04 /* Status register 35
32 [0] = STAT_BUSY */ 36#define RNG_REG_INTACK_RDY_MASK (1 << 0)
33#define RNG_ALARM_REG 0x24 /* Alarm register 37#define RNG_REG_INTACK_SHUTDOWN_OFLO_MASK (1 << 1)
34 [7:0] = ALARM_COUNTER */ 38#define RNG_SHUTDOWN_OFLO_MASK (1 << 1)
35#define RNG_CONFIG_REG 0x28 /* Configuration register 39
36 [11:6] = RESET_COUNT 40#define RNG_CONTROL_STARTUP_CYCLES_SHIFT 16
37 [5:3] = RING2_DELAY 41#define RNG_CONTROL_STARTUP_CYCLES_MASK (0xffff << 16)
38 [2:0] = RING1_DELAY */ 42#define RNG_CONTROL_ENABLE_TRNG_SHIFT 10
39#define RNG_REV_REG 0x3c /* Revision register 43#define RNG_CONTROL_ENABLE_TRNG_MASK (1 << 10)
40 [7:0] = REV_NB */ 44
41#define RNG_MASK_REG 0x40 /* Mask and reset register 45#define RNG_CONFIG_MAX_REFIL_CYCLES_SHIFT 16
42 [2] = IT_EN 46#define RNG_CONFIG_MAX_REFIL_CYCLES_MASK (0xffff << 16)
43 [1] = SOFTRESET 47#define RNG_CONFIG_MIN_REFIL_CYCLES_SHIFT 0
44 [0] = AUTOIDLE */ 48#define RNG_CONFIG_MIN_REFIL_CYCLES_MASK (0xff << 0)
45#define RNG_SYSSTATUS 0x44 /* System status 49
46 [0] = RESETDONE */ 50#define RNG_CONTROL_STARTUP_CYCLES 0xff
51#define RNG_CONFIG_MIN_REFIL_CYCLES 0x21
52#define RNG_CONFIG_MAX_REFIL_CYCLES 0x22
53
54#define RNG_ALARMCNT_ALARM_TH_SHIFT 0x0
55#define RNG_ALARMCNT_ALARM_TH_MASK (0xff << 0)
56#define RNG_ALARMCNT_SHUTDOWN_TH_SHIFT 16
57#define RNG_ALARMCNT_SHUTDOWN_TH_MASK (0x1f << 16)
58#define RNG_ALARM_THRESHOLD 0xff
59#define RNG_SHUTDOWN_THRESHOLD 0x4
60
61#define RNG_REG_FROENABLE_MASK 0xffffff
62#define RNG_REG_FRODETUNE_MASK 0xffffff
63
64#define OMAP2_RNG_OUTPUT_SIZE 0x4
65#define OMAP4_RNG_OUTPUT_SIZE 0x8
66
67enum {
68 RNG_OUTPUT_L_REG = 0,
69 RNG_OUTPUT_H_REG,
70 RNG_STATUS_REG,
71 RNG_INTMASK_REG,
72 RNG_INTACK_REG,
73 RNG_CONTROL_REG,
74 RNG_CONFIG_REG,
75 RNG_ALARMCNT_REG,
76 RNG_FROENABLE_REG,
77 RNG_FRODETUNE_REG,
78 RNG_ALARMMASK_REG,
79 RNG_ALARMSTOP_REG,
80 RNG_REV_REG,
81 RNG_SYSCONFIG_REG,
82};
83
84static const u16 reg_map_omap2[] = {
85 [RNG_OUTPUT_L_REG] = 0x0,
86 [RNG_STATUS_REG] = 0x4,
87 [RNG_CONFIG_REG] = 0x28,
88 [RNG_REV_REG] = 0x3c,
89 [RNG_SYSCONFIG_REG] = 0x40,
90};
47 91
92static const u16 reg_map_omap4[] = {
93 [RNG_OUTPUT_L_REG] = 0x0,
94 [RNG_OUTPUT_H_REG] = 0x4,
95 [RNG_STATUS_REG] = 0x8,
96 [RNG_INTMASK_REG] = 0xc,
97 [RNG_INTACK_REG] = 0x10,
98 [RNG_CONTROL_REG] = 0x14,
99 [RNG_CONFIG_REG] = 0x18,
100 [RNG_ALARMCNT_REG] = 0x1c,
101 [RNG_FROENABLE_REG] = 0x20,
102 [RNG_FRODETUNE_REG] = 0x24,
103 [RNG_ALARMMASK_REG] = 0x28,
104 [RNG_ALARMSTOP_REG] = 0x2c,
105 [RNG_REV_REG] = 0x1FE0,
106 [RNG_SYSCONFIG_REG] = 0x1FE4,
107};
108
109struct omap_rng_dev;
48/** 110/**
49 * struct omap_rng_private_data - RNG IP block-specific data 111 * struct omap_rng_pdata - RNG IP block-specific data
50 * @base: virtual address of the beginning of the RNG IP block registers 112 * @regs: Pointer to the register offsets structure.
51 * @mem_res: struct resource * for the IP block registers physical memory 113 * @data_size: No. of bytes in RNG output.
114 * @data_present: Callback to determine if data is available.
115 * @init: Callback for IP specific initialization sequence.
116 * @cleanup: Callback for IP specific cleanup sequence.
52 */ 117 */
53struct omap_rng_private_data { 118struct omap_rng_pdata {
54 void __iomem *base; 119 u16 *regs;
55 struct resource *mem_res; 120 u32 data_size;
121 u32 (*data_present)(struct omap_rng_dev *priv);
122 int (*init)(struct omap_rng_dev *priv);
123 void (*cleanup)(struct omap_rng_dev *priv);
56}; 124};
57 125
58static inline u32 omap_rng_read_reg(struct omap_rng_private_data *priv, int reg) 126struct omap_rng_dev {
127 void __iomem *base;
128 struct device *dev;
129 const struct omap_rng_pdata *pdata;
130};
131
132static inline u32 omap_rng_read(struct omap_rng_dev *priv, u16 reg)
59{ 133{
60 return __raw_readl(priv->base + reg); 134 return __raw_readl(priv->base + priv->pdata->regs[reg]);
61} 135}
62 136
63static inline void omap_rng_write_reg(struct omap_rng_private_data *priv, 137static inline void omap_rng_write(struct omap_rng_dev *priv, u16 reg,
64 int reg, u32 val) 138 u32 val)
65{ 139{
66 __raw_writel(val, priv->base + reg); 140 __raw_writel(val, priv->base + priv->pdata->regs[reg]);
67} 141}
68 142
69static int omap_rng_data_present(struct hwrng *rng, int wait) 143static int omap_rng_data_present(struct hwrng *rng, int wait)
70{ 144{
71 struct omap_rng_private_data *priv; 145 struct omap_rng_dev *priv;
72 int data, i; 146 int data, i;
73 147
74 priv = (struct omap_rng_private_data *)rng->priv; 148 priv = (struct omap_rng_dev *)rng->priv;
75 149
76 for (i = 0; i < 20; i++) { 150 for (i = 0; i < 20; i++) {
77 data = omap_rng_read_reg(priv, RNG_STAT_REG) ? 0 : 1; 151 data = priv->pdata->data_present(priv);
78 if (data || !wait) 152 if (data || !wait)
79 break; 153 break;
80 /* RNG produces data fast enough (2+ MBit/sec, even 154 /* RNG produces data fast enough (2+ MBit/sec, even
@@ -89,27 +163,212 @@ static int omap_rng_data_present(struct hwrng *rng, int wait)
89 163
90static int omap_rng_data_read(struct hwrng *rng, u32 *data) 164static int omap_rng_data_read(struct hwrng *rng, u32 *data)
91{ 165{
92 struct omap_rng_private_data *priv; 166 struct omap_rng_dev *priv;
167 u32 data_size, i;
168
169 priv = (struct omap_rng_dev *)rng->priv;
170 data_size = priv->pdata->data_size;
171
172 for (i = 0; i < data_size / sizeof(u32); i++)
173 data[i] = omap_rng_read(priv, RNG_OUTPUT_L_REG + i);
174
175 if (priv->pdata->regs[RNG_INTACK_REG])
176 omap_rng_write(priv, RNG_INTACK_REG, RNG_REG_INTACK_RDY_MASK);
177 return data_size;
178}
179
180static int omap_rng_init(struct hwrng *rng)
181{
182 struct omap_rng_dev *priv;
93 183
94 priv = (struct omap_rng_private_data *)rng->priv; 184 priv = (struct omap_rng_dev *)rng->priv;
185 return priv->pdata->init(priv);
186}
95 187
96 *data = omap_rng_read_reg(priv, RNG_OUT_REG); 188static void omap_rng_cleanup(struct hwrng *rng)
189{
190 struct omap_rng_dev *priv;
97 191
98 return sizeof(u32); 192 priv = (struct omap_rng_dev *)rng->priv;
193 priv->pdata->cleanup(priv);
99} 194}
100 195
101static struct hwrng omap_rng_ops = { 196static struct hwrng omap_rng_ops = {
102 .name = "omap", 197 .name = "omap",
103 .data_present = omap_rng_data_present, 198 .data_present = omap_rng_data_present,
104 .data_read = omap_rng_data_read, 199 .data_read = omap_rng_data_read,
200 .init = omap_rng_init,
201 .cleanup = omap_rng_cleanup,
202};
203
204static inline u32 omap2_rng_data_present(struct omap_rng_dev *priv)
205{
206 return omap_rng_read(priv, RNG_STATUS_REG) ? 0 : 1;
207}
208
209static int omap2_rng_init(struct omap_rng_dev *priv)
210{
211 omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x1);
212 return 0;
213}
214
215static void omap2_rng_cleanup(struct omap_rng_dev *priv)
216{
217 omap_rng_write(priv, RNG_SYSCONFIG_REG, 0x0);
218}
219
220static struct omap_rng_pdata omap2_rng_pdata = {
221 .regs = (u16 *)reg_map_omap2,
222 .data_size = OMAP2_RNG_OUTPUT_SIZE,
223 .data_present = omap2_rng_data_present,
224 .init = omap2_rng_init,
225 .cleanup = omap2_rng_cleanup,
105}; 226};
106 227
228#if defined(CONFIG_OF)
229static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv)
230{
231 return omap_rng_read(priv, RNG_STATUS_REG) & RNG_REG_STATUS_RDY;
232}
233
234static int omap4_rng_init(struct omap_rng_dev *priv)
235{
236 u32 val;
237
238 /* Return if RNG is already running. */
239 if (omap_rng_read(priv, RNG_CONFIG_REG) & RNG_CONTROL_ENABLE_TRNG_MASK)
240 return 0;
241
242 val = RNG_CONFIG_MIN_REFIL_CYCLES << RNG_CONFIG_MIN_REFIL_CYCLES_SHIFT;
243 val |= RNG_CONFIG_MAX_REFIL_CYCLES << RNG_CONFIG_MAX_REFIL_CYCLES_SHIFT;
244 omap_rng_write(priv, RNG_CONFIG_REG, val);
245
246 omap_rng_write(priv, RNG_FRODETUNE_REG, 0x0);
247 omap_rng_write(priv, RNG_FROENABLE_REG, RNG_REG_FROENABLE_MASK);
248 val = RNG_ALARM_THRESHOLD << RNG_ALARMCNT_ALARM_TH_SHIFT;
249 val |= RNG_SHUTDOWN_THRESHOLD << RNG_ALARMCNT_SHUTDOWN_TH_SHIFT;
250 omap_rng_write(priv, RNG_ALARMCNT_REG, val);
251
252 val = RNG_CONTROL_STARTUP_CYCLES << RNG_CONTROL_STARTUP_CYCLES_SHIFT;
253 val |= RNG_CONTROL_ENABLE_TRNG_MASK;
254 omap_rng_write(priv, RNG_CONTROL_REG, val);
255
256 return 0;
257}
258
259static void omap4_rng_cleanup(struct omap_rng_dev *priv)
260{
261 int val;
262
263 val = omap_rng_read(priv, RNG_CONTROL_REG);
264 val &= ~RNG_CONTROL_ENABLE_TRNG_MASK;
265 omap_rng_write(priv, RNG_CONFIG_REG, val);
266}
267
268static irqreturn_t omap4_rng_irq(int irq, void *dev_id)
269{
270 struct omap_rng_dev *priv = dev_id;
271 u32 fro_detune, fro_enable;
272
273 /*
274 * Interrupt raised by a fro shutdown threshold, do the following:
275 * 1. Clear the alarm events.
276 * 2. De tune the FROs which are shutdown.
277 * 3. Re enable the shutdown FROs.
278 */
279 omap_rng_write(priv, RNG_ALARMMASK_REG, 0x0);
280 omap_rng_write(priv, RNG_ALARMSTOP_REG, 0x0);
281
282 fro_enable = omap_rng_read(priv, RNG_FROENABLE_REG);
283 fro_detune = ~fro_enable & RNG_REG_FRODETUNE_MASK;
284 fro_detune = fro_detune | omap_rng_read(priv, RNG_FRODETUNE_REG);
285 fro_enable = RNG_REG_FROENABLE_MASK;
286
287 omap_rng_write(priv, RNG_FRODETUNE_REG, fro_detune);
288 omap_rng_write(priv, RNG_FROENABLE_REG, fro_enable);
289
290 omap_rng_write(priv, RNG_INTACK_REG, RNG_REG_INTACK_SHUTDOWN_OFLO_MASK);
291
292 return IRQ_HANDLED;
293}
294
295static struct omap_rng_pdata omap4_rng_pdata = {
296 .regs = (u16 *)reg_map_omap4,
297 .data_size = OMAP4_RNG_OUTPUT_SIZE,
298 .data_present = omap4_rng_data_present,
299 .init = omap4_rng_init,
300 .cleanup = omap4_rng_cleanup,
301};
302
303static const struct of_device_id omap_rng_of_match[] = {
304 {
305 .compatible = "ti,omap2-rng",
306 .data = &omap2_rng_pdata,
307 },
308 {
309 .compatible = "ti,omap4-rng",
310 .data = &omap4_rng_pdata,
311 },
312 {},
313};
314MODULE_DEVICE_TABLE(of, omap_rng_of_match);
315
316static int of_get_omap_rng_device_details(struct omap_rng_dev *priv,
317 struct platform_device *pdev)
318{
319 const struct of_device_id *match;
320 struct device *dev = &pdev->dev;
321 int irq, err;
322
323 match = of_match_device(of_match_ptr(omap_rng_of_match), dev);
324 if (!match) {
325 dev_err(dev, "no compatible OF match\n");
326 return -EINVAL;
327 }
328 priv->pdata = match->data;
329
330 if (of_device_is_compatible(dev->of_node, "ti,omap4-rng")) {
331 irq = platform_get_irq(pdev, 0);
332 if (irq < 0) {
333 dev_err(dev, "%s: error getting IRQ resource - %d\n",
334 __func__, irq);
335 return irq;
336 }
337
338 err = devm_request_irq(dev, irq, omap4_rng_irq,
339 IRQF_TRIGGER_NONE, dev_name(dev), priv);
340 if (err) {
341 dev_err(dev, "unable to request irq %d, err = %d\n",
342 irq, err);
343 return err;
344 }
345 omap_rng_write(priv, RNG_INTMASK_REG, RNG_SHUTDOWN_OFLO_MASK);
346 }
347 return 0;
348}
349#else
350static int of_get_omap_rng_device_details(struct omap_rng_dev *omap_rng,
351 struct platform_device *pdev)
352{
353 return -EINVAL;
354}
355#endif
356
357static int get_omap_rng_device_details(struct omap_rng_dev *omap_rng)
358{
359 /* Only OMAP2/3 can be non-DT */
360 omap_rng->pdata = &omap2_rng_pdata;
361 return 0;
362}
363
107static int omap_rng_probe(struct platform_device *pdev) 364static int omap_rng_probe(struct platform_device *pdev)
108{ 365{
109 struct omap_rng_private_data *priv; 366 struct omap_rng_dev *priv;
367 struct resource *res;
368 struct device *dev = &pdev->dev;
110 int ret; 369 int ret;
111 370
112 priv = kzalloc(sizeof(struct omap_rng_private_data), GFP_KERNEL); 371 priv = devm_kzalloc(dev, sizeof(struct omap_rng_dev), GFP_KERNEL);
113 if (!priv) { 372 if (!priv) {
114 dev_err(&pdev->dev, "could not allocate memory\n"); 373 dev_err(&pdev->dev, "could not allocate memory\n");
115 return -ENOMEM; 374 return -ENOMEM;
@@ -117,26 +376,29 @@ static int omap_rng_probe(struct platform_device *pdev)
117 376
118 omap_rng_ops.priv = (unsigned long)priv; 377 omap_rng_ops.priv = (unsigned long)priv;
119 platform_set_drvdata(pdev, priv); 378 platform_set_drvdata(pdev, priv);
379 priv->dev = dev;
120 380
121 priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 381 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
122 priv->base = devm_ioremap_resource(&pdev->dev, priv->mem_res); 382 priv->base = devm_ioremap_resource(dev, res);
123 if (IS_ERR(priv->base)) { 383 if (IS_ERR(priv->base)) {
124 ret = PTR_ERR(priv->base); 384 ret = PTR_ERR(priv->base);
125 goto err_ioremap; 385 goto err_ioremap;
126 } 386 }
127 platform_set_drvdata(pdev, priv);
128 387
129 pm_runtime_enable(&pdev->dev); 388 pm_runtime_enable(&pdev->dev);
130 pm_runtime_get_sync(&pdev->dev); 389 pm_runtime_get_sync(&pdev->dev);
131 390
391 ret = (dev->of_node) ? of_get_omap_rng_device_details(priv, pdev) :
392 get_omap_rng_device_details(priv);
393 if (ret)
394 goto err_ioremap;
395
132 ret = hwrng_register(&omap_rng_ops); 396 ret = hwrng_register(&omap_rng_ops);
133 if (ret) 397 if (ret)
134 goto err_register; 398 goto err_register;
135 399
136 dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n", 400 dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
137 omap_rng_read_reg(priv, RNG_REV_REG)); 401 omap_rng_read(priv, RNG_REV_REG));
138
139 omap_rng_write_reg(priv, RNG_MASK_REG, 0x1);
140 402
141 return 0; 403 return 0;
142 404
@@ -144,26 +406,21 @@ err_register:
144 priv->base = NULL; 406 priv->base = NULL;
145 pm_runtime_disable(&pdev->dev); 407 pm_runtime_disable(&pdev->dev);
146err_ioremap: 408err_ioremap:
147 kfree(priv); 409 dev_err(dev, "initialization failed.\n");
148
149 return ret; 410 return ret;
150} 411}
151 412
152static int __exit omap_rng_remove(struct platform_device *pdev) 413static int __exit omap_rng_remove(struct platform_device *pdev)
153{ 414{
154 struct omap_rng_private_data *priv = platform_get_drvdata(pdev); 415 struct omap_rng_dev *priv = platform_get_drvdata(pdev);
155 416
156 hwrng_unregister(&omap_rng_ops); 417 hwrng_unregister(&omap_rng_ops);
157 418
158 omap_rng_write_reg(priv, RNG_MASK_REG, 0x0); 419 priv->pdata->cleanup(priv);
159 420
160 pm_runtime_put_sync(&pdev->dev); 421 pm_runtime_put_sync(&pdev->dev);
161 pm_runtime_disable(&pdev->dev); 422 pm_runtime_disable(&pdev->dev);
162 423
163 release_mem_region(priv->mem_res->start, resource_size(priv->mem_res));
164
165 kfree(priv);
166
167 return 0; 424 return 0;
168} 425}
169 426
@@ -171,9 +428,9 @@ static int __exit omap_rng_remove(struct platform_device *pdev)
171 428
172static int omap_rng_suspend(struct device *dev) 429static int omap_rng_suspend(struct device *dev)
173{ 430{
174 struct omap_rng_private_data *priv = dev_get_drvdata(dev); 431 struct omap_rng_dev *priv = dev_get_drvdata(dev);
175 432
176 omap_rng_write_reg(priv, RNG_MASK_REG, 0x0); 433 priv->pdata->cleanup(priv);
177 pm_runtime_put_sync(dev); 434 pm_runtime_put_sync(dev);
178 435
179 return 0; 436 return 0;
@@ -181,10 +438,10 @@ static int omap_rng_suspend(struct device *dev)
181 438
182static int omap_rng_resume(struct device *dev) 439static int omap_rng_resume(struct device *dev)
183{ 440{
184 struct omap_rng_private_data *priv = dev_get_drvdata(dev); 441 struct omap_rng_dev *priv = dev_get_drvdata(dev);
185 442
186 pm_runtime_get_sync(dev); 443 pm_runtime_get_sync(dev);
187 omap_rng_write_reg(priv, RNG_MASK_REG, 0x1); 444 priv->pdata->init(priv);
188 445
189 return 0; 446 return 0;
190} 447}
@@ -198,31 +455,18 @@ static SIMPLE_DEV_PM_OPS(omap_rng_pm, omap_rng_suspend, omap_rng_resume);
198 455
199#endif 456#endif
200 457
201/* work with hotplug and coldplug */
202MODULE_ALIAS("platform:omap_rng");
203
204static struct platform_driver omap_rng_driver = { 458static struct platform_driver omap_rng_driver = {
205 .driver = { 459 .driver = {
206 .name = "omap_rng", 460 .name = "omap_rng",
207 .owner = THIS_MODULE, 461 .owner = THIS_MODULE,
208 .pm = OMAP_RNG_PM, 462 .pm = OMAP_RNG_PM,
463 .of_match_table = of_match_ptr(omap_rng_of_match),
209 }, 464 },
210 .probe = omap_rng_probe, 465 .probe = omap_rng_probe,
211 .remove = __exit_p(omap_rng_remove), 466 .remove = __exit_p(omap_rng_remove),
212}; 467};
213 468
214static int __init omap_rng_init(void) 469module_platform_driver(omap_rng_driver);
215{ 470MODULE_ALIAS("platform:omap_rng");
216 return platform_driver_register(&omap_rng_driver);
217}
218
219static void __exit omap_rng_exit(void)
220{
221 platform_driver_unregister(&omap_rng_driver);
222}
223
224module_init(omap_rng_init);
225module_exit(omap_rng_exit);
226
227MODULE_AUTHOR("Deepak Saxena (and others)"); 471MODULE_AUTHOR("Deepak Saxena (and others)");
228MODULE_LICENSE("GPL"); 472MODULE_LICENSE("GPL");
diff --git a/drivers/char/hw_random/picoxcell-rng.c b/drivers/char/hw_random/picoxcell-rng.c
index 973b95113edf..3d4c2293c6f5 100644
--- a/drivers/char/hw_random/picoxcell-rng.c
+++ b/drivers/char/hw_random/picoxcell-rng.c
@@ -33,7 +33,7 @@
33 33
34static void __iomem *rng_base; 34static void __iomem *rng_base;
35static struct clk *rng_clk; 35static struct clk *rng_clk;
36struct device *rng_dev; 36static struct device *rng_dev;
37 37
38static inline u32 picoxcell_trng_read_csr(void) 38static inline u32 picoxcell_trng_read_csr(void)
39{ 39{
diff --git a/drivers/char/hw_random/tx4939-rng.c b/drivers/char/hw_random/tx4939-rng.c
index 00593c847cf0..09c5fbea2b93 100644
--- a/drivers/char/hw_random/tx4939-rng.c
+++ b/drivers/char/hw_random/tx4939-rng.c
@@ -110,12 +110,10 @@ static int __init tx4939_rng_probe(struct platform_device *dev)
110 struct resource *r; 110 struct resource *r;
111 int i; 111 int i;
112 112
113 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
114 if (!r)
115 return -EBUSY;
116 rngdev = devm_kzalloc(&dev->dev, sizeof(*rngdev), GFP_KERNEL); 113 rngdev = devm_kzalloc(&dev->dev, sizeof(*rngdev), GFP_KERNEL);
117 if (!rngdev) 114 if (!rngdev)
118 return -ENOMEM; 115 return -ENOMEM;
116 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
119 rngdev->base = devm_ioremap_resource(&dev->dev, r); 117 rngdev->base = devm_ioremap_resource(&dev->dev, r);
120 if (IS_ERR(rngdev->base)) 118 if (IS_ERR(rngdev->base))
121 return PTR_ERR(rngdev->base); 119 return PTR_ERR(rngdev->base);
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index d0387a84eec1..e737772ad69a 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/hw_random.h> 30#include <linux/hw_random.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <asm/cpu_device_id.h>
32#include <asm/io.h> 33#include <asm/io.h>
33#include <asm/msr.h> 34#include <asm/msr.h>
34#include <asm/cpufeature.h> 35#include <asm/cpufeature.h>
@@ -220,5 +221,11 @@ static void __exit mod_exit(void)
220module_init(mod_init); 221module_init(mod_init);
221module_exit(mod_exit); 222module_exit(mod_exit);
222 223
224static struct x86_cpu_id via_rng_cpu_id[] = {
225 X86_FEATURE_MATCH(X86_FEATURE_XSTORE),
226 {}
227};
228
223MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock"); 229MODULE_DESCRIPTION("H/W RNG driver for VIA CPU with PadLock");
224MODULE_LICENSE("GPL"); 230MODULE_LICENSE("GPL");
231MODULE_DEVICE_TABLE(x86cpu, via_rng_cpu_id);
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index d5a5f020810a..ec318bf434a6 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -810,6 +810,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
810 struct ipmi_recv __user *precv64; 810 struct ipmi_recv __user *precv64;
811 struct ipmi_recv recv64; 811 struct ipmi_recv recv64;
812 812
813 memset(&recv64, 0, sizeof(recv64));
813 if (get_compat_ipmi_recv(&recv64, compat_ptr(arg))) 814 if (get_compat_ipmi_recv(&recv64, compat_ptr(arg)))
814 return -EFAULT; 815 return -EFAULT;
815 816
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 4445fa164a2d..ec4e10fcf1a5 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1848,7 +1848,7 @@ int ipmi_request_settime(ipmi_user_t user,
1848 int retries, 1848 int retries,
1849 unsigned int retry_time_ms) 1849 unsigned int retry_time_ms)
1850{ 1850{
1851 unsigned char saddr, lun; 1851 unsigned char saddr = 0, lun = 0;
1852 int rv; 1852 int rv;
1853 1853
1854 if (!user) 1854 if (!user)
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index af4b23ffc5a6..15e4a6031934 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -71,6 +71,11 @@
71#include <linux/of_address.h> 71#include <linux/of_address.h>
72#include <linux/of_irq.h> 72#include <linux/of_irq.h>
73 73
74#ifdef CONFIG_PARISC
75#include <asm/hardware.h> /* for register_parisc_driver() stuff */
76#include <asm/parisc-device.h>
77#endif
78
74#define PFX "ipmi_si: " 79#define PFX "ipmi_si: "
75 80
76/* Measure times between events in the driver. */ 81/* Measure times between events in the driver. */
@@ -298,6 +303,9 @@ static int pci_registered;
298#ifdef CONFIG_ACPI 303#ifdef CONFIG_ACPI
299static int pnp_registered; 304static int pnp_registered;
300#endif 305#endif
306#ifdef CONFIG_PARISC
307static int parisc_registered;
308#endif
301 309
302static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; 310static unsigned int kipmid_max_busy_us[SI_MAX_PARMS];
303static int num_max_busy_us; 311static int num_max_busy_us;
@@ -2279,6 +2287,8 @@ static struct pnp_driver ipmi_pnp_driver = {
2279 .remove = ipmi_pnp_remove, 2287 .remove = ipmi_pnp_remove,
2280 .id_table = pnp_dev_table, 2288 .id_table = pnp_dev_table,
2281}; 2289};
2290
2291MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
2282#endif 2292#endif
2283 2293
2284#ifdef CONFIG_DMI 2294#ifdef CONFIG_DMI
@@ -2697,6 +2707,62 @@ static struct platform_driver ipmi_driver = {
2697 .remove = ipmi_remove, 2707 .remove = ipmi_remove,
2698}; 2708};
2699 2709
2710#ifdef CONFIG_PARISC
2711static int ipmi_parisc_probe(struct parisc_device *dev)
2712{
2713 struct smi_info *info;
2714
2715 info = smi_info_alloc();
2716
2717 if (!info) {
2718 dev_err(&dev->dev,
2719 "could not allocate memory for PARISC probe\n");
2720 return -ENOMEM;
2721 }
2722
2723 info->si_type = SI_KCS;
2724 info->addr_source = SI_DEVICETREE;
2725 info->io_setup = mem_setup;
2726 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
2727 info->io.addr_data = dev->hpa.start;
2728 info->io.regsize = 1;
2729 info->io.regspacing = 1;
2730 info->io.regshift = 0;
2731 info->irq = 0; /* no interrupt */
2732 info->irq_setup = NULL;
2733 info->dev = &dev->dev;
2734
2735 dev_dbg(&dev->dev, "addr 0x%lx\n", info->io.addr_data);
2736
2737 dev_set_drvdata(&dev->dev, info);
2738
2739 if (add_smi(info)) {
2740 kfree(info);
2741 return -EBUSY;
2742 }
2743
2744 return 0;
2745}
2746
2747static int ipmi_parisc_remove(struct parisc_device *dev)
2748{
2749 cleanup_one_si(dev_get_drvdata(&dev->dev));
2750 return 0;
2751}
2752
2753static struct parisc_device_id ipmi_parisc_tbl[] = {
2754 { HPHW_MC, HVERSION_REV_ANY_ID, 0x004, 0xC0 },
2755 { 0, }
2756};
2757
2758static struct parisc_driver ipmi_parisc_driver = {
2759 .name = "ipmi",
2760 .id_table = ipmi_parisc_tbl,
2761 .probe = ipmi_parisc_probe,
2762 .remove = ipmi_parisc_remove,
2763};
2764#endif /* CONFIG_PARISC */
2765
2700static int wait_for_msg_done(struct smi_info *smi_info) 2766static int wait_for_msg_done(struct smi_info *smi_info)
2701{ 2767{
2702 enum si_sm_result smi_result; 2768 enum si_sm_result smi_result;
@@ -3462,6 +3528,13 @@ static int init_ipmi_si(void)
3462 spmi_find_bmc(); 3528 spmi_find_bmc();
3463#endif 3529#endif
3464 3530
3531#ifdef CONFIG_PARISC
3532 register_parisc_driver(&ipmi_parisc_driver);
3533 parisc_registered = 1;
3534 /* poking PC IO addresses will crash machine, don't do it */
3535 si_trydefaults = 0;
3536#endif
3537
3465 /* We prefer devices with interrupts, but in the case of a machine 3538 /* We prefer devices with interrupts, but in the case of a machine
3466 with multiple BMCs we assume that there will be several instances 3539 with multiple BMCs we assume that there will be several instances
3467 of a given type so if we succeed in registering a type then also 3540 of a given type so if we succeed in registering a type then also
@@ -3608,6 +3681,10 @@ static void cleanup_ipmi_si(void)
3608 if (pnp_registered) 3681 if (pnp_registered)
3609 pnp_unregister_driver(&ipmi_pnp_driver); 3682 pnp_unregister_driver(&ipmi_pnp_driver);
3610#endif 3683#endif
3684#ifdef CONFIG_PARISC
3685 if (parisc_registered)
3686 unregister_parisc_driver(&ipmi_parisc_driver);
3687#endif
3611 3688
3612 platform_driver_unregister(&ipmi_driver); 3689 platform_driver_unregister(&ipmi_driver);
3613 3690
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 5c5cc00ebb07..d39cca659a3f 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -1182,14 +1182,14 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id)
1182 } 1182 }
1183 count++; 1183 count++;
1184 1184
1185 if (gis & (BIT1 + BIT0)) { 1185 if (gis & (BIT1 | BIT0)) {
1186 isr = read_reg16(info, CHB + ISR); 1186 isr = read_reg16(info, CHB + ISR);
1187 if (isr & IRQ_DCD) 1187 if (isr & IRQ_DCD)
1188 dcd_change(info, tty); 1188 dcd_change(info, tty);
1189 if (isr & IRQ_CTS) 1189 if (isr & IRQ_CTS)
1190 cts_change(info, tty); 1190 cts_change(info, tty);
1191 } 1191 }
1192 if (gis & (BIT3 + BIT2)) 1192 if (gis & (BIT3 | BIT2))
1193 { 1193 {
1194 isr = read_reg16(info, CHA + ISR); 1194 isr = read_reg16(info, CHA + ISR);
1195 if (isr & IRQ_TIMER) { 1195 if (isr & IRQ_TIMER) {
@@ -1210,7 +1210,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id)
1210 if (isr & IRQ_RXTIME) { 1210 if (isr & IRQ_RXTIME) {
1211 issue_command(info, CHA, CMD_RXFIFO_READ); 1211 issue_command(info, CHA, CMD_RXFIFO_READ);
1212 } 1212 }
1213 if (isr & (IRQ_RXEOM + IRQ_RXFIFO)) { 1213 if (isr & (IRQ_RXEOM | IRQ_RXFIFO)) {
1214 if (info->params.mode == MGSL_MODE_HDLC) 1214 if (info->params.mode == MGSL_MODE_HDLC)
1215 rx_ready_hdlc(info, isr & IRQ_RXEOM); 1215 rx_ready_hdlc(info, isr & IRQ_RXEOM);
1216 else 1216 else
@@ -3031,11 +3031,11 @@ static void loopback_enable(MGSLPC_INFO *info)
3031 unsigned char val; 3031 unsigned char val;
3032 3032
3033 /* CCR1:02..00 CM[2..0] Clock Mode = 111 (clock mode 7) */ 3033 /* CCR1:02..00 CM[2..0] Clock Mode = 111 (clock mode 7) */
3034 val = read_reg(info, CHA + CCR1) | (BIT2 + BIT1 + BIT0); 3034 val = read_reg(info, CHA + CCR1) | (BIT2 | BIT1 | BIT0);
3035 write_reg(info, CHA + CCR1, val); 3035 write_reg(info, CHA + CCR1, val);
3036 3036
3037 /* CCR2:04 SSEL Clock source select, 1=submode b */ 3037 /* CCR2:04 SSEL Clock source select, 1=submode b */
3038 val = read_reg(info, CHA + CCR2) | (BIT4 + BIT5); 3038 val = read_reg(info, CHA + CCR2) | (BIT4 | BIT5);
3039 write_reg(info, CHA + CCR2, val); 3039 write_reg(info, CHA + CCR2, val);
3040 3040
3041 /* set LinkSpeed if available, otherwise default to 2Mbps */ 3041 /* set LinkSpeed if available, otherwise default to 2Mbps */
@@ -3125,10 +3125,10 @@ static void hdlc_mode(MGSLPC_INFO *info)
3125 val |= BIT4; 3125 val |= BIT4;
3126 break; // FM0 3126 break; // FM0
3127 case HDLC_ENCODING_BIPHASE_MARK: 3127 case HDLC_ENCODING_BIPHASE_MARK:
3128 val |= BIT4 + BIT2; 3128 val |= BIT4 | BIT2;
3129 break; // FM1 3129 break; // FM1
3130 case HDLC_ENCODING_BIPHASE_LEVEL: 3130 case HDLC_ENCODING_BIPHASE_LEVEL:
3131 val |= BIT4 + BIT3; 3131 val |= BIT4 | BIT3;
3132 break; // Manchester 3132 break; // Manchester
3133 } 3133 }
3134 write_reg(info, CHA + CCR0, val); 3134 write_reg(info, CHA + CCR0, val);
@@ -3185,7 +3185,7 @@ static void hdlc_mode(MGSLPC_INFO *info)
3185 */ 3185 */
3186 val = 0x00; 3186 val = 0x00;
3187 if (info->params.crc_type == HDLC_CRC_NONE) 3187 if (info->params.crc_type == HDLC_CRC_NONE)
3188 val |= BIT2 + BIT1; 3188 val |= BIT2 | BIT1;
3189 if (info->params.preamble != HDLC_PREAMBLE_PATTERN_NONE) 3189 if (info->params.preamble != HDLC_PREAMBLE_PATTERN_NONE)
3190 val |= BIT5; 3190 val |= BIT5;
3191 switch (info->params.preamble_length) 3191 switch (info->params.preamble_length)
@@ -3197,7 +3197,7 @@ static void hdlc_mode(MGSLPC_INFO *info)
3197 val |= BIT6; 3197 val |= BIT6;
3198 break; 3198 break;
3199 case HDLC_PREAMBLE_LENGTH_64BITS: 3199 case HDLC_PREAMBLE_LENGTH_64BITS:
3200 val |= BIT7 + BIT6; 3200 val |= BIT7 | BIT6;
3201 break; 3201 break;
3202 } 3202 }
3203 write_reg(info, CHA + CCR3, val); 3203 write_reg(info, CHA + CCR3, val);
@@ -3264,8 +3264,8 @@ static void hdlc_mode(MGSLPC_INFO *info)
3264 clear_reg_bits(info, CHA + PVR, BIT3); 3264 clear_reg_bits(info, CHA + PVR, BIT3);
3265 3265
3266 irq_enable(info, CHA, 3266 irq_enable(info, CHA,
3267 IRQ_RXEOM + IRQ_RXFIFO + IRQ_ALLSENT + 3267 IRQ_RXEOM | IRQ_RXFIFO | IRQ_ALLSENT |
3268 IRQ_UNDERRUN + IRQ_TXFIFO); 3268 IRQ_UNDERRUN | IRQ_TXFIFO);
3269 issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET); 3269 issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET);
3270 wait_command_complete(info, CHA); 3270 wait_command_complete(info, CHA);
3271 read_reg16(info, CHA + ISR); /* clear pending IRQs */ 3271 read_reg16(info, CHA + ISR); /* clear pending IRQs */
@@ -3582,8 +3582,8 @@ static void async_mode(MGSLPC_INFO *info)
3582 } else 3582 } else
3583 clear_reg_bits(info, CHA + PVR, BIT3); 3583 clear_reg_bits(info, CHA + PVR, BIT3);
3584 irq_enable(info, CHA, 3584 irq_enable(info, CHA,
3585 IRQ_RXEOM + IRQ_RXFIFO + IRQ_BREAK_ON + IRQ_RXTIME + 3585 IRQ_RXEOM | IRQ_RXFIFO | IRQ_BREAK_ON | IRQ_RXTIME |
3586 IRQ_ALLSENT + IRQ_TXFIFO); 3586 IRQ_ALLSENT | IRQ_TXFIFO);
3587 issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET); 3587 issue_command(info, CHA, CMD_TXRESET + CMD_RXRESET);
3588 wait_command_complete(info, CHA); 3588 wait_command_complete(info, CHA);
3589 read_reg16(info, CHA + ISR); /* clear pending IRQs */ 3589 read_reg16(info, CHA + ISR); /* clear pending IRQs */
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0d91fe52f3f5..7737b5bd26af 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -255,10 +255,7 @@
255#include <linux/fips.h> 255#include <linux/fips.h>
256#include <linux/ptrace.h> 256#include <linux/ptrace.h>
257#include <linux/kmemcheck.h> 257#include <linux/kmemcheck.h>
258 258#include <linux/irq.h>
259#ifdef CONFIG_GENERIC_HARDIRQS
260# include <linux/irq.h>
261#endif
262 259
263#include <asm/processor.h> 260#include <asm/processor.h>
264#include <asm/uaccess.h> 261#include <asm/uaccess.h>
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index bf2349dbbf7f..7cc1fe2241fd 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -876,11 +876,6 @@ found:
876 if (useinput) 876 if (useinput)
877 sonypi_report_input_event(event); 877 sonypi_report_input_event(event);
878 878
879#ifdef CONFIG_ACPI
880 if (sonypi_acpi_device)
881 acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
882#endif
883
884 kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event, 879 kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event,
885 sizeof(event), &sonypi_device.fifo_lock); 880 sizeof(event), &sonypi_device.fifo_lock);
886 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); 881 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 7faeb1cde97d..0e506bad1986 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -279,33 +279,37 @@ loff_t srom_llseek(struct file *file, loff_t offset, int origin)
279 return fixed_size_llseek(file, offset, origin, srom->total_size); 279 return fixed_size_llseek(file, offset, origin, srom->total_size);
280} 280}
281 281
282static ssize_t total_show(struct device *dev, 282static ssize_t total_size_show(struct device *dev,
283 struct device_attribute *attr, char *buf) 283 struct device_attribute *attr, char *buf)
284{ 284{
285 struct srom_dev *srom = dev_get_drvdata(dev); 285 struct srom_dev *srom = dev_get_drvdata(dev);
286 return sprintf(buf, "%u\n", srom->total_size); 286 return sprintf(buf, "%u\n", srom->total_size);
287} 287}
288static DEVICE_ATTR_RO(total_size);
288 289
289static ssize_t sector_show(struct device *dev, 290static ssize_t sector_size_show(struct device *dev,
290 struct device_attribute *attr, char *buf) 291 struct device_attribute *attr, char *buf)
291{ 292{
292 struct srom_dev *srom = dev_get_drvdata(dev); 293 struct srom_dev *srom = dev_get_drvdata(dev);
293 return sprintf(buf, "%u\n", srom->sector_size); 294 return sprintf(buf, "%u\n", srom->sector_size);
294} 295}
296static DEVICE_ATTR_RO(sector_size);
295 297
296static ssize_t page_show(struct device *dev, 298static ssize_t page_size_show(struct device *dev,
297 struct device_attribute *attr, char *buf) 299 struct device_attribute *attr, char *buf)
298{ 300{
299 struct srom_dev *srom = dev_get_drvdata(dev); 301 struct srom_dev *srom = dev_get_drvdata(dev);
300 return sprintf(buf, "%u\n", srom->page_size); 302 return sprintf(buf, "%u\n", srom->page_size);
301} 303}
304static DEVICE_ATTR_RO(page_size);
302 305
303static struct device_attribute srom_dev_attrs[] = { 306static struct attribute *srom_dev_attrs[] = {
304 __ATTR(total_size, S_IRUGO, total_show, NULL), 307 &dev_attr_total_size.attr,
305 __ATTR(sector_size, S_IRUGO, sector_show, NULL), 308 &dev_attr_sector_size.attr,
306 __ATTR(page_size, S_IRUGO, page_show, NULL), 309 &dev_attr_page_size.attr,
307 __ATTR_NULL 310 NULL,
308}; 311};
312ATTRIBUTE_GROUPS(srom_dev);
309 313
310static char *srom_devnode(struct device *dev, umode_t *mode) 314static char *srom_devnode(struct device *dev, umode_t *mode)
311{ 315{
@@ -349,7 +353,7 @@ static int srom_setup_minor(struct srom_dev *srom, int index)
349 353
350 dev = device_create(srom_class, &platform_bus, 354 dev = device_create(srom_class, &platform_bus,
351 MKDEV(srom_major, index), srom, "%d", index); 355 MKDEV(srom_major, index), srom, "%d", index);
352 return PTR_RET(dev); 356 return PTR_ERR_OR_ZERO(dev);
353} 357}
354 358
355/** srom_init() - Initialize the driver's module. */ 359/** srom_init() - Initialize the driver's module. */
@@ -418,7 +422,7 @@ static int srom_init(void)
418 result = PTR_ERR(srom_class); 422 result = PTR_ERR(srom_class);
419 goto fail_cdev; 423 goto fail_cdev;
420 } 424 }
421 srom_class->dev_attrs = srom_dev_attrs; 425 srom_class->dev_groups = srom_dev_groups;
422 srom_class->devnode = srom_devnode; 426 srom_class->devnode = srom_devnode;
423 427
424 /* Do per-partition initialization */ 428 /* Do per-partition initialization */
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 4519cb332987..5796d0157ce0 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -766,6 +766,25 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
766} 766}
767#endif 767#endif
768 768
769#ifdef CONFIG_PM_SLEEP
770static int tpm_tis_resume(struct device *dev)
771{
772 struct tpm_chip *chip = dev_get_drvdata(dev);
773 int ret;
774
775 if (chip->vendor.irq)
776 tpm_tis_reenable_interrupts(chip);
777
778 ret = tpm_pm_resume(dev);
779 if (!ret)
780 tpm_do_selftest(chip);
781
782 return ret;
783}
784#endif
785
786static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
787
769#ifdef CONFIG_PNP 788#ifdef CONFIG_PNP
770static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev, 789static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
771 const struct pnp_device_id *pnp_id) 790 const struct pnp_device_id *pnp_id)
@@ -787,26 +806,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
787 return tpm_tis_init(&pnp_dev->dev, start, len, irq); 806 return tpm_tis_init(&pnp_dev->dev, start, len, irq);
788} 807}
789 808
790static int tpm_tis_pnp_suspend(struct pnp_dev *dev, pm_message_t msg)
791{
792 return tpm_pm_suspend(&dev->dev);
793}
794
795static int tpm_tis_pnp_resume(struct pnp_dev *dev)
796{
797 struct tpm_chip *chip = pnp_get_drvdata(dev);
798 int ret;
799
800 if (chip->vendor.irq)
801 tpm_tis_reenable_interrupts(chip);
802
803 ret = tpm_pm_resume(&dev->dev);
804 if (!ret)
805 tpm_do_selftest(chip);
806
807 return ret;
808}
809
810static struct pnp_device_id tpm_pnp_tbl[] = { 809static struct pnp_device_id tpm_pnp_tbl[] = {
811 {"PNP0C31", 0}, /* TPM */ 810 {"PNP0C31", 0}, /* TPM */
812 {"ATM1200", 0}, /* Atmel */ 811 {"ATM1200", 0}, /* Atmel */
@@ -835,9 +834,12 @@ static struct pnp_driver tis_pnp_driver = {
835 .name = "tpm_tis", 834 .name = "tpm_tis",
836 .id_table = tpm_pnp_tbl, 835 .id_table = tpm_pnp_tbl,
837 .probe = tpm_tis_pnp_init, 836 .probe = tpm_tis_pnp_init,
838 .suspend = tpm_tis_pnp_suspend,
839 .resume = tpm_tis_pnp_resume,
840 .remove = tpm_tis_pnp_remove, 837 .remove = tpm_tis_pnp_remove,
838#ifdef CONFIG_PM_SLEEP
839 .driver = {
840 .pm = &tpm_tis_pm,
841 },
842#endif
841}; 843};
842 844
843#define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2 845#define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2
@@ -846,20 +848,6 @@ module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id,
846MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); 848MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
847#endif 849#endif
848 850
849#ifdef CONFIG_PM_SLEEP
850static int tpm_tis_resume(struct device *dev)
851{
852 struct tpm_chip *chip = dev_get_drvdata(dev);
853
854 if (chip->vendor.irq)
855 tpm_tis_reenable_interrupts(chip);
856
857 return tpm_pm_resume(dev);
858}
859#endif
860
861static SIMPLE_DEV_PM_OPS(tpm_tis_pm, tpm_pm_suspend, tpm_tis_resume);
862
863static struct platform_driver tis_drv = { 851static struct platform_driver tis_drv = {
864 .driver = { 852 .driver = {
865 .name = "tpm_tis", 853 .name = "tpm_tis",
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index fc45567ad3ac..b79cf3e1b793 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1529,18 +1529,22 @@ static void remove_port_data(struct port *port)
1529{ 1529{
1530 struct port_buffer *buf; 1530 struct port_buffer *buf;
1531 1531
1532 spin_lock_irq(&port->inbuf_lock);
1532 /* Remove unused data this port might have received. */ 1533 /* Remove unused data this port might have received. */
1533 discard_port_data(port); 1534 discard_port_data(port);
1534 1535
1535 reclaim_consumed_buffers(port);
1536
1537 /* Remove buffers we queued up for the Host to send us data in. */ 1536 /* Remove buffers we queued up for the Host to send us data in. */
1538 while ((buf = virtqueue_detach_unused_buf(port->in_vq))) 1537 while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
1539 free_buf(buf, true); 1538 free_buf(buf, true);
1539 spin_unlock_irq(&port->inbuf_lock);
1540
1541 spin_lock_irq(&port->outvq_lock);
1542 reclaim_consumed_buffers(port);
1540 1543
1541 /* Free pending buffers from the out-queue. */ 1544 /* Free pending buffers from the out-queue. */
1542 while ((buf = virtqueue_detach_unused_buf(port->out_vq))) 1545 while ((buf = virtqueue_detach_unused_buf(port->out_vq)))
1543 free_buf(buf, true); 1546 free_buf(buf, true);
1547 spin_unlock_irq(&port->outvq_lock);
1544} 1548}
1545 1549
1546/* 1550/*
@@ -1554,6 +1558,7 @@ static void unplug_port(struct port *port)
1554 list_del(&port->list); 1558 list_del(&port->list);
1555 spin_unlock_irq(&port->portdev->ports_lock); 1559 spin_unlock_irq(&port->portdev->ports_lock);
1556 1560
1561 spin_lock_irq(&port->inbuf_lock);
1557 if (port->guest_connected) { 1562 if (port->guest_connected) {
1558 /* Let the app know the port is going down. */ 1563 /* Let the app know the port is going down. */
1559 send_sigio_to_port(port); 1564 send_sigio_to_port(port);
@@ -1564,6 +1569,7 @@ static void unplug_port(struct port *port)
1564 1569
1565 wake_up_interruptible(&port->waitqueue); 1570 wake_up_interruptible(&port->waitqueue);
1566 } 1571 }
1572 spin_unlock_irq(&port->inbuf_lock);
1567 1573
1568 if (is_console_port(port)) { 1574 if (is_console_port(port)) {
1569 spin_lock_irq(&pdrvdata_lock); 1575 spin_lock_irq(&pdrvdata_lock);
@@ -1585,9 +1591,8 @@ static void unplug_port(struct port *port)
1585 device_destroy(pdrvdata.class, port->dev->devt); 1591 device_destroy(pdrvdata.class, port->dev->devt);
1586 cdev_del(port->cdev); 1592 cdev_del(port->cdev);
1587 1593
1588 kfree(port->name);
1589
1590 debugfs_remove(port->debugfs_file); 1594 debugfs_remove(port->debugfs_file);
1595 kfree(port->name);
1591 1596
1592 /* 1597 /*
1593 * Locks around here are not necessary - a port can't be 1598 * Locks around here are not necessary - a port can't be
@@ -1681,7 +1686,9 @@ static void handle_control_message(struct ports_device *portdev,
1681 * If the guest is connected, it'll be interested in 1686 * If the guest is connected, it'll be interested in
1682 * knowing the host connection state changed. 1687 * knowing the host connection state changed.
1683 */ 1688 */
1689 spin_lock_irq(&port->inbuf_lock);
1684 send_sigio_to_port(port); 1690 send_sigio_to_port(port);
1691 spin_unlock_irq(&port->inbuf_lock);
1685 break; 1692 break;
1686 case VIRTIO_CONSOLE_PORT_NAME: 1693 case VIRTIO_CONSOLE_PORT_NAME:
1687 /* 1694 /*
@@ -1801,13 +1808,13 @@ static void in_intr(struct virtqueue *vq)
1801 if (!port->guest_connected && !is_rproc_serial(port->portdev->vdev)) 1808 if (!port->guest_connected && !is_rproc_serial(port->portdev->vdev))
1802 discard_port_data(port); 1809 discard_port_data(port);
1803 1810
1811 /* Send a SIGIO indicating new data in case the process asked for it */
1812 send_sigio_to_port(port);
1813
1804 spin_unlock_irqrestore(&port->inbuf_lock, flags); 1814 spin_unlock_irqrestore(&port->inbuf_lock, flags);
1805 1815
1806 wake_up_interruptible(&port->waitqueue); 1816 wake_up_interruptible(&port->waitqueue);
1807 1817
1808 /* Send a SIGIO indicating new data in case the process asked for it */
1809 send_sigio_to_port(port);
1810
1811 if (is_console_port(port) && hvc_poll(port->cons.hvc)) 1818 if (is_console_port(port) && hvc_poll(port->cons.hvc))
1812 hvc_kick(); 1819 hvc_kick();
1813} 1820}
@@ -2241,10 +2248,8 @@ static int __init init(void)
2241 } 2248 }
2242 2249
2243 pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL); 2250 pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL);
2244 if (!pdrvdata.debugfs_dir) { 2251 if (!pdrvdata.debugfs_dir)
2245 pr_warning("Error %ld creating debugfs dir for virtio-ports\n", 2252 pr_warning("Error creating debugfs dir for virtio-ports\n");
2246 PTR_ERR(pdrvdata.debugfs_dir));
2247 }
2248 INIT_LIST_HEAD(&pdrvdata.consoles); 2253 INIT_LIST_HEAD(&pdrvdata.consoles);
2249 INIT_LIST_HEAD(&pdrvdata.portdevs); 2254 INIT_LIST_HEAD(&pdrvdata.portdevs);
2250 2255