Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5765088imm; Mon, 23 Jul 2018 05:49:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfQS+WbPqiyPyJmqZokoyTtP9MPZHzug7mcMZWtxs1QJ6J5udCIUfWzbZ6VRBXsUHmSyNOr X-Received: by 2002:a17:902:8697:: with SMTP id g23-v6mr12767125plo.292.1532350140984; Mon, 23 Jul 2018 05:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532350140; cv=none; d=google.com; s=arc-20160816; b=kwXCHLKdt6cbqPa9UeJ5KqeAXUFulJRkhNAxXmEyOJw0u3ThMFTkmDvYFGp1/fdEU1 MgFL5NUzZvBzOc3V+gcXTR22X6PrUDvFTzLodhE6+IvFXYVljXrs4FTzaLzK8sun9B9X Zizxc6CgWtHcjH5dSmNJ0bzJU63nY6sD64CNY0FbeLN6keA23nL/Lplu+uRYx+tXy6zk tvouYTBAtknDNnTSPlwt/lUdjN3i2tU+lUKLMAcyDmWE4rQzMrO4iF42/nYwgafa8N0j TFESZLM8T41KxEDGy9UE0lIAJm9FNY7fCufhSXAy1X0WbDgXKaJBvK9lhWqpg2VWAT7r NzWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=cALx6GptBewkTx0q1MNh0pGcFgNBk65/ZRGheR+Qjdc=; b=cSlYd4hw/QYPTP9xhoofPzzXe/B0atM1rj5BC6iCBMLd5d29itkwlk3D6zEbbuAm4C ivuZgoZKRWXfpfxZR1B/nIQGmtjSmsOGY+2RtHBUhnhbju8LX+GkKXihEwV3l6NALw9k 6Ed2gQGLr1jZLps2ugAIzxcKBD0sBZJkVIHYmIQyxiCmZSJD7j0XQGGfve7aS05eEov4 WnYEBKzG1oF14gab402c1XsiQZQJ8YLNrJ1cDZEjI1qqRc+R7F4TaQyj/xQuA+MmeBB9 XlFt2ATWZPqUZjoAiLsEtx+nKaUuacDcOIG1yR/4gc9cTcX8+zBkHryv+66AAQosYLox lQxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25-v6si8763999pgk.555.2018.07.23.05.48.46; Mon, 23 Jul 2018 05:49:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389752AbeGWNsY (ORCPT + 99 others); Mon, 23 Jul 2018 09:48:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51930 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388215AbeGWNsX (ORCPT ); Mon, 23 Jul 2018 09:48:23 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 379FBBDB; Mon, 23 Jul 2018 12:47:19 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Weinberger Subject: [PATCH 4.4 102/107] ubi: Introduce vol_ignored() Date: Mon, 23 Jul 2018 14:42:36 +0200 Message-Id: <20180723122418.624558482@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Weinberger commit 243a4f8126fcf7facb04b324dbb7c85d10b11ce9 upstream. This makes the logic more easy to follow. Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/ubi/attach.c | 24 ++++++++++++++++++------ drivers/mtd/ubi/ubi.h | 15 +++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) --- a/drivers/mtd/ubi/attach.c +++ b/drivers/mtd/ubi/attach.c @@ -803,6 +803,20 @@ out_unlock: return err; } +static bool vol_ignored(int vol_id) +{ + switch (vol_id) { + case UBI_LAYOUT_VOLUME_ID: + return true; + } + +#ifdef CONFIG_MTD_UBI_FASTMAP + return ubi_is_fm_vol(vol_id); +#else + return false; +#endif +} + /** * scan_peb - scan and process UBI headers of a PEB. * @ubi: UBI device description object @@ -995,17 +1009,15 @@ static int scan_peb(struct ubi_device *u *vid = vol_id; if (sqnum) *sqnum = be64_to_cpu(vidh->sqnum); - if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOLUME_ID) { + if (vol_id > UBI_MAX_VOLUMES && !vol_ignored(vol_id)) { int lnum = be32_to_cpu(vidh->lnum); /* Unsupported internal volume */ switch (vidh->compat) { case UBI_COMPAT_DELETE: - if (vol_id != UBI_FM_SB_VOLUME_ID - && vol_id != UBI_FM_DATA_VOLUME_ID) { - ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it", - vol_id, lnum); - } + ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it", + vol_id, lnum); + err = add_to_list(ai, pnum, vol_id, lnum, ec, 1, &ai->erase); if (err) --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h @@ -1101,4 +1101,19 @@ static inline int idx2vol_id(const struc return idx; } +/** + * ubi_is_fm_vol - check whether a volume ID is a Fastmap volume. + * @vol_id: volume ID + */ +static inline bool ubi_is_fm_vol(int vol_id) +{ + switch (vol_id) { + case UBI_FM_SB_VOLUME_ID: + case UBI_FM_DATA_VOLUME_ID: + return true; + } + + return false; +} + #endif /* !__UBI_UBI_H__ */