summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2017-10-25 14:34:22 +0000
committerkettenis <kettenis@openbsd.org>2017-10-25 14:34:22 +0000
commita834c8533f497e61c4d5b0ce293443c0d0846be2 (patch)
tree7de7105ed18a211fc2aeb3dcc1c4410132f6ab8e
parentDefault allow-rename to off because it is ridiculous that applications (diff)
downloadwireguard-openbsd-a834c8533f497e61c4d5b0ce293443c0d0846be2.tar.xz
wireguard-openbsd-a834c8533f497e61c4d5b0ce293443c0d0846be2.zip
Storing the address of a stack variable in a global variable is a bad idea.
Rework the code to store the relevant information in the softc. As a bonus, this reduces the stack space that is used such that this file compiles with clang. ok ians@
-rw-r--r--sys/arch/armv7/omap/amdisplay.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/sys/arch/armv7/omap/amdisplay.c b/sys/arch/armv7/omap/amdisplay.c
index 90008866ad1..c61446f88f7 100644
--- a/sys/arch/armv7/omap/amdisplay.c
+++ b/sys/arch/armv7/omap/amdisplay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: amdisplay.c,v 1.6 2017/09/11 05:50:53 jsg Exp $ */
+/* $OpenBSD: amdisplay.c,v 1.7 2017/10/25 14:34:22 kettenis Exp $ */
/*
* Copyright (c) 2016 Ian Sutton <ians@openbsd.org>
*
@@ -74,7 +74,7 @@ struct amdisplay_softc {
#define LCD_MODE_COMPAT (1 << 1)
#define LCD_MODE_ALLOC (1 << 2)
- struct edid_info *sc_edid;
+ struct edid_info sc_edid;
struct videomode *sc_active_mode;
int sc_active_depth;
@@ -179,7 +179,6 @@ amdisplay_attach(struct device *parent, struct device *self, void *args)
struct amdisplay_softc *sc = (struct amdisplay_softc *) self;
struct fdt_attach_args *faa = args;
struct wsemuldisplaydev_attach_args wsaa;
- struct edid_info edid;
uint64_t pel_clk = 0;
uint32_t reg;
uint8_t *edid_buf;
@@ -213,25 +212,23 @@ amdisplay_attach(struct device *parent, struct device *self, void *args)
sc->sc_flags |= LCD_MODE_ALLOC;
if (nxphdmi_get_edid(edid_buf, EDID_LENGTH) ||
- edid_parse(edid_buf, &edid)) {
+ edid_parse(edid_buf, &sc->sc_edid)) {
printf("%s: no display attached.\n", DEVNAME(sc));
free(edid_buf, M_DEVBUF, EDID_LENGTH);
amdisplay_detach(self, 0);
return;
}
- sc->sc_edid = &edid;
-
#ifdef LCD_DEBUG
- edid_print(&edid);
+ edid_print(&sc->sc_edid);
#endif
/* determine max supported resolution our clock signal can handle */
- for (; i < edid.edid_nmodes - 1; i++) {
- if (edid.edid_modes[i].dot_clock < LCD_MAX_PELCLK &&
- edid.edid_modes[i].dot_clock > pel_clk) {
- pel_clk = edid.edid_modes[i].dot_clock;
- memcpy(sc->sc_active_mode, &edid.edid_modes[i],
+ for (; i < sc->sc_edid.edid_nmodes - 1; i++) {
+ if (sc->sc_edid.edid_modes[i].dot_clock < LCD_MAX_PELCLK &&
+ sc->sc_edid.edid_modes[i].dot_clock > pel_clk) {
+ pel_clk = sc->sc_edid.edid_modes[i].dot_clock;
+ memcpy(sc->sc_active_mode, &sc->sc_edid.edid_modes[i],
sizeof(struct videomode));
}
}
@@ -377,9 +374,6 @@ amdisplay_detach(struct device *self, int flags)
{
struct amdisplay_softc *sc = (struct amdisplay_softc *)self;
- if (sc->sc_edid)
- free(sc->sc_edid, M_DEVBUF, sizeof(struct edid_info));
-
if (ISSET(sc->sc_flags, LCD_MODE_ALLOC))
free(sc->sc_active_mode, M_DEVBUF, sizeof(struct videomode));