Port-macppc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Uninitialized field and duplicated function in kauai.c ?
Hi,
Reading the arch/macppc/dev/kauai.c driver I found something strange
regarding the 'sc_dmacmd' field for the buffer of DBDMA commands:
It's defined as a pointer in kauai_softc (line numbers are for rev. 1.24):
61 struct kauai_softc {
[...]
68 dbdma_command_t *sc_dmacmd;
[...]
74 };
However, such filed is nowhere initialized to point to a valid
allocated buffer. kauai_attach() just tests if the buffer is 16-byte
aligned as required by DBDMA, but as it's not initialized, it points
to address 0 so the error should never be triggered:
106 void
107 kauai_attach(device_t parent, device_t self, void *aux)
108 {
[...]
119 #ifdef DIAGNOSTIC
120 if ((vaddr_t)sc->sc_dmacmd & 0x0f) {
121 aprint_error(": bad dbdma alignment\n");
122 return;
123 }
124 #endif
Then this uninitialized pointer is used by kauai_dma_init() :
286 int
287 kauai_dma_init(void *v, int channel, int drive, void *databuf,
288 size_t datalen, int flags)
289 {
290 struct kauai_softc *sc = v;
291 dbdma_command_t *cmdp = sc->sc_dmacmd;
[...]
310 DBDMA_BUILD(cmdp, cmd, 0, rest, vtophys(va),
It looks like it was meant to be defined as an array in the softc or
allocated with the dbdma_alloc() function (which is what wdc_obio.c
does), which in addition also makes sure the buffer is 16-byte
aligned.
There is also a private function defined in kauai.c, getnodebypci(),
which is line-for-line identical to the pcidev_to_ofdev() function
defined in arch/powerpc/oea/ofw_autoconf.c (in 4.0 it's on
arch/macppc/macppc/autoconf.c).
83 static int getnodebypci(pci_chipset_tag_t, pcitag_t);
[...]
126 node = getnodebypci(pa->pa_pc, pa->pa_tag);
[...]
357 /*
358 * Find OF-device corresponding to the PCI device.
359 */
360 int
361 getnodebypci(pci_chipset_tag_t pc, pcitag_t tag)
[...]
-----
Marco
Home |
Main Index |
Thread Index |
Old Index