diff options
Diffstat (limited to 'drivers/message/fusion/mptctl.c')
-rw-r--r-- | drivers/message/fusion/mptctl.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index d8ddfdf8be14..6e6e16aab9da 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -54,7 +54,7 @@ | |||
54 | #include <linux/pci.h> | 54 | #include <linux/pci.h> |
55 | #include <linux/delay.h> /* for mdelay */ | 55 | #include <linux/delay.h> /* for mdelay */ |
56 | #include <linux/miscdevice.h> | 56 | #include <linux/miscdevice.h> |
57 | #include <linux/smp_lock.h> | 57 | #include <linux/mutex.h> |
58 | #include <linux/compat.h> | 58 | #include <linux/compat.h> |
59 | 59 | ||
60 | #include <asm/io.h> | 60 | #include <asm/io.h> |
@@ -83,6 +83,7 @@ MODULE_VERSION(my_VERSION); | |||
83 | 83 | ||
84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
85 | 85 | ||
86 | static DEFINE_MUTEX(mpctl_mutex); | ||
86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; | 87 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; |
87 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; | 88 | static u8 mptctl_taskmgmt_id = MPT_MAX_PROTOCOL_DRIVERS; |
88 | 89 | ||
@@ -596,17 +597,24 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
596 | } | 597 | } |
597 | 598 | ||
598 | static int | 599 | static int |
600 | mptctl_release(struct inode *inode, struct file *filep) | ||
601 | { | ||
602 | fasync_helper(-1, filep, 0, &async_queue); | ||
603 | return 0; | ||
604 | } | ||
605 | |||
606 | static int | ||
599 | mptctl_fasync(int fd, struct file *filep, int mode) | 607 | mptctl_fasync(int fd, struct file *filep, int mode) |
600 | { | 608 | { |
601 | MPT_ADAPTER *ioc; | 609 | MPT_ADAPTER *ioc; |
602 | int ret; | 610 | int ret; |
603 | 611 | ||
604 | lock_kernel(); | 612 | mutex_lock(&mpctl_mutex); |
605 | list_for_each_entry(ioc, &ioc_list, list) | 613 | list_for_each_entry(ioc, &ioc_list, list) |
606 | ioc->aen_event_read_flag=0; | 614 | ioc->aen_event_read_flag=0; |
607 | 615 | ||
608 | ret = fasync_helper(fd, filep, mode, &async_queue); | 616 | ret = fasync_helper(fd, filep, mode, &async_queue); |
609 | unlock_kernel(); | 617 | mutex_unlock(&mpctl_mutex); |
610 | return ret; | 618 | return ret; |
611 | } | 619 | } |
612 | 620 | ||
@@ -698,9 +706,9 @@ static long | |||
698 | mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 706 | mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
699 | { | 707 | { |
700 | long ret; | 708 | long ret; |
701 | lock_kernel(); | 709 | mutex_lock(&mpctl_mutex); |
702 | ret = __mptctl_ioctl(file, cmd, arg); | 710 | ret = __mptctl_ioctl(file, cmd, arg); |
703 | unlock_kernel(); | 711 | mutex_unlock(&mpctl_mutex); |
704 | return ret; | 712 | return ret; |
705 | } | 713 | } |
706 | 714 | ||
@@ -977,7 +985,7 @@ retry_wait: | |||
977 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; | 985 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl_cmds.reply; |
978 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; | 986 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; |
979 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { | 987 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { |
980 | printk(MYIOC_s_INFO_FMT "F/W update successfull!\n", iocp->name); | 988 | printk(MYIOC_s_INFO_FMT "F/W update successful!\n", iocp->name); |
981 | return 0; | 989 | return 0; |
982 | } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { | 990 | } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { |
983 | printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", | 991 | printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", |
@@ -1306,8 +1314,10 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1306 | else | 1314 | else |
1307 | karg->adapterType = MPT_IOCTL_INTERFACE_SCSI; | 1315 | karg->adapterType = MPT_IOCTL_INTERFACE_SCSI; |
1308 | 1316 | ||
1309 | if (karg->hdr.port > 1) | 1317 | if (karg->hdr.port > 1) { |
1318 | kfree(karg); | ||
1310 | return -EINVAL; | 1319 | return -EINVAL; |
1320 | } | ||
1311 | port = karg->hdr.port; | 1321 | port = karg->hdr.port; |
1312 | 1322 | ||
1313 | karg->port = port; | 1323 | karg->port = port; |
@@ -2397,7 +2407,7 @@ done_free_mem: | |||
2397 | } | 2407 | } |
2398 | 2408 | ||
2399 | /* mf is null if command issued successfully | 2409 | /* mf is null if command issued successfully |
2400 | * otherwise, failure occured after mf acquired. | 2410 | * otherwise, failure occurred after mf acquired. |
2401 | */ | 2411 | */ |
2402 | if (mf) | 2412 | if (mf) |
2403 | mpt_free_msg_frame(ioc, mf); | 2413 | mpt_free_msg_frame(ioc, mf); |
@@ -2814,6 +2824,7 @@ static const struct file_operations mptctl_fops = { | |||
2814 | .llseek = no_llseek, | 2824 | .llseek = no_llseek, |
2815 | .fasync = mptctl_fasync, | 2825 | .fasync = mptctl_fasync, |
2816 | .unlocked_ioctl = mptctl_ioctl, | 2826 | .unlocked_ioctl = mptctl_ioctl, |
2827 | .release = mptctl_release, | ||
2817 | #ifdef CONFIG_COMPAT | 2828 | #ifdef CONFIG_COMPAT |
2818 | .compat_ioctl = compat_mpctl_ioctl, | 2829 | .compat_ioctl = compat_mpctl_ioctl, |
2819 | #endif | 2830 | #endif |
@@ -2926,7 +2937,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, | |||
2926 | static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) | 2937 | static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg) |
2927 | { | 2938 | { |
2928 | long ret; | 2939 | long ret; |
2929 | lock_kernel(); | 2940 | mutex_lock(&mpctl_mutex); |
2930 | switch (cmd) { | 2941 | switch (cmd) { |
2931 | case MPTIOCINFO: | 2942 | case MPTIOCINFO: |
2932 | case MPTIOCINFO1: | 2943 | case MPTIOCINFO1: |
@@ -2951,7 +2962,7 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
2951 | ret = -ENOIOCTLCMD; | 2962 | ret = -ENOIOCTLCMD; |
2952 | break; | 2963 | break; |
2953 | } | 2964 | } |
2954 | unlock_kernel(); | 2965 | mutex_unlock(&mpctl_mutex); |
2955 | return ret; | 2966 | return ret; |
2956 | } | 2967 | } |
2957 | 2968 | ||