Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751534AbeAPWXX (ORCPT + 1 other); Tue, 16 Jan 2018 17:23:23 -0500 Received: from mail-yb0-f193.google.com ([209.85.213.193]:35351 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751396AbeAPWXV (ORCPT ); Tue, 16 Jan 2018 17:23:21 -0500 X-Google-Smtp-Source: ACJfBovpE6IEtIOssJmR2Q1JETrxVKEjdfQGj0xsSuPgl/emJjnVrikBAT2AGYJE+ymlD7NW1ULfbg== Date: Tue, 16 Jan 2018 17:23:19 -0500 From: Sean Paul To: Andrzej Hajda Cc: Philippe Cornu , Daniel Vetter , Gustavo Padovan , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Archit Taneja , Brian Norris , Benjamin Gaignard , Yannick Fertre , Vincent Abriou , Alexandre Torgue Subject: Re: [PATCH] drm/dsi: Fix improper use of mipi_dsi_device_transfer() return value Message-ID: <20180116222319.z3zxpux7e5xp3znc@art_vandelay> References: <20180112144847.18810-1-philippe.cornu@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 15, 2018 at 10:12:24AM +0100, Andrzej Hajda wrote: > On 12.01.2018 15:48, Philippe Cornu wrote: > > The function mipi_dsi_device_transfer() returns the number of transmitted > > or received bytes on success or a negative error code on failure. > > > > The functions mipi_dsi_shutdown_peripheral(), mipi_dsi_turn_on_peripheral() & > > mipi_dsi_set_maximum_return_packet_size() use improperly this returned > > value in case of success: 0 should be returned instead of the number of > > transmitted bytes. > > > > Signed-off-by: Philippe Cornu > > I guess, the best would be to create and use some helper similar to > PTR_ERR_OR_ZERO, > but this is also OK. > > Reviewed-by: Andrzej Hajda Applied to drm-misc-next. Thanks for the patch and review Sean > > ?-- > Regards > Andrzej > > > --- > > drivers/gpu/drm/drm_mipi_dsi.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c > > index 4b47226b90d4..bc73b7f5b9fc 100644 > > --- a/drivers/gpu/drm/drm_mipi_dsi.c > > +++ b/drivers/gpu/drm/drm_mipi_dsi.c > > @@ -498,8 +498,9 @@ int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi) > > .tx_buf = (u8 [2]) { 0, 0 }, > > .tx_len = 2, > > }; > > + int ret = mipi_dsi_device_transfer(dsi, &msg); > > > > - return mipi_dsi_device_transfer(dsi, &msg); > > + return (ret < 0) ? ret : 0; > > } > > EXPORT_SYMBOL(mipi_dsi_shutdown_peripheral); > > > > @@ -517,8 +518,9 @@ int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi) > > .tx_buf = (u8 [2]) { 0, 0 }, > > .tx_len = 2, > > }; > > + int ret = mipi_dsi_device_transfer(dsi, &msg); > > > > - return mipi_dsi_device_transfer(dsi, &msg); > > + return (ret < 0) ? ret : 0; > > } > > EXPORT_SYMBOL(mipi_dsi_turn_on_peripheral); > > > > @@ -541,8 +543,9 @@ int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, > > .tx_len = sizeof(tx), > > .tx_buf = tx, > > }; > > + int ret = mipi_dsi_device_transfer(dsi, &msg); > > > > - return mipi_dsi_device_transfer(dsi, &msg); > > + return (ret < 0) ? ret : 0; > > } > > EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size); > > > > -- Sean Paul, Software Engineer, Google / Chromium OS