svn commit: r308768 - head/sys/dev/uart
Ruslan Bukin
br at FreeBSD.org
Thu Nov 17 16:06:54 UTC 2016
Author: br
Date: Thu Nov 17 16:06:53 2016
New Revision: 308768
URL: https://svnweb.freebsd.org/changeset/base/308768
Log:
Do not reallocate driver softc for uart unnecessarily.
Do not assume that all uart drivers use uart_softc structure as is.
Some do a sensible thing and do declare their uart class and driver
properly and arrive into uart_bus_attach with suitably sized softc.
Submitted by: kan
Sponsored by: DARPA, AFRL
Modified:
head/sys/dev/uart/uart_core.c
Modified: head/sys/dev/uart/uart_core.c
==============================================================================
--- head/sys/dev/uart/uart_core.c Thu Nov 17 15:37:44 2016 (r308767)
+++ head/sys/dev/uart/uart_core.c Thu Nov 17 16:06:53 2016 (r308768)
@@ -573,7 +573,7 @@ uart_bus_attach(device_t dev)
* the device.
*/
sc0 = device_get_softc(dev);
- if (sc0->sc_class->size > sizeof(*sc)) {
+ if (sc0->sc_class->size > device_get_driver(dev)->size) {
sc = malloc(sc0->sc_class->size, M_UART, M_WAITOK|M_ZERO);
bcopy(sc0, sc, sizeof(*sc));
device_set_softc(dev, sc);
@@ -781,11 +781,10 @@ uart_bus_detach(device_t dev)
mtx_destroy(&sc->sc_hwmtx_s);
- if (sc->sc_class->size > sizeof(*sc)) {
+ if (sc->sc_class->size > device_get_driver(dev)->size) {
device_set_softc(dev, NULL);
free(sc, M_UART);
- } else
- device_set_softc(dev, NULL);
+ }
return (0);
}
More information about the svn-src-all
mailing list