From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dczUR-0005ub-Ex for barebox@lists.infradead.org; Wed, 02 Aug 2017 19:39:33 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Wed, 2 Aug 2017 21:39:06 +0200 Message-Id: <20170802193907.4317-2-u.kleine-koenig@pengutronix.de> In-Reply-To: <20170802193907.4317-1-u.kleine-koenig@pengutronix.de> References: <20170802193907.4317-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 1/2] spi: imx: add error checking To: barebox@lists.infradead.org VGhpcyBtYWtlcyBpdCBwb3NzaWJsZSB0aGF0IHRoZSB4Y2hnX3NpbmdsZSBjYWxsYmFja3MgcmV0 dXJuIGFuIGVycm9yIGNvZGUgdGhhdAppcyB0aGVuIHBhc3NlZCB0byB0aGUgY2FsbGVyIG9mIHNw aV90cmFuc2Zlci4gVGhlcmUgaXMgbm8gY2hhbmdlIGluIGJlaGF2aW91cgppbnRlbmRlZCBhcyB1 cCB0byBub3cgdGhlIGNhbGxiYWNrcyBhbHdheXMgcmV0dXJuIDAuCgpTaWduZWQtb2ZmLWJ5OiBV d2UgS2xlaW5lLUvDtm5pZyA8dS5rbGVpbmUta29lbmlnQHBlbmd1dHJvbml4LmRlPgotLS0KIGRy aXZlcnMvc3BpL2lteF9zcGkuYyB8IDc3ICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr LS0tLS0tLS0tLS0tLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDQ4IGluc2VydGlvbnMoKyksIDI5 IGRlb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