[U-Boot] [PATCH] serial: bcm283x_mu: make pending values more explicit

dm_serial_ops.pending should return the number of characters, not just a valid C Boolean integer value. The existing code does already does this, but only as an accident since BCM283X_MU_LSR_RX_READY happens to be BIT(0). Enhance the code to be more explicit about the values it returns.
Suggested-by: Simon Glass sjg@chromium.org Signed-off-by: Stephen Warren swarren@wwwdotorg.org --- drivers/serial/serial_bcm283x_mu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index fc36bc0e85d6..7357bbfb2679 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -116,9 +116,9 @@ static int bcm283x_mu_serial_pending(struct udevice *dev, bool input)
if (input) { WATCHDOG_RESET(); - return lsr & BCM283X_MU_LSR_RX_READY; + return (lsr & BCM283X_MU_LSR_RX_READY) ? 1 : 0; } else { - return !(lsr & BCM283X_MU_LSR_TX_IDLE); + return (lsr & BCM283X_MU_LSR_TX_IDLE) ? 0 : 1; } }

On 13 April 2016 at 22:29, Stephen Warren swarren@wwwdotorg.org wrote:
dm_serial_ops.pending should return the number of characters, not just a valid C Boolean integer value. The existing code does already does this, but only as an accident since BCM283X_MU_LSR_RX_READY happens to be BIT(0). Enhance the code to be more explicit about the values it returns.
Suggested-by: Simon Glass sjg@chromium.org Signed-off-by: Stephen Warren swarren@wwwdotorg.org
drivers/serial/serial_bcm283x_mu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Wed, Apr 13, 2016 at 10:29:52PM -0600, Stephen Warren wrote:
dm_serial_ops.pending should return the number of characters, not just a valid C Boolean integer value. The existing code does already does this, but only as an accident since BCM283X_MU_LSR_RX_READY happens to be BIT(0). Enhance the code to be more explicit about the values it returns.
Suggested-by: Simon Glass sjg@chromium.org Signed-off-by: Stephen Warren swarren@wwwdotorg.org
Applied to u-boot/master, thanks!
participants (3)
-
Simon Glass
-
Stephen Warren
-
Tom Rini