aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2010-10-28 11:31:21 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-11-11 08:58:49 -0500
commitfe52f7922c446b2f604ef609153f1cef0ea17278 (patch)
treea5221472e42dafee91dc194880ab52979ebe6b03
parent1ccd7923fe521273d63d936129754e71a33ebe51 (diff)
USB: gadget: f_mass_storage: drop START_TRANSFER() macro
This commit drops START_TRANSFER_OR() and START_TRANSFER() macros with a pair of nice inline functions which are actually more readable and easier to use. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/f_mass_storage.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 2a4aca1d4865..c71f69fbf730 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -692,16 +692,23 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
692 } 692 }
693} 693}
694 694
695#define START_TRANSFER_OR(common, ep_name, req, pbusy, state) \ 695static bool start_in_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
696 if (fsg_is_set(common)) \ 696{
697 start_transfer((common)->fsg, (common)->fsg->ep_name, \ 697 if (!fsg_is_set(common))
698 req, pbusy, state); \ 698 return false;
699 else 699 start_transfer(common->fsg, common->fsg->bulk_in,
700 700 bh->inreq, &bh->inreq_busy, &bh->state);
701#define START_TRANSFER(common, ep_name, req, pbusy, state) \ 701 return true;
702 START_TRANSFER_OR(common, ep_name, req, pbusy, state) (void)0 702}
703
704 703
704static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
705{
706 if (!fsg_is_set(common))
707 return false;
708 start_transfer(common->fsg, common->fsg->bulk_out,
709 bh->outreq, &bh->outreq_busy, &bh->state);
710 return true;
711}
705 712
706static int sleep_thread(struct fsg_common *common) 713static int sleep_thread(struct fsg_common *common)
707{ 714{
@@ -842,10 +849,8 @@ static int do_read(struct fsg_common *common)
842 849
843 /* Send this buffer and go read some more */ 850 /* Send this buffer and go read some more */
844 bh->inreq->zero = 0; 851 bh->inreq->zero = 0;
845 START_TRANSFER_OR(common, bulk_in, bh->inreq, 852 if (!start_in_transfer(common, bh))
846 &bh->inreq_busy, &bh->state) 853 /* Don't know what to do if common->fsg is NULL */
847 /* Don't know what to do if
848 * common->fsg is NULL */
849 return -EIO; 854 return -EIO;
850 common->next_buffhd_to_fill = bh->next; 855 common->next_buffhd_to_fill = bh->next;
851 } 856 }
@@ -961,8 +966,7 @@ static int do_write(struct fsg_common *common)
961 bh->outreq->length = amount; 966 bh->outreq->length = amount;
962 bh->bulk_out_intended_length = amount; 967 bh->bulk_out_intended_length = amount;
963 bh->outreq->short_not_ok = 1; 968 bh->outreq->short_not_ok = 1;
964 START_TRANSFER_OR(common, bulk_out, bh->outreq, 969 if (!start_out_transfer(common, bh))
965 &bh->outreq_busy, &bh->state)
966 /* Don't know what to do if 970 /* Don't know what to do if
967 * common->fsg is NULL */ 971 * common->fsg is NULL */
968 return -EIO; 972 return -EIO;
@@ -1636,8 +1640,7 @@ static int throw_away_data(struct fsg_common *common)
1636 bh->outreq->length = amount; 1640 bh->outreq->length = amount;
1637 bh->bulk_out_intended_length = amount; 1641 bh->bulk_out_intended_length = amount;
1638 bh->outreq->short_not_ok = 1; 1642 bh->outreq->short_not_ok = 1;
1639 START_TRANSFER_OR(common, bulk_out, bh->outreq, 1643 if (!start_out_transfer(common, bh))
1640 &bh->outreq_busy, &bh->state)
1641 /* Don't know what to do if 1644 /* Don't know what to do if
1642 * common->fsg is NULL */ 1645 * common->fsg is NULL */
1643 return -EIO; 1646 return -EIO;
@@ -1688,8 +1691,7 @@ static int finish_reply(struct fsg_common *common)
1688 /* If there's no residue, simply send the last buffer */ 1691 /* If there's no residue, simply send the last buffer */
1689 } else if (common->residue == 0) { 1692 } else if (common->residue == 0) {
1690 bh->inreq->zero = 0; 1693 bh->inreq->zero = 0;
1691 START_TRANSFER_OR(common, bulk_in, bh->inreq, 1694 if (!start_in_transfer(common, bh))
1692 &bh->inreq_busy, &bh->state)
1693 return -EIO; 1695 return -EIO;
1694 common->next_buffhd_to_fill = bh->next; 1696 common->next_buffhd_to_fill = bh->next;
1695 1697
@@ -1698,8 +1700,7 @@ static int finish_reply(struct fsg_common *common)
1698 * stall, pad out the remaining data with 0's. */ 1700 * stall, pad out the remaining data with 0's. */
1699 } else if (common->can_stall) { 1701 } else if (common->can_stall) {
1700 bh->inreq->zero = 1; 1702 bh->inreq->zero = 1;
1701 START_TRANSFER_OR(common, bulk_in, bh->inreq, 1703 if (!start_in_transfer(common, bh))
1702 &bh->inreq_busy, &bh->state)
1703 /* Don't know what to do if 1704 /* Don't know what to do if
1704 * common->fsg is NULL */ 1705 * common->fsg is NULL */
1705 rc = -EIO; 1706 rc = -EIO;
@@ -1798,8 +1799,7 @@ static int send_status(struct fsg_common *common)
1798 1799
1799 bh->inreq->length = USB_BULK_CS_WRAP_LEN; 1800 bh->inreq->length = USB_BULK_CS_WRAP_LEN;
1800 bh->inreq->zero = 0; 1801 bh->inreq->zero = 0;
1801 START_TRANSFER_OR(common, bulk_in, bh->inreq, 1802 if (!start_in_transfer(common, bh))
1802 &bh->inreq_busy, &bh->state)
1803 /* Don't know what to do if common->fsg is NULL */ 1803 /* Don't know what to do if common->fsg is NULL */
1804 return -EIO; 1804 return -EIO;
1805 1805
@@ -2287,8 +2287,7 @@ static int get_next_command(struct fsg_common *common)
2287 /* Queue a request to read a Bulk-only CBW */ 2287 /* Queue a request to read a Bulk-only CBW */
2288 set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN); 2288 set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN);
2289 bh->outreq->short_not_ok = 1; 2289 bh->outreq->short_not_ok = 1;
2290 START_TRANSFER_OR(common, bulk_out, bh->outreq, 2290 if (!start_out_transfer(common, bh))
2291 &bh->outreq_busy, &bh->state)
2292 /* Don't know what to do if common->fsg is NULL */ 2291 /* Don't know what to do if common->fsg is NULL */
2293 return -EIO; 2292 return -EIO;
2294 2293