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-0008ED-4g for barebox@lists.infradead.org; Fri, 13 Apr 2018 23:31:24 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sat, 14 Apr 2018 01:30:51 +0200 Message-Id: <20180413233053.15570-2-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 2/4] pci: refactor bar configuration To: barebox@lists.infradead.org SW5zdGVhZCBvZiBkb2luZyBuZWFybHkgdGhlIHNhbWUgdGhyZWUgdGltZXMgZm9yIHRoZSB0aHJl ZSBkaWZmZXJlbnQKbWVtb3J5IHR5cGVzLCB1c2Ugc29tZSBoZWxwZXIgdmFyaWFibGVzIGFuZCBk byB0aGUgc2FtZSBpbiBhIG1vcmUKZ2VuZXJpYyB3YXkgb25seSBvbmNlLgoKQXBhcnQgZnJvbSBt aW5vciBjaGFuZ2VzIGluIHRoZSBwcl9kZWJ1ZyBvdXRwdXQgdGhlcmUgaXMgbm8gc2VtYW50aWMK Y2hhbmdlIGludGVuZGVkLgoKU2lnbmVkLW9mZi1ieTogVXdlIEtsZWluZS1Lw7ZuaWcgPHUua2xl aW5lLWtvZW5pZ0BwZW5ndXRyb25peC5kZT4KLS0tCiBkcml2ZXJzL3BjaS9wY2kuYyB8IDEwNCAr KysrKysrKysrKysrKysrKysrKysrLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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