From: Masahiro Yamada Date: Fri, 03 Oct 2014 22:04:23 +0900 Subject: [U-Boot] How does Driver Model UART work? In-Reply-To: <20141003214549.D7B7.AA925319@jp.panasonic.com> References: <20141003214549.D7B7.AA925319@jp.panasonic.com> Message-ID: <20141003220423.D7BB.AA925319@jp.panasonic.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Simon, I am totally being confused. As far as I looked at the dm code, the private data is calloc'ed in device_probe() function if (drv->priv_auto_alloc_size) { dev->priv = calloc(1, drv->priv_auto_alloc_size); if (!dev->priv) { ret = -ENOMEM; goto fail; } } So, dev->priv is storing the address of the allocated memory. Am I understanding correctly? If so, I can't understand the following code: static int ns16550_serial_getc(struct udevice *dev) { struct NS16550 *const com_port = dev_get_priv(dev); if (!serial_in(&com_port->lsr) & UART_LSR_DR) return -EAGAIN; "com_port" is dev->priv, so it is pointing to the allocated area on RAM, I guess. It looks like serial_in(&com_port->lsr) is trying to read from the hardware register ? Or reading from malloc area RAM ?? Best Regards Masahiro Yamada