Re: [PATCH] usb: gadget: udc: Fix assignment of 0/1 to bool variables

From: Michal Simek
Date: Tue Oct 08 2019 - 02:34:36 EST


On 07. 10. 19 20:15, Saurav Girepunje wrote:
> Use true/false assignment for below bool variables in udc-xilinx.c:
>
> bool buffer0ready;
> bool buffer1ready;
> bool is_in;
> bool is_iso;
>
> Signed-off-by: Saurav Girepunje <saurav.girepunje@xxxxxxxxx>
> ---
> drivers/usb/gadget/udc/udc-xilinx.c | 36 ++++++++++++++---------------
> 1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
> index 29d8e5f8bb58..b077c5bfd9ae 100644
> --- a/drivers/usb/gadget/udc/udc-xilinx.c
> +++ b/drivers/usb/gadget/udc/udc-xilinx.c
> @@ -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];
> /* 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;
>

Acked-by: Michal Simek <michal.simek@xxxxxxxxxx>

Thanks,
Michal