diff options
author | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2011-01-13 01:06:28 -0500 |
commit | f43dc23d5ea91fca257be02138a255f02d98e806 (patch) | |
tree | b29722f6e965316e90ac97abf79923ced250dc21 /drivers/block/ub.c | |
parent | f8e53553f452dcbf67cb89c8cba63a1cd6eb4cc0 (diff) | |
parent | 4162cf64973df51fc885825bc9ca4d055891c49f (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into common/serial-rework
Conflicts:
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/setup-mxg.c
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
arch/sh/kernel/cpu/sh3/setup-sh7705.c
arch/sh/kernel/cpu/sh3/setup-sh770x.c
arch/sh/kernel/cpu/sh3/setup-sh7710.c
arch/sh/kernel/cpu/sh3/setup-sh7720.c
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
arch/sh/kernel/cpu/sh4/setup-sh7750.c
arch/sh/kernel/cpu/sh4/setup-sh7760.c
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
arch/sh/kernel/cpu/sh4a/setup-shx3.c
arch/sh/kernel/cpu/sh5/setup-sh5.c
drivers/serial/sh-sci.c
drivers/serial/sh-sci.h
include/linux/serial_sci.h
Diffstat (limited to 'drivers/block/ub.c')
-rw-r--r-- | drivers/block/ub.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index cc54473b8e77..9ae3bb713286 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/blkdev.h> | 27 | #include <linux/blkdev.h> |
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/scatterlist.h> | 29 | #include <linux/scatterlist.h> |
30 | #include <linux/slab.h> | ||
31 | #include <linux/mutex.h> | ||
30 | #include <scsi/scsi.h> | 32 | #include <scsi/scsi.h> |
31 | 33 | ||
32 | #define DRV_NAME "ub" | 34 | #define DRV_NAME "ub" |
@@ -246,6 +248,7 @@ struct ub_completion { | |||
246 | spinlock_t lock; | 248 | spinlock_t lock; |
247 | }; | 249 | }; |
248 | 250 | ||
251 | static DEFINE_MUTEX(ub_mutex); | ||
249 | static inline void ub_init_completion(struct ub_completion *x) | 252 | static inline void ub_init_completion(struct ub_completion *x) |
250 | { | 253 | { |
251 | x->done = 0; | 254 | x->done = 0; |
@@ -393,8 +396,8 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum); | |||
393 | #define ub_usb_ids usb_storage_usb_ids | 396 | #define ub_usb_ids usb_storage_usb_ids |
394 | #else | 397 | #else |
395 | 398 | ||
396 | static struct usb_device_id ub_usb_ids[] = { | 399 | static const struct usb_device_id ub_usb_ids[] = { |
397 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, | 400 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_BULK) }, |
398 | { } | 401 | { } |
399 | }; | 402 | }; |
400 | 403 | ||
@@ -647,7 +650,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) | |||
647 | return 0; | 650 | return 0; |
648 | } | 651 | } |
649 | 652 | ||
650 | if (lun->changed && !blk_pc_request(rq)) { | 653 | if (lun->changed && rq->cmd_type != REQ_TYPE_BLOCK_PC) { |
651 | blk_start_request(rq); | 654 | blk_start_request(rq); |
652 | ub_end_rq(rq, SAM_STAT_CHECK_CONDITION); | 655 | ub_end_rq(rq, SAM_STAT_CHECK_CONDITION); |
653 | return 0; | 656 | return 0; |
@@ -683,7 +686,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) | |||
683 | } | 686 | } |
684 | urq->nsg = n_elem; | 687 | urq->nsg = n_elem; |
685 | 688 | ||
686 | if (blk_pc_request(rq)) { | 689 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
687 | ub_cmd_build_packet(sc, lun, cmd, urq); | 690 | ub_cmd_build_packet(sc, lun, cmd, urq); |
688 | } else { | 691 | } else { |
689 | ub_cmd_build_block(sc, lun, cmd, urq); | 692 | ub_cmd_build_block(sc, lun, cmd, urq); |
@@ -780,7 +783,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
780 | rq = urq->rq; | 783 | rq = urq->rq; |
781 | 784 | ||
782 | if (cmd->error == 0) { | 785 | if (cmd->error == 0) { |
783 | if (blk_pc_request(rq)) { | 786 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
784 | if (cmd->act_len >= rq->resid_len) | 787 | if (cmd->act_len >= rq->resid_len) |
785 | rq->resid_len = 0; | 788 | rq->resid_len = 0; |
786 | else | 789 | else |
@@ -794,7 +797,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) | |||
794 | } | 797 | } |
795 | } | 798 | } |
796 | } else { | 799 | } else { |
797 | if (blk_pc_request(rq)) { | 800 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
798 | /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ | 801 | /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ |
799 | memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); | 802 | memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); |
800 | rq->sense_len = UB_SENSE_SIZE; | 803 | rq->sense_len = UB_SENSE_SIZE; |
@@ -1709,6 +1712,18 @@ err_open: | |||
1709 | return rc; | 1712 | return rc; |
1710 | } | 1713 | } |
1711 | 1714 | ||
1715 | static int ub_bd_unlocked_open(struct block_device *bdev, fmode_t mode) | ||
1716 | { | ||
1717 | int ret; | ||
1718 | |||
1719 | mutex_lock(&ub_mutex); | ||
1720 | ret = ub_bd_open(bdev, mode); | ||
1721 | mutex_unlock(&ub_mutex); | ||
1722 | |||
1723 | return ret; | ||
1724 | } | ||
1725 | |||
1726 | |||
1712 | /* | 1727 | /* |
1713 | */ | 1728 | */ |
1714 | static int ub_bd_release(struct gendisk *disk, fmode_t mode) | 1729 | static int ub_bd_release(struct gendisk *disk, fmode_t mode) |
@@ -1716,7 +1731,10 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode) | |||
1716 | struct ub_lun *lun = disk->private_data; | 1731 | struct ub_lun *lun = disk->private_data; |
1717 | struct ub_dev *sc = lun->udev; | 1732 | struct ub_dev *sc = lun->udev; |
1718 | 1733 | ||
1734 | mutex_lock(&ub_mutex); | ||
1719 | ub_put(sc); | 1735 | ub_put(sc); |
1736 | mutex_unlock(&ub_mutex); | ||
1737 | |||
1720 | return 0; | 1738 | return 0; |
1721 | } | 1739 | } |
1722 | 1740 | ||
@@ -1728,8 +1746,13 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode, | |||
1728 | { | 1746 | { |
1729 | struct gendisk *disk = bdev->bd_disk; | 1747 | struct gendisk *disk = bdev->bd_disk; |
1730 | void __user *usermem = (void __user *) arg; | 1748 | void __user *usermem = (void __user *) arg; |
1749 | int ret; | ||
1750 | |||
1751 | mutex_lock(&ub_mutex); | ||
1752 | ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); | ||
1753 | mutex_unlock(&ub_mutex); | ||
1731 | 1754 | ||
1732 | return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); | 1755 | return ret; |
1733 | } | 1756 | } |
1734 | 1757 | ||
1735 | /* | 1758 | /* |
@@ -1789,11 +1812,11 @@ static int ub_bd_media_changed(struct gendisk *disk) | |||
1789 | return lun->changed; | 1812 | return lun->changed; |
1790 | } | 1813 | } |
1791 | 1814 | ||
1792 | static struct block_device_operations ub_bd_fops = { | 1815 | static const struct block_device_operations ub_bd_fops = { |
1793 | .owner = THIS_MODULE, | 1816 | .owner = THIS_MODULE, |
1794 | .open = ub_bd_open, | 1817 | .open = ub_bd_unlocked_open, |
1795 | .release = ub_bd_release, | 1818 | .release = ub_bd_release, |
1796 | .locked_ioctl = ub_bd_ioctl, | 1819 | .ioctl = ub_bd_ioctl, |
1797 | .media_changed = ub_bd_media_changed, | 1820 | .media_changed = ub_bd_media_changed, |
1798 | .revalidate_disk = ub_bd_revalidate, | 1821 | .revalidate_disk = ub_bd_revalidate, |
1799 | }; | 1822 | }; |
@@ -2320,10 +2343,9 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) | |||
2320 | disk->queue = q; | 2343 | disk->queue = q; |
2321 | 2344 | ||
2322 | blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); | 2345 | blk_queue_bounce_limit(q, BLK_BOUNCE_HIGH); |
2323 | blk_queue_max_hw_segments(q, UB_MAX_REQ_SG); | 2346 | blk_queue_max_segments(q, UB_MAX_REQ_SG); |
2324 | blk_queue_max_phys_segments(q, UB_MAX_REQ_SG); | ||
2325 | blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ | 2347 | blk_queue_segment_boundary(q, 0xffffffff); /* Dubious. */ |
2326 | blk_queue_max_sectors(q, UB_MAX_SECTORS); | 2348 | blk_queue_max_hw_sectors(q, UB_MAX_SECTORS); |
2327 | blk_queue_logical_block_size(q, lun->capacity.bsize); | 2349 | blk_queue_logical_block_size(q, lun->capacity.bsize); |
2328 | 2350 | ||
2329 | lun->disk = disk; | 2351 | lun->disk = disk; |