aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/Kconfig9
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/cs5535_gpio.c259
-rw-r--r--drivers/char/hw_random/via-rng.c10
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c27
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c23
-rw-r--r--drivers/char/ramoops.c13
-rw-r--r--drivers/char/raw.c14
8 files changed, 64 insertions, 292 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index d4a7776f4b77..0f175a866ef0 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1047,15 +1047,6 @@ config NSC_GPIO
1047 pc8736x_gpio drivers. If those drivers are built as 1047 pc8736x_gpio drivers. If those drivers are built as
1048 modules, this one will be too, named nsc_gpio 1048 modules, this one will be too, named nsc_gpio
1049 1049
1050config CS5535_GPIO
1051 tristate "AMD CS5535/CS5536 GPIO (Geode Companion Device)"
1052 depends on X86_32
1053 help
1054 Give userspace access to the GPIO pins on the AMD CS5535 and
1055 CS5536 Geode companion devices.
1056
1057 If compiled as a module, it will be called cs5535_gpio.
1058
1059config RAW_DRIVER 1050config RAW_DRIVER
1060 tristate "RAW driver (/dev/raw/rawN)" 1051 tristate "RAW driver (/dev/raw/rawN)"
1061 depends on BLOCK 1052 depends on BLOCK
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index fa0b824b7a65..1e9dffb33778 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -82,7 +82,6 @@ obj-$(CONFIG_NWFLASH) += nwflash.o
82obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o 82obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
83obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o 83obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o
84obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o 84obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o
85obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
86obj-$(CONFIG_GPIO_TB0219) += tb0219.o 85obj-$(CONFIG_GPIO_TB0219) += tb0219.o
87obj-$(CONFIG_TELCLOCK) += tlclk.o 86obj-$(CONFIG_TELCLOCK) += tlclk.o
88 87
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c
deleted file mode 100644
index 0cf1e5fad9ab..000000000000
--- a/drivers/char/cs5535_gpio.c
+++ /dev/null
@@ -1,259 +0,0 @@
1/*
2 * AMD CS5535/CS5536 GPIO driver.
3 * Allows a user space process to play with the GPIO pins.
4 *
5 * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the smems of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 */
11
12#include <linux/fs.h>
13#include <linux/module.h>
14#include <linux/errno.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/cdev.h>
18#include <linux/ioport.h>
19#include <linux/pci.h>
20
21#include <asm/uaccess.h>
22#include <asm/io.h>
23
24
25#define NAME "cs5535_gpio"
26
27MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
28MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO Pin Driver");
29MODULE_LICENSE("GPL");
30
31static int major;
32module_param(major, int, 0);
33MODULE_PARM_DESC(major, "Major device number");
34
35static ulong mask;
36module_param(mask, ulong, 0);
37MODULE_PARM_DESC(mask, "GPIO channel mask");
38
39#define MSR_LBAR_GPIO 0x5140000C
40
41static u32 gpio_base;
42
43static struct pci_device_id divil_pci[] = {
44 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) },
45 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) },
46 { } /* NULL entry */
47};
48MODULE_DEVICE_TABLE(pci, divil_pci);
49
50static struct cdev cs5535_gpio_cdev;
51
52/* reserve 32 entries even though some aren't usable */
53#define CS5535_GPIO_COUNT 32
54
55/* IO block size */
56#define CS5535_GPIO_SIZE 256
57
58struct gpio_regmap {
59 u32 rd_offset;
60 u32 wr_offset;
61 char on;
62 char off;
63};
64static struct gpio_regmap rm[] =
65{
66 { 0x30, 0x00, '1', '0' }, /* GPIOx_READ_BACK / GPIOx_OUT_VAL */
67 { 0x20, 0x20, 'I', 'i' }, /* GPIOx_IN_EN */
68 { 0x04, 0x04, 'O', 'o' }, /* GPIOx_OUT_EN */
69 { 0x08, 0x08, 't', 'T' }, /* GPIOx_OUT_OD_EN */
70 { 0x18, 0x18, 'P', 'p' }, /* GPIOx_OUT_PU_EN */
71 { 0x1c, 0x1c, 'D', 'd' }, /* GPIOx_OUT_PD_EN */
72};
73
74
75/**
76 * Gets the register offset for the GPIO bank.
77 * Low (0-15) starts at 0x00, high (16-31) starts at 0x80
78 */
79static inline u32 cs5535_lowhigh_base(int reg)
80{
81 return (reg & 0x10) << 3;
82}
83
84static ssize_t cs5535_gpio_write(struct file *file, const char __user *data,
85 size_t len, loff_t *ppos)
86{
87 u32 m = iminor(file->f_path.dentry->d_inode);
88 int i, j;
89 u32 base = gpio_base + cs5535_lowhigh_base(m);
90 u32 m0, m1;
91 char c;
92
93 /**
94 * Creates the mask for atomic bit programming.
95 * The high 16 bits and the low 16 bits are used to set the mask.
96 * For example, GPIO 15 maps to 31,15: 0,1 => On; 1,0=> Off
97 */
98 m1 = 1 << (m & 0x0F);
99 m0 = m1 << 16;
100
101 for (i = 0; i < len; ++i) {
102 if (get_user(c, data+i))
103 return -EFAULT;
104
105 for (j = 0; j < ARRAY_SIZE(rm); j++) {
106 if (c == rm[j].on) {
107 outl(m1, base + rm[j].wr_offset);
108 /* If enabling output, turn off AUX 1 and AUX 2 */
109 if (c == 'O') {
110 outl(m0, base + 0x10);
111 outl(m0, base + 0x14);
112 }
113 break;
114 } else if (c == rm[j].off) {
115 outl(m0, base + rm[j].wr_offset);
116 break;
117 }
118 }
119 }
120 *ppos = 0;
121 return len;
122}
123
124static ssize_t cs5535_gpio_read(struct file *file, char __user *buf,
125 size_t len, loff_t *ppos)
126{
127 u32 m = iminor(file->f_path.dentry->d_inode);
128 u32 base = gpio_base + cs5535_lowhigh_base(m);
129 int rd_bit = 1 << (m & 0x0f);
130 int i;
131 char ch;
132 ssize_t count = 0;
133
134 if (*ppos >= ARRAY_SIZE(rm))
135 return 0;
136
137 for (i = *ppos; (i < (*ppos + len)) && (i < ARRAY_SIZE(rm)); i++) {
138 ch = (inl(base + rm[i].rd_offset) & rd_bit) ?
139 rm[i].on : rm[i].off;
140
141 if (put_user(ch, buf+count))
142 return -EFAULT;
143
144 count++;
145 }
146
147 /* add a line-feed if there is room */
148 if ((i == ARRAY_SIZE(rm)) && (count < len)) {
149 put_user('\n', buf + count);
150 count++;
151 }
152
153 *ppos += count;
154 return count;
155}
156
157static int cs5535_gpio_open(struct inode *inode, struct file *file)
158{
159 u32 m = iminor(inode);
160
161 /* the mask says which pins are usable by this driver */
162 if ((mask & (1 << m)) == 0)
163 return -EINVAL;
164
165 return nonseekable_open(inode, file);
166}
167
168static const struct file_operations cs5535_gpio_fops = {
169 .owner = THIS_MODULE,
170 .write = cs5535_gpio_write,
171 .read = cs5535_gpio_read,
172 .open = cs5535_gpio_open,
173 .llseek = no_llseek,
174};
175
176static int __init cs5535_gpio_init(void)
177{
178 dev_t dev_id;
179 u32 low, hi;
180 int retval;
181
182 if (pci_dev_present(divil_pci) == 0) {
183 printk(KERN_WARNING NAME ": DIVIL not found\n");
184 return -ENODEV;
185 }
186
187 /* Grab the GPIO I/O range */
188 rdmsr(MSR_LBAR_GPIO, low, hi);
189
190 /* Check the mask and whether GPIO is enabled (sanity check) */
191 if (hi != 0x0000f001) {
192 printk(KERN_WARNING NAME ": GPIO not enabled\n");
193 return -ENODEV;
194 }
195
196 /* Mask off the IO base address */
197 gpio_base = low & 0x0000ff00;
198
199 /**
200 * Some GPIO pins
201 * 31-29,23 : reserved (always mask out)
202 * 28 : Power Button
203 * 26 : PME#
204 * 22-16 : LPC
205 * 14,15 : SMBus
206 * 9,8 : UART1
207 * 7 : PCI INTB
208 * 3,4 : UART2/DDC
209 * 2 : IDE_IRQ0
210 * 0 : PCI INTA
211 *
212 * If a mask was not specified, be conservative and only allow:
213 * 1,2,5,6,10-13,24,25,27
214 */
215 if (mask != 0)
216 mask &= 0x1f7fffff;
217 else
218 mask = 0x0b003c66;
219
220 if (!request_region(gpio_base, CS5535_GPIO_SIZE, NAME)) {
221 printk(KERN_ERR NAME ": can't allocate I/O for GPIO\n");
222 return -ENODEV;
223 }
224
225 if (major) {
226 dev_id = MKDEV(major, 0);
227 retval = register_chrdev_region(dev_id, CS5535_GPIO_COUNT,
228 NAME);
229 } else {
230 retval = alloc_chrdev_region(&dev_id, 0, CS5535_GPIO_COUNT,
231 NAME);
232 major = MAJOR(dev_id);
233 }
234
235 if (retval) {
236 release_region(gpio_base, CS5535_GPIO_SIZE);
237 return -1;
238 }
239
240 printk(KERN_DEBUG NAME ": base=%#x mask=%#lx major=%d\n",
241 gpio_base, mask, major);
242
243 cdev_init(&cs5535_gpio_cdev, &cs5535_gpio_fops);
244 cdev_add(&cs5535_gpio_cdev, dev_id, CS5535_GPIO_COUNT);
245
246 return 0;
247}
248
249static void __exit cs5535_gpio_cleanup(void)
250{
251 dev_t dev_id = MKDEV(major, 0);
252
253 cdev_del(&cs5535_gpio_cdev);
254 unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT);
255 release_region(gpio_base, CS5535_GPIO_SIZE);
256}
257
258module_init(cs5535_gpio_init);
259module_exit(cs5535_gpio_cleanup);
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index 794aacb715c1..d0387a84eec1 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -24,6 +24,7 @@
24 * warranty of any kind, whether express or implied. 24 * warranty of any kind, whether express or implied.
25 */ 25 */
26 26
27#include <crypto/padlock.h>
27#include <linux/module.h> 28#include <linux/module.h>
28#include <linux/kernel.h> 29#include <linux/kernel.h>
29#include <linux/hw_random.h> 30#include <linux/hw_random.h>
@@ -34,7 +35,6 @@
34#include <asm/i387.h> 35#include <asm/i387.h>
35 36
36 37
37#define PFX KBUILD_MODNAME ": "
38 38
39 39
40enum { 40enum {
@@ -81,8 +81,7 @@ static inline u32 xstore(u32 *addr, u32 edx_in)
81 ts_state = irq_ts_save(); 81 ts_state = irq_ts_save();
82 82
83 asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */" 83 asm(".byte 0x0F,0xA7,0xC0 /* xstore %%edi (addr=%0) */"
84 :"=m"(*addr), "=a"(eax_out) 84 : "=m" (*addr), "=a" (eax_out), "+d" (edx_in), "+D" (addr));
85 :"D"(addr), "d"(edx_in));
86 85
87 irq_ts_restore(ts_state); 86 irq_ts_restore(ts_state);
88 return eax_out; 87 return eax_out;
@@ -90,8 +89,10 @@ static inline u32 xstore(u32 *addr, u32 edx_in)
90 89
91static int via_rng_data_present(struct hwrng *rng, int wait) 90static int via_rng_data_present(struct hwrng *rng, int wait)
92{ 91{
92 char buf[16 + PADLOCK_ALIGNMENT - STACK_ALIGN] __attribute__
93 ((aligned(STACK_ALIGN)));
94 u32 *via_rng_datum = (u32 *)PTR_ALIGN(&buf[0], PADLOCK_ALIGNMENT);
93 u32 bytes_out; 95 u32 bytes_out;
94 u32 *via_rng_datum = (u32 *)(&rng->priv);
95 int i; 96 int i;
96 97
97 /* We choose the recommended 1-byte-per-instruction RNG rate, 98 /* We choose the recommended 1-byte-per-instruction RNG rate,
@@ -115,6 +116,7 @@ static int via_rng_data_present(struct hwrng *rng, int wait)
115 break; 116 break;
116 udelay(10); 117 udelay(10);
117 } 118 }
119 rng->priv = *via_rng_datum;
118 return bytes_out ? 1 : 0; 120 return bytes_out ? 1 : 0;
119} 121}
120 122
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 2fe72f8edf44..38223e93aa98 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -970,6 +970,33 @@ out_kfree:
970} 970}
971EXPORT_SYMBOL(ipmi_create_user); 971EXPORT_SYMBOL(ipmi_create_user);
972 972
973int ipmi_get_smi_info(int if_num, struct ipmi_smi_info *data)
974{
975 int rv = 0;
976 ipmi_smi_t intf;
977 struct ipmi_smi_handlers *handlers;
978
979 mutex_lock(&ipmi_interfaces_mutex);
980 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
981 if (intf->intf_num == if_num)
982 goto found;
983 }
984 /* Not found, return an error */
985 rv = -EINVAL;
986 mutex_unlock(&ipmi_interfaces_mutex);
987 return rv;
988
989found:
990 handlers = intf->handlers;
991 rv = -ENOSYS;
992 if (handlers->get_smi_info)
993 rv = handlers->get_smi_info(intf->send_info, data);
994 mutex_unlock(&ipmi_interfaces_mutex);
995
996 return rv;
997}
998EXPORT_SYMBOL(ipmi_get_smi_info);
999
973static void free_user(struct kref *ref) 1000static void free_user(struct kref *ref)
974{ 1001{
975 ipmi_user_t user = container_of(ref, struct ipmi_user, refcount); 1002 ipmi_user_t user = container_of(ref, struct ipmi_user, refcount);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index f27c04e18aaa..b6ae6e9a9c5f 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -57,6 +57,7 @@
57#include <asm/irq.h> 57#include <asm/irq.h>
58#include <linux/interrupt.h> 58#include <linux/interrupt.h>
59#include <linux/rcupdate.h> 59#include <linux/rcupdate.h>
60#include <linux/ipmi.h>
60#include <linux/ipmi_smi.h> 61#include <linux/ipmi_smi.h>
61#include <asm/io.h> 62#include <asm/io.h>
62#include "ipmi_si_sm.h" 63#include "ipmi_si_sm.h"
@@ -109,10 +110,6 @@ enum si_type {
109}; 110};
110static char *si_to_str[] = { "kcs", "smic", "bt" }; 111static char *si_to_str[] = { "kcs", "smic", "bt" };
111 112
112enum ipmi_addr_src {
113 SI_INVALID = 0, SI_HOTMOD, SI_HARDCODED, SI_SPMI, SI_ACPI, SI_SMBIOS,
114 SI_PCI, SI_DEVICETREE, SI_DEFAULT
115};
116static char *ipmi_addr_src_to_str[] = { NULL, "hotmod", "hardcoded", "SPMI", 113static char *ipmi_addr_src_to_str[] = { NULL, "hotmod", "hardcoded", "SPMI",
117 "ACPI", "SMBIOS", "PCI", 114 "ACPI", "SMBIOS", "PCI",
118 "device-tree", "default" }; 115 "device-tree", "default" };
@@ -293,6 +290,7 @@ struct smi_info {
293 struct task_struct *thread; 290 struct task_struct *thread;
294 291
295 struct list_head link; 292 struct list_head link;
293 union ipmi_smi_info_union addr_info;
296}; 294};
297 295
298#define smi_inc_stat(smi, stat) \ 296#define smi_inc_stat(smi, stat) \
@@ -1188,6 +1186,18 @@ static int smi_start_processing(void *send_info,
1188 return 0; 1186 return 0;
1189} 1187}
1190 1188
1189static int get_smi_info(void *send_info, struct ipmi_smi_info *data)
1190{
1191 struct smi_info *smi = send_info;
1192
1193 data->addr_src = smi->addr_source;
1194 data->dev = smi->dev;
1195 data->addr_info = smi->addr_info;
1196 get_device(smi->dev);
1197
1198 return 0;
1199}
1200
1191static void set_maintenance_mode(void *send_info, int enable) 1201static void set_maintenance_mode(void *send_info, int enable)
1192{ 1202{
1193 struct smi_info *smi_info = send_info; 1203 struct smi_info *smi_info = send_info;
@@ -1199,6 +1209,7 @@ static void set_maintenance_mode(void *send_info, int enable)
1199static struct ipmi_smi_handlers handlers = { 1209static struct ipmi_smi_handlers handlers = {
1200 .owner = THIS_MODULE, 1210 .owner = THIS_MODULE,
1201 .start_processing = smi_start_processing, 1211 .start_processing = smi_start_processing,
1212 .get_smi_info = get_smi_info,
1202 .sender = sender, 1213 .sender = sender,
1203 .request_events = request_events, 1214 .request_events = request_events,
1204 .set_maintenance_mode = set_maintenance_mode, 1215 .set_maintenance_mode = set_maintenance_mode,
@@ -1930,7 +1941,8 @@ static void __devinit hardcode_find_bmc(void)
1930static int acpi_failure; 1941static int acpi_failure;
1931 1942
1932/* For GPE-type interrupts. */ 1943/* For GPE-type interrupts. */
1933static u32 ipmi_acpi_gpe(void *context) 1944static u32 ipmi_acpi_gpe(acpi_handle gpe_device,
1945 u32 gpe_number, void *context)
1934{ 1946{
1935 struct smi_info *smi_info = context; 1947 struct smi_info *smi_info = context;
1936 unsigned long flags; 1948 unsigned long flags;
@@ -2158,6 +2170,7 @@ static int __devinit ipmi_pnp_probe(struct pnp_dev *dev,
2158 printk(KERN_INFO PFX "probing via ACPI\n"); 2170 printk(KERN_INFO PFX "probing via ACPI\n");
2159 2171
2160 handle = acpi_dev->handle; 2172 handle = acpi_dev->handle;
2173 info->addr_info.acpi_info.acpi_handle = handle;
2161 2174
2162 /* _IFT tells us the interface type: KCS, BT, etc */ 2175 /* _IFT tells us the interface type: KCS, BT, etc */
2163 status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp); 2176 status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp);
diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c
index d3d63be2cd37..1a9f5f6d6ac5 100644
--- a/drivers/char/ramoops.c
+++ b/drivers/char/ramoops.c
@@ -30,7 +30,7 @@
30 30
31#define RAMOOPS_KERNMSG_HDR "====" 31#define RAMOOPS_KERNMSG_HDR "===="
32 32
33#define RECORD_SIZE 4096 33#define RECORD_SIZE 4096UL
34 34
35static ulong mem_address; 35static ulong mem_address;
36module_param(mem_address, ulong, 0400); 36module_param(mem_address, ulong, 0400);
@@ -68,11 +68,16 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper,
68 char *buf, *buf_orig; 68 char *buf, *buf_orig;
69 struct timeval timestamp; 69 struct timeval timestamp;
70 70
71 if (reason != KMSG_DUMP_OOPS &&
72 reason != KMSG_DUMP_PANIC &&
73 reason != KMSG_DUMP_KEXEC)
74 return;
75
71 /* Only dump oopses if dump_oops is set */ 76 /* Only dump oopses if dump_oops is set */
72 if (reason == KMSG_DUMP_OOPS && !dump_oops) 77 if (reason == KMSG_DUMP_OOPS && !dump_oops)
73 return; 78 return;
74 79
75 buf = (char *)(cxt->virt_addr + (cxt->count * RECORD_SIZE)); 80 buf = cxt->virt_addr + (cxt->count * RECORD_SIZE);
76 buf_orig = buf; 81 buf_orig = buf;
77 82
78 memset(buf, '\0', RECORD_SIZE); 83 memset(buf, '\0', RECORD_SIZE);
@@ -83,8 +88,8 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper,
83 buf += res; 88 buf += res;
84 89
85 hdr_size = buf - buf_orig; 90 hdr_size = buf - buf_orig;
86 l2_cpy = min(l2, (unsigned long)(RECORD_SIZE - hdr_size)); 91 l2_cpy = min(l2, RECORD_SIZE - hdr_size);
87 l1_cpy = min(l1, (unsigned long)(RECORD_SIZE - hdr_size) - l2_cpy); 92 l1_cpy = min(l1, RECORD_SIZE - hdr_size - l2_cpy);
88 93
89 s2_start = l2 - l2_cpy; 94 s2_start = l2 - l2_cpy;
90 s1_start = l1 - l1_cpy; 95 s1_start = l1 - l1_cpy;
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index bfe25ea9766b..b4b9d5a47885 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -65,15 +65,12 @@ static int raw_open(struct inode *inode, struct file *filp)
65 if (!bdev) 65 if (!bdev)
66 goto out; 66 goto out;
67 igrab(bdev->bd_inode); 67 igrab(bdev->bd_inode);
68 err = blkdev_get(bdev, filp->f_mode); 68 err = blkdev_get(bdev, filp->f_mode | FMODE_EXCL, raw_open);
69 if (err) 69 if (err)
70 goto out; 70 goto out;
71 err = bd_claim(bdev, raw_open);
72 if (err)
73 goto out1;
74 err = set_blocksize(bdev, bdev_logical_block_size(bdev)); 71 err = set_blocksize(bdev, bdev_logical_block_size(bdev));
75 if (err) 72 if (err)
76 goto out2; 73 goto out1;
77 filp->f_flags |= O_DIRECT; 74 filp->f_flags |= O_DIRECT;
78 filp->f_mapping = bdev->bd_inode->i_mapping; 75 filp->f_mapping = bdev->bd_inode->i_mapping;
79 if (++raw_devices[minor].inuse == 1) 76 if (++raw_devices[minor].inuse == 1)
@@ -83,10 +80,8 @@ static int raw_open(struct inode *inode, struct file *filp)
83 mutex_unlock(&raw_mutex); 80 mutex_unlock(&raw_mutex);
84 return 0; 81 return 0;
85 82
86out2:
87 bd_release(bdev);
88out1: 83out1:
89 blkdev_put(bdev, filp->f_mode); 84 blkdev_put(bdev, filp->f_mode | FMODE_EXCL);
90out: 85out:
91 mutex_unlock(&raw_mutex); 86 mutex_unlock(&raw_mutex);
92 return err; 87 return err;
@@ -110,8 +105,7 @@ static int raw_release(struct inode *inode, struct file *filp)
110 } 105 }
111 mutex_unlock(&raw_mutex); 106 mutex_unlock(&raw_mutex);
112 107
113 bd_release(bdev); 108 blkdev_put(bdev, filp->f_mode | FMODE_EXCL);
114 blkdev_put(bdev, filp->f_mode);
115 return 0; 109 return 0;
116} 110}
117 111