Tue Jan 5 16:30:37 2021 UTC ()
Misc KNF.  NFCI.


(skrll)
diff -r1.22 -r1.23 src/sys/arch/mips/adm5120/dev/ahci.c

cvs diff -r1.22 -r1.23 src/sys/arch/mips/adm5120/dev/ahci.c (expand / switch to unified diff)

--- src/sys/arch/mips/adm5120/dev/ahci.c 2020/04/05 20:59:38 1.22
+++ src/sys/arch/mips/adm5120/dev/ahci.c 2021/01/05 16:30:37 1.23
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ahci.c,v 1.22 2020/04/05 20:59:38 skrll Exp $ */ 1/* $NetBSD: ahci.c,v 1.23 2021/01/05 16:30:37 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko. 4 * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or 7 * Redistribution and use in source and binary forms, with or
8 * without modification, are permitted provided that the following 8 * without modification, are permitted provided that the following
9 * conditions are met: 9 * conditions are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above 12 * 2. Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following 13 * copyright notice, this list of conditions and the following
14 * disclaimer in the documentation and/or other materials provided 14 * disclaimer in the documentation and/or other materials provided
@@ -54,27 +54,27 @@ @@ -54,27 +54,27 @@
54 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 54 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
55 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 55 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
56 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
57 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 57 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
58 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 58 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59 * POSSIBILITY OF SUCH DAMAGE. 59 * POSSIBILITY OF SUCH DAMAGE.
60 */ 60 */
61 61
62/* 62/*
63 * !! HIGHLY EXPERIMENTAL CODE !! 63 * !! HIGHLY EXPERIMENTAL CODE !!
64 */ 64 */
65 65
66#include <sys/cdefs.h> 66#include <sys/cdefs.h>
67__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.22 2020/04/05 20:59:38 skrll Exp $"); 67__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.23 2021/01/05 16:30:37 skrll Exp $");
68 68
69#include <sys/param.h> 69#include <sys/param.h>
70#include <sys/systm.h> 70#include <sys/systm.h>
71#include <sys/kernel.h> 71#include <sys/kernel.h>
72#include <sys/proc.h> 72#include <sys/proc.h>
73#include <sys/device.h> 73#include <sys/device.h>
74#include <sys/kmem.h> 74#include <sys/kmem.h>
75 75
76#include <sys/bus.h> 76#include <sys/bus.h>
77#include <machine/cpu.h> 77#include <machine/cpu.h>
78 78
79#include <dev/usb/usb.h> 79#include <dev/usb/usb.h>
80#include <dev/usb/usbdi.h> 80#include <dev/usb/usbdi.h>
@@ -879,27 +879,27 @@ ahci_device_ctrl_start(struct usbd_xfer  @@ -879,27 +879,27 @@ ahci_device_ctrl_start(struct usbd_xfer
879 td3 = (struct admhcd_td *)KSEG1ADDR(&td_v[3]); 879 td3 = (struct admhcd_td *)KSEG1ADDR(&td_v[3]);
880 err = usb_allocmem(&sc->sc_bus, 880 err = usb_allocmem(&sc->sc_bus,
881 sizeof(usb_device_request_t), 881 sizeof(usb_device_request_t),
882 0, USBMALLOC_COHERENT, &reqdma); 882 0, USBMALLOC_COHERENT, &reqdma);
883 if (err) 883 if (err)
884 return USBD_NOMEM; 884 return USBD_NOMEM;
885 885
886 /* printf("ep: %p\n",ep); */ 886 /* printf("ep: %p\n",ep); */
887 }; 887 };
888 888
889 ep->control = pipe->up_dev->ud_addr | \ 889 ep->control = pipe->up_dev->ud_addr | \
890 ((pipe->up_dev->ud_speed==USB_SPEED_FULL)?ADMHCD_ED_SPEED:0) | \ 890 ((pipe->up_dev->ud_speed==USB_SPEED_FULL)?ADMHCD_ED_SPEED:0) | \
891 ((UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize))<<ADMHCD_ED_MAXSHIFT); 891 ((UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize))<<ADMHCD_ED_MAXSHIFT);
892 memcpy(KERNADDR(&reqdma, 0), req, sizeof *req); 892 memcpy(KERNADDR(&reqdma, 0), req, sizeof(*req));
893/* printf("status: %x\n",REG_READ(ADMHCD_REG_PORTSTATUS0)); 893/* printf("status: %x\n",REG_READ(ADMHCD_REG_PORTSTATUS0));
894 printf("ep_control: %x\n",ep->control); 894 printf("ep_control: %x\n",ep->control);
895 printf("speed: %x\n",pipe->up_dev->ud_speed); 895 printf("speed: %x\n",pipe->up_dev->ud_speed);
896 printf("req: %p\n",req); 896 printf("req: %p\n",req);
897 printf("dmabuf: %p\n",xfer->ux_dmabuf.block); */ 897 printf("dmabuf: %p\n",xfer->ux_dmabuf.block); */
898 898
899 isread = req->bmRequestType & UT_READ; 899 isread = req->bmRequestType & UT_READ;
900 len = UGETW(req->wLength); 900 len = UGETW(req->wLength);
901 901
902 ep->next = ep; 902 ep->next = ep;
903 903
904 td->buffer = DMAADDR(&reqdma,0) | 0xa0000000; 904 td->buffer = DMAADDR(&reqdma,0) | 0xa0000000;
905 td->buflen=sizeof(*req); 905 td->buflen=sizeof(*req);
@@ -1226,36 +1226,37 @@ ahci_device_bulk_start(struct usbd_xfer  @@ -1226,36 +1226,37 @@ ahci_device_bulk_start(struct usbd_xfer
1226/* printf("level: %d\n",level); 1226/* printf("level: %d\n",level);
1227 printf("short_xfer: %x\n",short_ok); 1227 printf("short_xfer: %x\n",short_ok);
1228 printf("ep_control: %x\n",ep->control); 1228 printf("ep_control: %x\n",ep->control);
1229 printf("speed: %x\n",pipe->up_dev->ud_speed); 1229 printf("speed: %x\n",pipe->up_dev->ud_speed);
1230 printf("dmabuf: %p\n",xfer->ux_dmabuf.block); */ 1230 printf("dmabuf: %p\n",xfer->ux_dmabuf.block); */
1231 1231
1232 isread = UE_GET_DIR(endpt) == UE_DIR_IN; 1232 isread = UE_GET_DIR(endpt) == UE_DIR_IN;
1233 len = xfer->ux_length; 1233 len = xfer->ux_length;
1234 1234
1235 ep->next = ep; 1235 ep->next = ep;
1236 1236
1237 i = 0; 1237 i = 0;
1238 offset = 0; 1238 offset = 0;
1239 while ((len>0) || (i==0)) { 1239 while (len > 0) || i == 0) {
1240 tlen = uimin(len,4096); 1240 tlen = uimin(len,4096);
1241 td[i]->buffer = DMAADDR(&xfer->ux_dmabuf,offset) | 0xa0000000; 1241 td[i]->buffer = DMAADDR(&xfer->ux_dmabuf, offset) | 0xa0000000;
1242 td[i]->buflen=tlen; 1242 td[i]->buflen = tlen;
1243 td[i]->control=(isread?ADMHCD_TD_IN:ADMHCD_TD_OUT) | toggle | ADMHCD_TD_OWN | short_ok; 1243 td[i]->control = (isread ? ADMHCD_TD_IN : ADMHCD_TD_OUT) |
1244 td[i]->len=tlen; 1244 toggle | ADMHCD_TD_OWN | short_ok;
 1245 td[i]->len = tlen;
1245 toggle = ADMHCD_TD_TOGGLE; 1246 toggle = ADMHCD_TD_TOGGLE;
1246 len -= tlen; 1247 len -= tlen;
1247 offset += tlen; 1248 offset += tlen;
1248 td[i]->next = td[i+1]; 1249 td[i]->next = td[i + 1];
1249 i++; 1250 i++;
1250 }; 1251 };
1251 1252
1252 td[i]->buffer = 0; 1253 td[i]->buffer = 0;
1253 td[i]->buflen = 0; 1254 td[i]->buflen = 0;
1254 td[i]->control = 0; 1255 td[i]->control = 0;
1255 td[i]->next = 0; 1256 td[i]->next = 0;
1256 1257
1257 ep->head = td[0]; 1258 ep->head = td[0];
1258 ep->tail = td[i]; 1259 ep->tail = td[i];
1259 segs = i; 1260 segs = i;
1260 len = 0; 1261 len = 0;
1261 1262