svn commit: r283481 - stable/10/sys/dev/uart
Ian Lepore
ian at FreeBSD.org
Sun May 24 17:57:31 UTC 2015
Author: ian
Date: Sun May 24 17:57:29 2015
New Revision: 283481
URL: https://svnweb.freebsd.org/changeset/base/283481
Log:
MFC r281073, r281074, r281077, r281200:
Use OF_getencprop over OF_getprop and fdt32_to_cpu. The latter may give
us the wrong data in the failure case if shift was not zero.
Remove the extra copy of uart_fdt_get_clock and uart_fdt_get_shift. While
here also use OF_getencprop in uart_fdt_get_clock.
Move uart_fdt_get_clock and uart_fdt_get_shift to uart_bus_fdt.c, we may
not build uart_cpu_fdt.c in all configs.
Fix uart_fdt_get_clock. It should have been using the cell variable passed
in, not value on the stack.
Modified:
stable/10/sys/dev/uart/uart_bus_fdt.c
stable/10/sys/dev/uart/uart_cpu_fdt.c
stable/10/sys/dev/uart/uart_cpu_fdt.h
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/dev/uart/uart_bus_fdt.c
==============================================================================
--- stable/10/sys/dev/uart/uart_bus_fdt.c Sun May 24 17:57:07 2015 (r283480)
+++ stable/10/sys/dev/uart/uart_bus_fdt.c Sun May 24 17:57:29 2015 (r283481)
@@ -63,37 +63,29 @@ static driver_t uart_fdt_driver = {
sizeof(struct uart_softc),
};
-static int
+int
uart_fdt_get_clock(phandle_t node, pcell_t *cell)
{
- pcell_t clock;
-
- /*
- * clock-frequency is a FreeBSD-specific hack. Make its presence optional.
- */
- if ((OF_getprop(node, "clock-frequency", &clock,
- sizeof(clock))) <= 0)
- clock = 0;
- if (clock == 0)
+ /* clock-frequency is a FreeBSD-only extention. */
+ if ((OF_getencprop(node, "clock-frequency", cell,
+ sizeof(*cell))) <= 0) {
/* Try to retrieve parent 'bus-frequency' */
/* XXX this should go to simple-bus fixup or so */
- if ((OF_getprop(OF_parent(node), "bus-frequency", &clock,
- sizeof(clock))) <= 0)
- clock = 0;
+ if ((OF_getencprop(OF_parent(node), "bus-frequency", cell,
+ sizeof(*cell))) <= 0)
+ *cell = 0;
+ }
- *cell = fdt32_to_cpu(clock);
return (0);
}
-static int
+int
uart_fdt_get_shift(phandle_t node, pcell_t *cell)
{
- pcell_t shift;
- if ((OF_getprop(node, "reg-shift", &shift, sizeof(shift))) <= 0)
- shift = 0;
- *cell = fdt32_to_cpu(shift);
+ if ((OF_getencprop(node, "reg-shift", cell, sizeof(*cell))) <= 0)
+ *cell = 0;
return (0);
}
Modified: stable/10/sys/dev/uart/uart_cpu_fdt.c
==============================================================================
--- stable/10/sys/dev/uart/uart_cpu_fdt.c Sun May 24 17:57:07 2015 (r283480)
+++ stable/10/sys/dev/uart/uart_cpu_fdt.c Sun May 24 17:57:29 2015 (r283481)
@@ -58,38 +58,6 @@ __FBSDID("$FreeBSD$");
bus_space_tag_t uart_bus_space_io;
bus_space_tag_t uart_bus_space_mem;
-static int
-uart_fdt_get_clock(phandle_t node, pcell_t *cell)
-{
- pcell_t clock;
-
- /* clock-frequency is a FreeBSD-only extention. */
- if ((OF_getprop(node, "clock-frequency", &clock,
- sizeof(clock))) <= 0)
- clock = 0;
-
- if (clock == 0)
- /* Try to retrieve parent 'bus-frequency' */
- /* XXX this should go to simple-bus fixup or so */
- if ((OF_getprop(OF_parent(node), "bus-frequency", &clock,
- sizeof(clock))) <= 0)
- clock = 0;
-
- *cell = fdt32_to_cpu(clock);
- return (0);
-}
-
-static int
-uart_fdt_get_shift(phandle_t node, pcell_t *cell)
-{
- pcell_t shift;
-
- if ((OF_getprop(node, "reg-shift", &shift, sizeof(shift))) <= 0)
- shift = 0;
- *cell = fdt32_to_cpu(shift);
- return (0);
-}
-
int
uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
{
Modified: stable/10/sys/dev/uart/uart_cpu_fdt.h
==============================================================================
--- stable/10/sys/dev/uart/uart_cpu_fdt.h Sun May 24 17:57:07 2015 (r283480)
+++ stable/10/sys/dev/uart/uart_cpu_fdt.h Sun May 24 17:57:29 2015 (r283481)
@@ -50,5 +50,7 @@ SET_DECLARE(uart_fdt_class_set, struct o
#define UART_FDT_CLASS(data) \
DATA_SET(uart_fdt_class_set, data)
+int uart_fdt_get_clock(phandle_t node, pcell_t *cell);
+int uart_fdt_get_shift(phandle_t node, pcell_t *cell);
#endif /* _DEV_UART_CPU_FDT_H_ */
More information about the svn-src-stable-10
mailing list