Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic epget: Tiny clean up for 16-bit buses.



details:   https://anonhg.NetBSD.org/src/rev/074250d049ba
branches:  trunk
changeset: 1024142:074250d049ba
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Oct 11 02:42:46 2021 +0000

description:
epget: Tiny clean up for 16-bit buses.

- (offset & 1) must be zero, since IP header is aligned.

- Use bus_space_read_1(9) instead of bus_space_read_multi_1(9) for
  single-byte read.

diffstat:

 sys/dev/ic/elink3.c |  15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)

diffs (43 lines):

diff -r cb405d8f4724 -r 074250d049ba sys/dev/ic/elink3.c
--- a/sys/dev/ic/elink3.c       Mon Oct 11 02:35:18 2021 +0000
+++ b/sys/dev/ic/elink3.c       Mon Oct 11 02:42:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elink3.c,v 1.152 2020/02/07 01:19:46 thorpej Exp $     */
+/*     $NetBSD: elink3.c,v 1.153 2021/10/11 02:42:46 rin Exp $ */
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.152 2020/02/07 01:19:46 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elink3.c,v 1.153 2021/10/11 02:42:46 rin Exp $");
 
 #include "opt_inet.h"
 
@@ -1638,12 +1638,7 @@
                            rxreg, (u_int8_t *) offset, remaining);
                }
        } else {
-               if ((remaining > 1) && (offset & 1)) {
-                       bus_space_read_multi_1(iot, ioh,
-                           rxreg, (u_int8_t *) offset, 1);
-                       remaining -= 1;
-                       offset += 1;
-               }
+               /* (offset & 1) == 0 since IP header is aligned */
                if (remaining > 1) {
                        bus_space_read_multi_stream_2(iot, ioh,
                            rxreg, (u_int16_t *) offset,
@@ -1651,8 +1646,8 @@
                        offset += remaining & ~1;
                }
                if (remaining & 1) {
-                               bus_space_read_multi_1(iot, ioh,
-                           rxreg, (u_int8_t *) offset, remaining & 1);
+                       *(uint8_t *)offset =
+                           bus_space_read_1(iot, ioh, rxreg);
                }
        }
 



Home | Main Index | Thread Index | Old Index