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.90_1 #2 (Red Hat Linux)) id 1f78A6-0008EF-6X for barebox@lists.infradead.org; Fri, 13 Apr 2018 23:31:25 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sat, 14 Apr 2018 01:30:53 +0200 Message-Id: <20180413233053.15570-4-u.kleine-koenig@pengutronix.de> In-Reply-To: <20180413233053.15570-1-u.kleine-koenig@pengutronix.de> References: <20180413233053.15570-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 4/4] pci: don't hide hard to understand sanity check in size calculation To: barebox@lists.infradead.org cGNpX3NpemUoKSBoYWQgYSBjaGVjayB0aGF0IG1hZGUgaXQgcmV0dXJuIDAgKGkuZS4gYW4gZXJy b3IpIGluIHNvbWUKY2FzZXMuIEl0IHRvb2sgbWUgYSB3aGlsZSB0byB3b3JrIG91dCBpbiB3aGlj aCBzaXR1YXRpb25zIGV4YWN0bHkgdGhpcwpjaGVjayB0cmlnZ2VyZWQ6IElmIHdyaXRpbmcgMHhm ZmZmZmZmZSB0byB0aGUgQkFSIHJlZ2lzdGVyIGRvZXNuJ3QKY2hhbmdlIGl0J3MgdmFsdWUgYW5k IHRoZSBtYXNrZWQgdmFsdWUgaXNuJ3QgaW4gdGhlIGZvcm0gMGIxLi4uLjEwLi4uMC4KClRoaXMg cGF0Y2ggcmVwbGFjZXMgdGhlIGNoZWNrIGluIHBjaV9zaXplKCkgYnkgYSBzaW1pbGFyIGNoZWNr IGluCnNldHVwX2RldmljZSgpIHdoZXJlIGl0IGlzIG1vcmUgZXhwZW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