Skip to contentSkip to conversation

usb: gadget: udc: Fix assignment of 0/1 to bool variables

PATCH Michal Simek 2 participants 2 messages Oct 8, 2019 – Oct 22, 2019 1 message not in the archive USB

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20191007181527.GA6816@saurav

Michal Simek

author Acked-by
#1 lore raw
Quoted 137 lines · Saurav Girepunje

Use true/false assignment for below bool variables in udc-xilinx.c:

bool buffer0ready;
bool buffer1ready;
bool is_in;
bool is_iso;

---
 drivers/usb/gadget/udc/udc-xilinx.c | 36 ++++++++++++++---------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/usb/gadget/udc/udc-xilinx.c +16 -16
index 29d8e5f8bb58..b077c5bfd9ae 100644
@@ -392,7 +392,7 @@ static int xudc_dma_send(struct xusb_ep *ep, struct xusb_req *req,
 			      XUSB_EP_BUF0COUNT_OFFSET, length);
 		udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET,
 			      XUSB_DMA_BRR_CTRL | (1 << ep->epnumber));
-		ep->buffer0ready = 1;
+		ep->buffer0ready = true;
 		ep->curbufnum = 1;
 	} else if (ep->curbufnum && !ep->buffer1ready) {
 		/* Get the Buffer address and copy the transmit data.*/
@@ -404,7 +404,7 @@ static int xudc_dma_send(struct xusb_ep *ep, struct xusb_req *req,
 		udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET,
 			      XUSB_DMA_BRR_CTRL | (1 << (ep->epnumber +
 			      XUSB_STATUS_EP_BUFF2_SHIFT)));
-		ep->buffer1ready = 1;
+		ep->buffer1ready = true;
 		ep->curbufnum = 0;
 	} else {
 		/* None of ping pong buffers are ready currently .*/
@@ -442,7 +442,7 @@ static int xudc_dma_receive(struct xusb_ep *ep, struct xusb_req *req,
 		udc->write_fn(udc->addr, XUSB_DMA_CONTROL_OFFSET,
 			      XUSB_DMA_BRR_CTRL | XUSB_DMA_READ_FROM_DPRAM |
 			      (1 << ep->epnumber));
-		ep->buffer0ready = 1;
+		ep->buffer0ready = true;
 		ep->curbufnum = 1;
 	} else if (ep->curbufnum && !ep->buffer1ready) {
 		/* Get the Buffer address and copy the transmit data */
@@ -453,7 +453,7 @@ static int xudc_dma_receive(struct xusb_ep *ep, struct xusb_req *req,
 			      XUSB_DMA_BRR_CTRL | XUSB_DMA_READ_FROM_DPRAM |
 			      (1 << (ep->epnumber +
 			      XUSB_STATUS_EP_BUFF2_SHIFT)));
-		ep->buffer1ready = 1;
+		ep->buffer1ready = true;
 		ep->curbufnum = 0;
 	} else {
 		/* None of the ping-pong buffers are ready currently */
@@ -507,7 +507,7 @@ static int xudc_eptxrx(struct xusb_ep *ep, struct xusb_req *req,
 		 */
 		udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET,
 			      1 << ep->epnumber);
-		ep->buffer0ready = 1;
+		ep->buffer0ready = true;
 		ep->curbufnum = 1;
 	} else if (ep->curbufnum && !ep->buffer1ready) {
 		/* Get the Buffer address and copy the transmit data.*/
@@ -525,7 +525,7 @@ static int xudc_eptxrx(struct xusb_ep *ep, struct xusb_req *req,
 		 */
 		udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET,
 			      1 << (ep->epnumber + XUSB_STATUS_EP_BUFF2_SHIFT));
-		ep->buffer1ready = 1;
+		ep->buffer1ready = true;
 		ep->curbufnum = 0;
 	} else {
 		/* None of the ping-pong buffers are ready currently */
@@ -818,11 +818,11 @@ static int __xudc_ep_enable(struct xusb_ep *ep,
 	case USB_ENDPOINT_XFER_CONTROL:
 		dev_dbg(udc->dev, "only one control endpoint\n");
 		/* NON- ISO */
-		ep->is_iso = 0;
+		ep->is_iso = false;
 		return -EINVAL;
 	case USB_ENDPOINT_XFER_INT:
 		/* NON- ISO */
-		ep->is_iso = 0;
+		ep->is_iso = false;
 		if (maxpacket > 64) {
 			dev_dbg(udc->dev, "bogus maxpacket %d\n", maxpacket);
 			return -EINVAL;
@@ -830,7 +830,7 @@ static int __xudc_ep_enable(struct xusb_ep *ep,
 		break;
 	case USB_ENDPOINT_XFER_BULK:
 		/* NON- ISO */
-		ep->is_iso = 0;
+		ep->is_iso = false;
 		if (!(is_power_of_2(maxpacket) && maxpacket >= 8 &&
 				maxpacket <= 512)) {
 			dev_dbg(udc->dev, "bogus maxpacket %d\n", maxpacket);
@@ -839,12 +839,12 @@ static int __xudc_ep_enable(struct xusb_ep *ep,
 		break;
 	case USB_ENDPOINT_XFER_ISOC:
 		/* ISO */
-		ep->is_iso = 1;
+		ep->is_iso = true;
 		break;
 	}
 
-	ep->buffer0ready = 0;
-	ep->buffer1ready = 0;
+	ep->buffer0ready = false;
+	ep->buffer1ready = false;
 	ep->curbufnum = 0;
 	ep->rambase = rambase[ep->epnumber];
 	xudc_epconfig(ep, udc);
@@ -868,11 +868,11 @@ static int __xudc_ep_enable(struct xusb_ep *ep,
 	if (ep->epnumber && !ep->is_in) {
 		udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET,
 			      1 << ep->epnumber);
-		ep->buffer0ready = 1;
+		ep->buffer0ready = true;
 		udc->write_fn(udc->addr, XUSB_BUFFREADY_OFFSET,
 			     (1 << (ep->epnumber +
 			      XUSB_STATUS_EP_BUFF2_SHIFT)));
-		ep->buffer1ready = 1;
+		ep->buffer1ready = true;
 	}
 
 	return 0;
@@ -1331,8 +1331,8 @@ static void xudc_eps_init(struct xusb_udc *udc)
 		 * each endpoint is 0x10.
 		 */
 		ep->offset = XUSB_EP0_CONFIG_OFFSET + (ep_number * 0x10);
-		ep->is_in = 0;
-		ep->is_iso = 0;
+		ep->is_in = false;
+		ep->is_iso = false;
 		ep->maxpacket = 0;
 		xudc_epconfig(ep, udc);
 
@@ -1952,9 +1952,9 @@ static void xudc_nonctrl_ep_handler(struct xusb_udc *udc, u8 epnum,
 	ep = &udc->ep[epnum];

drivers/usb/gadget/udc/udc-xilinx.c static void xudc_nonctrl_ep_handler(struct xusb_udc *udc, u8 epnum, · line 1960

Quoted 10 lines
drivers/usb/gadget/udc/udc-xilinx.c +2 -2
 	/* Process the End point interrupts.*/
 	if (intrstatus & (XUSB_STATUS_EP0_BUFF1_COMP_MASK << epnum))
-		ep->buffer0ready = 0;
+		ep->buffer0ready = false;
 	if (intrstatus & (XUSB_STATUS_EP0_BUFF2_COMP_MASK << epnum))
-		ep->buffer1ready = 0;
+		ep->buffer1ready = false;
 
 	if (list_empty(&ep->queue))
 		return;

Thanks,
Michal

#2 lore raw

Hi,

Quoted 10 lines · Michal Simek
Quoted 10 lines
(quoted diff) +2 -2
@@ -1952,9 +1952,9 @@ static void xudc_nonctrl_ep_handler(struct xusb_udc *udc, u8 epnum,
 	ep = &udc->ep[epnum];
 	/* Process the End point interrupts.*/
 	if (intrstatus & (XUSB_STATUS_EP0_BUFF1_COMP_MASK << epnum))
-		ep->buffer0ready = 0;
+		ep->buffer0ready = false;
 	if (intrstatus & (XUSB_STATUS_EP0_BUFF2_COMP_MASK << epnum))
-		ep->buffer1ready = 0;
+		ep->buffer1ready = false;
 
Quoted 5 lines

Review static void xudc_nonctrl_ep_handler(struct xusb_udc *udc, u8 epnum, · line 1960

Quoted 3 lines
(quoted diff) +0 -0
 	if (list_empty(&ep->queue))
 		return;

I don't have the original patch, sorry. Care to resend with Acks?

Signature · 1 line
balbi