From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail.tricorecenter.de ([217.6.246.34] helo=root.phytec.de) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b6CTj-0005ON-Vq for barebox@lists.infradead.org; Fri, 27 May 2016 07:46:46 +0000 Received: from idefix.phytec.de (idefix.phytec.de [172.16.0.10]) by root.phytec.de (Postfix) with ESMTP id 4572EA00AF7 for ; Fri, 27 May 2016 09:46:39 +0200 (CEST) From: Teresa Remmet Date: Fri, 27 May 2016 09:44:14 +0200 Message-Id: <1464335095-35180-22-git-send-email-t.remmet@phytec.de> In-Reply-To: <1464335095-35180-1-git-send-email-t.remmet@phytec.de> References: <1464335095-35180-1-git-send-email-t.remmet@phytec.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 v2 21/62] UBI: Fastmap: Make ubi_refill_pools() fair To: barebox@lists.infradead.org RnJvbTogUmljaGFyZCBXZWluYmVyZ2VyIDxyaWNoYXJkQG5vZC5hdD4KCkN1cnJlbnRseSB1Ymlf cmVmaWxsX3Bvb2xzKCkgZmlyc3QgZmlsbHMgdGhlIGZpcnN0IGFuZCB0aGVuCnRoZSBzZWNvbmQg b25lLgpJZiBvbmx5IHZlcnkgZmV3IGZyZWUgUEVCcyBhcmUgYXZhaWxhYmxlIHRoZSBzZWNvbmQg cG9vbCBjYW4gZ2V0Cnplcm8gUEVCcy4KQ2hhbmdlIHViaV9yZWZpbGxfcG9vbHMoKSB0byBkaXN0 cmlidXRlIGZyZWUgUEVCcyBmYWlyIGJldHdlZW4KYWxsIHBvb2xzLgoKU2lnbmVkLW9mZi1ieTog UmljaGFyZCBXZWluYmVyZ2VyIDxyaWNoYXJkQG5vZC5hdD4KUmV2aWV3ZWQtYnk6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