dmaengine: usb-dmac: Avoid format-overflow warning

gcc points out that the fix-byte buffer might be too small:
drivers/dma/sh/usb-dmac.c: In function 'usb_dmac_probe':
drivers/dma/sh/usb-dmac.c:720:34: warning: '%u' directive writing between 1 and 10 bytes into a region of size 3 [-Wformat-overflow=]
720 | sprintf(pdev_irqname, "ch%u", index);
| ^~
In function 'usb_dmac_chan_probe',
inlined from 'usb_dmac_probe' at drivers/dma/sh/usb-dmac.c:814:9:
drivers/dma/sh/usb-dmac.c:720:31: note: directive argument in the range [0, 4294967294]
720 | sprintf(pdev_irqname, "ch%u", index);
| ^~~~~~
drivers/dma/sh/usb-dmac.c:720:9: note: 'sprintf' output between 4 and 13 bytes into a destination of size 5
720 | sprintf(pdev_irqname, "ch%u", index);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maximum number of channels for USB-DMAC as per the driver is 1-99 so use
u8 instead of unsigned int/int for DMAC channel indexing and make the
pdev_irqname string long enough to avoid the warning.

While at it use scnprintf() instead of sprintf() to make the code more
robust.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240110222210.193479-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by Lad Prabhakar and committed by Vinod Koul 62b68a88 c4d6dcb3

+5 -5
+5 -5
drivers/dma/sh/usb-dmac.c
··· 706 706 707 707 static int usb_dmac_chan_probe(struct usb_dmac *dmac, 708 708 struct usb_dmac_chan *uchan, 709 - unsigned int index) 709 + u8 index) 710 710 { 711 711 struct platform_device *pdev = to_platform_device(dmac->dev); 712 - char pdev_irqname[5]; 712 + char pdev_irqname[6]; 713 713 char *irqname; 714 714 int ret; 715 715 ··· 717 717 uchan->iomem = dmac->iomem + USB_DMAC_CHAN_OFFSET(index); 718 718 719 719 /* Request the channel interrupt. */ 720 - sprintf(pdev_irqname, "ch%u", index); 720 + scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index); 721 721 uchan->irq = platform_get_irq_byname(pdev, pdev_irqname); 722 722 if (uchan->irq < 0) 723 723 return -ENODEV; ··· 768 768 const enum dma_slave_buswidth widths = USB_DMAC_SLAVE_BUSWIDTH; 769 769 struct dma_device *engine; 770 770 struct usb_dmac *dmac; 771 - unsigned int i; 772 771 int ret; 772 + u8 i; 773 773 774 774 dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL); 775 775 if (!dmac) ··· 869 869 static void usb_dmac_remove(struct platform_device *pdev) 870 870 { 871 871 struct usb_dmac *dmac = platform_get_drvdata(pdev); 872 - int i; 872 + u8 i; 873 873 874 874 for (i = 0; i < dmac->n_channels; ++i) 875 875 usb_dmac_chan_remove(dmac, &dmac->channels[i]);