Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754956AbeAOJMr (ORCPT + 1 other); Mon, 15 Jan 2018 04:12:47 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:39131 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932689AbeAOJMa (ORCPT ); Mon, 15 Jan 2018 04:12:30 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180115091227euoutp021caa3092a60bd9cab703a8d19d9a9452~J8NUd_kFT0168101681euoutp02k X-AuditID: cbfec7f4-f790c6d0000075d3-ee-5a5c707b12d1 MIME-version: 1.0 Content-type: text/plain; charset="utf-8" Subject: Re: [PATCH] drm/dsi: Fix improper use of mipi_dsi_device_transfer() return value To: Philippe Cornu , Daniel Vetter , Gustavo Padovan , Sean Paul , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Archit Taneja , Brian Norris , Benjamin Gaignard , Yannick Fertre , Vincent Abriou , Alexandre Torgue From: Andrzej Hajda Message-id: Date: Mon, 15 Jan 2018 10:12:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 In-reply-to: <20180112144847.18810-1-philippe.cornu@st.com> Content-transfer-encoding: 8bit Content-language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA01SfSyUcRzv97zdwzz2dK786EW7rZoWqawekbHFntWaXv6IY6sbz7AcusOQ ysudl5NjJ9MumU2k1uRtxNikhRDOa5a4trwukbdUsrjnbP77fL+fz+f7ti+JCgdwWzI0PIqT h0vDxIQ5Vtv6u9vhbmSAxEmZQjBZ3R8QpvJbJ2CS0+dwJrmlg2Cqfs7jzPOucpQZWJknmHpD g4DpbyggGINyGme+VHwETNdgM8akZagID4p9kqjH2H5NFsIWN84g7OhQI8HWrRpwdjyzDWHr tU0IO7HWhLJLVQevmEnM3YK4sNAYTn7C/ZZ5SFf+FB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NmEIdZoJtJ4vHSTUwQLRMYJZbN/sMO0sImoCnxd/NNNogVdhITXnxiBLFZBFQl 3i7oYgaxRQUiJJpmzmUFsTkFrCUe/LkOto5ZQF7i4JXnLBC2uERz602WCYyCs5BcOwvh2llI OmYh6VjAyLKKUSS1tDg3PbfYSK84Mbe4NC9dLzk/dxMjMPa2Hfu5ZQdj17vgQ4wCHIxKPLwR y6KjhFgTy4orcw8xSnAwK4nwNgbHRAnxpiRWVqUW5ccXleakFh9ilOZgURLn7d2zOlJIID2x JDU7NbUgtQgmy8TBKdXA2O76STTIf7Ei36eeCoMpM5Xdtk6Z8GsjT3tCQMxe1hXZSjPfvvn6 jKUm3ntKhuypD8xLyjm+vnXcvP3ULUG/2j3TTvpduJvUe21aZc7MC85rnqbkrejXdXnWZbE7 VmizU2WjVIXTlefFzxRaYpfz16Xy/DFKcN6l+K6Jb7n/p0s5ac56FZ2ySizFGYmGWsxFxYkA 2DG3b7kCAAA= X-CMS-MailID: 20180115091226eucas1p13bd41d03dd59965bfa1ef5e6d2388d31 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180112144953epcas2p3046bd1b5cb6de9a616c5e6688cee97b4 X-RootMTR: 20180112144953epcas2p3046bd1b5cb6de9a616c5e6688cee97b4 References: <20180112144847.18810-1-philippe.cornu@st.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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  -- 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); >