aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-26 21:40:19 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-26 21:40:19 -0400
commitf35c69b736e4f910d7447346980145212c283570 (patch)
tree824b90cd870e6de07bbba19d761c1c74cf1fb4a7 /drivers/char
parentcd4373984a5903276f52777a6003425e023eaa7e (diff)
parente4aa937ec75df0eea0bee03bffa3303ad36c986b (diff)
Merge 3.10-rc3 into char-misc-next
We want the changes in here. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/mxc-rnga.c6
-rw-r--r--drivers/char/hw_random/omap-rng.c5
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c4
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c14
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c3
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c16
-rw-r--r--drivers/char/lp.c3
-rw-r--r--drivers/char/random.c54
-rw-r--r--drivers/char/ttyprintk.c2
9 files changed, 61 insertions, 46 deletions
diff --git a/drivers/char/hw_random/mxc-rnga.c b/drivers/char/hw_random/mxc-rnga.c
index 4ca35e8a5d8c..19a12ac64a9e 100644
--- a/drivers/char/hw_random/mxc-rnga.c
+++ b/drivers/char/hw_random/mxc-rnga.c
@@ -167,11 +167,6 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
167 clk_prepare_enable(mxc_rng->clk); 167 clk_prepare_enable(mxc_rng->clk);
168 168
169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
170 if (!res) {
171 err = -ENOENT;
172 goto err_region;
173 }
174
175 mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res); 170 mxc_rng->mem = devm_ioremap_resource(&pdev->dev, res);
176 if (IS_ERR(mxc_rng->mem)) { 171 if (IS_ERR(mxc_rng->mem)) {
177 err = PTR_ERR(mxc_rng->mem); 172 err = PTR_ERR(mxc_rng->mem);
@@ -189,7 +184,6 @@ static int __init mxc_rnga_probe(struct platform_device *pdev)
189 return 0; 184 return 0;
190 185
191err_ioremap: 186err_ioremap:
192err_region:
193 clk_disable_unprepare(mxc_rng->clk); 187 clk_disable_unprepare(mxc_rng->clk);
194 188
195out: 189out:
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c
index 749dc16ca2cc..d2903e772270 100644
--- a/drivers/char/hw_random/omap-rng.c
+++ b/drivers/char/hw_random/omap-rng.c
@@ -119,11 +119,6 @@ static int omap_rng_probe(struct platform_device *pdev)
119 dev_set_drvdata(&pdev->dev, priv); 119 dev_set_drvdata(&pdev->dev, priv);
120 120
121 priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 121 priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
122 if (!priv->mem_res) {
123 ret = -ENOENT;
124 goto err_ioremap;
125 }
126
127 priv->base = devm_ioremap_resource(&pdev->dev, priv->mem_res); 122 priv->base = devm_ioremap_resource(&pdev->dev, priv->mem_res);
128 if (IS_ERR(priv->base)) { 123 if (IS_ERR(priv->base)) {
129 ret = PTR_ERR(priv->base); 124 ret = PTR_ERR(priv->base);
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index cdd4c09fda96..a22a7a502740 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -95,9 +95,9 @@ struct si_sm_data {
95 enum bt_states state; 95 enum bt_states state;
96 unsigned char seq; /* BT sequence number */ 96 unsigned char seq; /* BT sequence number */
97 struct si_sm_io *io; 97 struct si_sm_io *io;
98 unsigned char write_data[IPMI_MAX_MSG_LENGTH]; 98 unsigned char write_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
99 int write_count; 99 int write_count;
100 unsigned char read_data[IPMI_MAX_MSG_LENGTH]; 100 unsigned char read_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
101 int read_count; 101 int read_count;
102 int truncated; 102 int truncated;
103 long timeout; /* microseconds countdown */ 103 long timeout; /* microseconds countdown */
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 9eb360ff8cab..d5a5f020810a 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -837,13 +837,25 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
837 return ipmi_ioctl(filep, cmd, arg); 837 return ipmi_ioctl(filep, cmd, arg);
838 } 838 }
839} 839}
840
841static long unlocked_compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
842 unsigned long arg)
843{
844 int ret;
845
846 mutex_lock(&ipmi_mutex);
847 ret = compat_ipmi_ioctl(filep, cmd, arg);
848 mutex_unlock(&ipmi_mutex);
849
850 return ret;
851}
840#endif 852#endif
841 853
842static const struct file_operations ipmi_fops = { 854static const struct file_operations ipmi_fops = {
843 .owner = THIS_MODULE, 855 .owner = THIS_MODULE,
844 .unlocked_ioctl = ipmi_unlocked_ioctl, 856 .unlocked_ioctl = ipmi_unlocked_ioctl,
845#ifdef CONFIG_COMPAT 857#ifdef CONFIG_COMPAT
846 .compat_ioctl = compat_ipmi_ioctl, 858 .compat_ioctl = unlocked_compat_ipmi_ioctl,
847#endif 859#endif
848 .open = ipmi_open, 860 .open = ipmi_open,
849 .release = ipmi_release, 861 .release = ipmi_release,
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 4d439d2fcfd6..4445fa164a2d 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2037,12 +2037,11 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
2037 entry = kmalloc(sizeof(*entry), GFP_KERNEL); 2037 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
2038 if (!entry) 2038 if (!entry)
2039 return -ENOMEM; 2039 return -ENOMEM;
2040 entry->name = kmalloc(strlen(name)+1, GFP_KERNEL); 2040 entry->name = kstrdup(name, GFP_KERNEL);
2041 if (!entry->name) { 2041 if (!entry->name) {
2042 kfree(entry); 2042 kfree(entry);
2043 return -ENOMEM; 2043 return -ENOMEM;
2044 } 2044 }
2045 strcpy(entry->name, name);
2046 2045
2047 file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data); 2046 file = proc_create_data(name, 0, smi->proc_dir, proc_ops, data);
2048 if (!file) { 2047 if (!file) {
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 313538abe63c..af4b23ffc5a6 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -663,8 +663,10 @@ static void handle_transaction_done(struct smi_info *smi_info)
663 /* We got the flags from the SMI, now handle them. */ 663 /* We got the flags from the SMI, now handle them. */
664 smi_info->handlers->get_result(smi_info->si_sm, msg, 4); 664 smi_info->handlers->get_result(smi_info->si_sm, msg, 4);
665 if (msg[2] != 0) { 665 if (msg[2] != 0) {
666 dev_warn(smi_info->dev, "Could not enable interrupts" 666 dev_warn(smi_info->dev,
667 ", failed get, using polled mode.\n"); 667 "Couldn't get irq info: %x.\n", msg[2]);
668 dev_warn(smi_info->dev,
669 "Maybe ok, but ipmi might run very slowly.\n");
668 smi_info->si_state = SI_NORMAL; 670 smi_info->si_state = SI_NORMAL;
669 } else { 671 } else {
670 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 672 msg[0] = (IPMI_NETFN_APP_REQUEST << 2);
@@ -685,10 +687,12 @@ static void handle_transaction_done(struct smi_info *smi_info)
685 687
686 /* We got the flags from the SMI, now handle them. */ 688 /* We got the flags from the SMI, now handle them. */
687 smi_info->handlers->get_result(smi_info->si_sm, msg, 4); 689 smi_info->handlers->get_result(smi_info->si_sm, msg, 4);
688 if (msg[2] != 0) 690 if (msg[2] != 0) {
689 dev_warn(smi_info->dev, "Could not enable interrupts" 691 dev_warn(smi_info->dev,
690 ", failed set, using polled mode.\n"); 692 "Couldn't set irq info: %x.\n", msg[2]);
691 else 693 dev_warn(smi_info->dev,
694 "Maybe ok, but ipmi might run very slowly.\n");
695 } else
692 smi_info->interrupt_disabled = 0; 696 smi_info->interrupt_disabled = 0;
693 smi_info->si_state = SI_NORMAL; 697 smi_info->si_state = SI_NORMAL;
694 break; 698 break;
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index dafd9ac6428f..0913d79424d3 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -622,9 +622,12 @@ static int lp_do_ioctl(unsigned int minor, unsigned int cmd,
622 return -EFAULT; 622 return -EFAULT;
623 break; 623 break;
624 case LPGETSTATUS: 624 case LPGETSTATUS:
625 if (mutex_lock_interruptible(&lp_table[minor].port_mutex))
626 return -EINTR;
625 lp_claim_parport_or_block (&lp_table[minor]); 627 lp_claim_parport_or_block (&lp_table[minor]);
626 status = r_str(minor); 628 status = r_str(minor);
627 lp_release_parport (&lp_table[minor]); 629 lp_release_parport (&lp_table[minor]);
630 mutex_unlock(&lp_table[minor].port_mutex);
628 631
629 if (copy_to_user(argp, &status, sizeof(int))) 632 if (copy_to_user(argp, &status, sizeof(int)))
630 return -EFAULT; 633 return -EFAULT;
diff --git a/drivers/char/random.c b/drivers/char/random.c
index cd9a6211dcad..35487e8ded59 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -865,16 +865,24 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
865 if (r->entropy_count / 8 < min + reserved) { 865 if (r->entropy_count / 8 < min + reserved) {
866 nbytes = 0; 866 nbytes = 0;
867 } else { 867 } else {
868 int entropy_count, orig;
869retry:
870 entropy_count = orig = ACCESS_ONCE(r->entropy_count);
868 /* If limited, never pull more than available */ 871 /* If limited, never pull more than available */
869 if (r->limit && nbytes + reserved >= r->entropy_count / 8) 872 if (r->limit && nbytes + reserved >= entropy_count / 8)
870 nbytes = r->entropy_count/8 - reserved; 873 nbytes = entropy_count/8 - reserved;
871 874
872 if (r->entropy_count / 8 >= nbytes + reserved) 875 if (entropy_count / 8 >= nbytes + reserved) {
873 r->entropy_count -= nbytes*8; 876 entropy_count -= nbytes*8;
874 else 877 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
875 r->entropy_count = reserved; 878 goto retry;
879 } else {
880 entropy_count = reserved;
881 if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig)
882 goto retry;
883 }
876 884
877 if (r->entropy_count < random_write_wakeup_thresh) 885 if (entropy_count < random_write_wakeup_thresh)
878 wakeup_write = 1; 886 wakeup_write = 1;
879 } 887 }
880 888
@@ -957,10 +965,23 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
957{ 965{
958 ssize_t ret = 0, i; 966 ssize_t ret = 0, i;
959 __u8 tmp[EXTRACT_SIZE]; 967 __u8 tmp[EXTRACT_SIZE];
968 unsigned long flags;
960 969
961 /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */ 970 /* if last_data isn't primed, we need EXTRACT_SIZE extra bytes */
962 if (fips_enabled && !r->last_data_init) 971 if (fips_enabled) {
963 nbytes += EXTRACT_SIZE; 972 spin_lock_irqsave(&r->lock, flags);
973 if (!r->last_data_init) {
974 r->last_data_init = true;
975 spin_unlock_irqrestore(&r->lock, flags);
976 trace_extract_entropy(r->name, EXTRACT_SIZE,
977 r->entropy_count, _RET_IP_);
978 xfer_secondary_pool(r, EXTRACT_SIZE);
979 extract_buf(r, tmp);
980 spin_lock_irqsave(&r->lock, flags);
981 memcpy(r->last_data, tmp, EXTRACT_SIZE);
982 }
983 spin_unlock_irqrestore(&r->lock, flags);
984 }
964 985
965 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_); 986 trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_);
966 xfer_secondary_pool(r, nbytes); 987 xfer_secondary_pool(r, nbytes);
@@ -970,19 +991,6 @@ static ssize_t extract_entropy(struct entropy_store *r, void *buf,
970 extract_buf(r, tmp); 991 extract_buf(r, tmp);
971 992
972 if (fips_enabled) { 993 if (fips_enabled) {
973 unsigned long flags;
974
975
976 /* prime last_data value if need be, per fips 140-2 */
977 if (!r->last_data_init) {
978 spin_lock_irqsave(&r->lock, flags);
979 memcpy(r->last_data, tmp, EXTRACT_SIZE);
980 r->last_data_init = true;
981 nbytes -= EXTRACT_SIZE;
982 spin_unlock_irqrestore(&r->lock, flags);
983 extract_buf(r, tmp);
984 }
985
986 spin_lock_irqsave(&r->lock, flags); 994 spin_lock_irqsave(&r->lock, flags);
987 if (!memcmp(tmp, r->last_data, EXTRACT_SIZE)) 995 if (!memcmp(tmp, r->last_data, EXTRACT_SIZE))
988 panic("Hardware RNG duplicated output!\n"); 996 panic("Hardware RNG duplicated output!\n");
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 4945bd3d18d0..d5d2e4a985aa 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -179,7 +179,6 @@ static int __init ttyprintk_init(void)
179{ 179{
180 int ret = -ENOMEM; 180 int ret = -ENOMEM;
181 181
182 tpk_port.port.ops = &null_ops;
183 mutex_init(&tpk_port.port_write_mutex); 182 mutex_init(&tpk_port.port_write_mutex);
184 183
185 ttyprintk_driver = tty_alloc_driver(1, 184 ttyprintk_driver = tty_alloc_driver(1,
@@ -190,6 +189,7 @@ static int __init ttyprintk_init(void)
190 return PTR_ERR(ttyprintk_driver); 189 return PTR_ERR(ttyprintk_driver);
191 190
192 tty_port_init(&tpk_port.port); 191 tty_port_init(&tpk_port.port);
192 tpk_port.port.ops = &null_ops;
193 193
194 ttyprintk_driver->driver_name = "ttyprintk"; 194 ttyprintk_driver->driver_name = "ttyprintk";
195 ttyprintk_driver->name = "ttyprintk"; 195 ttyprintk_driver->name = "ttyprintk";