From patchwork Thu Jan 10 12:38:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Looijmans X-Patchwork-Id: 1022893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43e; helo=mail-wr1-x43e.google.com; envelope-from=swupdate+bncbaabbr7z3tqqkgqeupxeoma@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=topic.nl Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="ZQCFiTJi"; dkim-atps=neutral Received: from mail-wr1-x43e.google.com (mail-wr1-x43e.google.com [IPv6:2a00:1450:4864:20::43e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43b5Bz0FzTz9sCs for ; Thu, 10 Jan 2019 23:38:34 +1100 (AEDT) Received: by mail-wr1-x43e.google.com with SMTP id w12sf3103502wru.20 for ; Thu, 10 Jan 2019 04:38:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1547123911; cv=pass; d=google.com; s=arc-20160816; b=oK1FNrezkSItN4N84PZ7NufmP66PHiFdkRLcoilMRnJoAWpeWTPdEjr809sxGR8qP2 tSFjqMKEjSu2fCSz6idMbVJqbM2L1Nve0GlgFXf3Z1xF5wVvkTUn2kL4mPdQBC+gfhyt Wm1JqYmZryZ/BhzqWD/HcJYFKecXQHSXJIlWvE0cEFE7iSZpEwPvS3XX78MWt06qA6Dj +v1fRydtJ9XFeCZpLrDWqz/583gMM8gvuN/lIle4rVUcRPpttxFB79+/IBTOcAL5KYzB 3wXf5E1vroDmdbkY3TzDvIRxXiEl7NyS3HgYTkMRfCQvHxDa7jTwGXIKDZgQw4jghkYW qjpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :mime-version:sender:dkim-signature; bh=ckxlEHpf9+rTSCRF0ZhhV1PU5KDGCWo6yq38nf/bnEc=; b=Ave18mmPmGvJFCS3qLBgC+PdL70kUljMVTjr4ULIPIh2EiKJVtXhOdeh+zNR4vOi0n SOJmWdiwyXRvPc2/CfchB6wckz9reKs/scLe3I8xTEV213wKDmsJBEcSkBo51nvolpfz w2X9afj1YbRqsw3R2hzf+YlVrLlN4p1QM/sDPA/WH7oMlSfY8gx3AY+ohDDSxRqE+wci 97sf5ukumSX9uxzEhAhRvDfS7SAwfzpqpb80jr2QOrRn6vciDXXQYN1GuiM7SS088eaS pQpyp+tAoEs8+24v1hlAqF9/+K15eZ0GW2K2Qe9IyuL9fzbSpTnP7xFdq0SKgvmL+VH7 nifg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=fail (google.com: domain of mike.looijmans@topic.nl does not designate 194.134.25.72 as permitted sender) smtp.mailfrom=mike.looijmans@topic.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ckxlEHpf9+rTSCRF0ZhhV1PU5KDGCWo6yq38nf/bnEc=; b=ZQCFiTJi25b0Yj4vEq70Mauko8zysrMebZVBm107HjVDb38tiAxIUixeFFucj3F5zn /7g4qLw1bvkU3ZT6l126ie/wEf8x/x94NEOViJ6UfyncttJ7INdCSAUGngiY/LMiRkw1 M/jg4Wfdd+gJMQzBOGcM0nZYAEoZhqR5sCotcMTzzEnhM1yxiZJjbFF/ijPF6vsK9acu rVuXVWUtRSjV4FfEFu3vTS9CJlf6N4AzfPdFrBmJQozYxuFZGQvr8xQbRmLV+FRsdwoV 1ePa/2J752v8ANsHVCrExC6DH/aS3N5f5KUwm7rKmiFX4sR95dwfvWSglqbxTEkyFMtC 8V5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=ckxlEHpf9+rTSCRF0ZhhV1PU5KDGCWo6yq38nf/bnEc=; b=AU+bdFXw3GsnxUlFEbz1howLh3aOPimFUZnMVngRnyDi5C210tMRF8fMUvuJ1sAwpA tD+i0PrUBxJfXkhGONneKpX2vfcIg9+5rDLGxnTAX63Z3OaSw3rm6WHt8vGvTgpzPVEt kMT3namRBZix53QAI/XJ0l42L82Ac/BeOmgDbi3xkExlSuYiDVh+bOqFolC7cZexmvSv X1IYKcaoM/hGA253U/Ia6mvJ0VRR2ReDYmVCIwMmfMlnRx0CSetNr3xReBmvFk3NFjZc hMreYjYWTCHmygJ87FmoTmSTUxQ6luCzJsU6PErtd/pC6zcbP8GYN7IUK60Uh9QvNXNS k4Yw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AJcUukc+4CmiV5nzky6VQOmTVf5IcvjzZnD/cK+640nBx9j/RG+IMnHE XsgQInQcr3Y5xqR6tCK+I3g= X-Google-Smtp-Source: ALg8bN4Y7/Y2tDftjsDFHPfJCvC+TjvwTSavAgahGi+RiHrMkOQTBOk4z56juruoXSVfGuSoqOnnfQ== X-Received: by 2002:a5d:45c5:: with SMTP id b5mr61741wrs.7.1547123911700; Thu, 10 Jan 2019 04:38:31 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:9c48:: with SMTP id f69ls1595371wme.7.gmail; Thu, 10 Jan 2019 04:38:31 -0800 (PST) X-Received: by 2002:a1c:2088:: with SMTP id g130mr491193wmg.6.1547123911352; Thu, 10 Jan 2019 04:38:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547123911; cv=none; d=google.com; s=arc-20160816; b=O98KRQ1VdlQGmpEJfiGBNZhp5f4pNn3seGzPVNQoAgP60SLeH15Elsb5Pe/tJxpUBr /VYJMqrWuuPWialjbCUoYY3PWfdXp+TzBucBnroPCjDthVkVfZbfocHurBjfnyrwAR2q zW5Y+C0noX3gA9oM8OuUiXtchJv5tcYmFUXz+SZjYYvzjk4dTZFtjDujkD53kqj7AURK P0lfb0gcH9AFEDxF2CgfH2ew40+uZ7pVj4J2mQakVU87VdGLgywupfRwIeezYcMhAoXX T0F+9KmK5ucEPkkAXACZ9Pb5LSQdzC138obXbXwFZMiC8Gb0T0LhxNkU2f8UoWLyBvtO ug0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=udEL1yHuoPg8AUHf4SVEGISf20ADcfgpwUriwc3ZkwE=; b=nt47jBRy43sWjcBPIVaa4RplubXro1LEFImlIP5DExBHigFfM/ArGKv6oPxNDJaz9K 1gsSmuJEmoyGwzN+PlKndkoQttli3T2rZ135bH6WlKmlzhL8BbwVgietAN0FCmTNa4N3 XJhZIKN9uThJjEsdlUehCXwKrD5G54MvjUtA4nLhNxDtRORqUaha/5cFdjfev3hU2G+2 DDodXNj5KyYJOyC549vOSpsIuNewTvGOGfiUUrty5mSOOkHSFfrzEAlAwCcq6ZMP+gF8 YuIZIpUsvLsJX0wzZ0jP9leNN8jPCsYp2zhHUWNz5CRpT18uEzIJmMUHjcxlF6GvquEc 4yAA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=fail (google.com: domain of mike.looijmans@topic.nl does not designate 194.134.25.72 as permitted sender) smtp.mailfrom=mike.looijmans@topic.nl Received: from smtp02.mail.online.nl (smtp02.mail.online.nl. [194.134.25.72]) by gmr-mx.google.com with ESMTP id x13si2593822wrn.3.2019.01.10.04.38.31 for ; Thu, 10 Jan 2019 04:38:31 -0800 (PST) Received-SPF: fail (google.com: domain of mike.looijmans@topic.nl does not designate 194.134.25.72 as permitted sender) client-ip=194.134.25.72; Received: from localhost.localdomain (s55969068.adsl.online.nl [85.150.144.104]) by smtp02.mail.online.nl (Postfix) with ESMTP id 0186E1A008F; Thu, 10 Jan 2019 13:38:29 +0100 (CET) From: Mike Looijmans To: swupdate@googlegroups.com Cc: Mike Looijmans Subject: [swupdate] [PATCH] mtd-interface: Properly handle flash devices without lock support Date: Thu, 10 Jan 2019 13:38:14 +0100 Message-Id: <20190110123814.14545-1-mike.looijmans@topic.nl> X-Mailer: git-send-email 2.17.1 X-Original-Sender: mike.looijmans@topic.nl X-Original-Authentication-Results: gmr-mx.google.com; spf=fail (google.com: domain of mike.looijmans@topic.nl does not designate 194.134.25.72 as permitted sender) smtp.mailfrom=mike.looijmans@topic.nl Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , mtd_is_locked() returns a negative value if the flash driver does not support (or require) locking. In that case, the flash routine should not attempt to call further (un)lock functions, they will only result in logging like this: libmtd: error!: MEMUNLOCK ioctl failed for eraseblock 20 (mtd4) error 95 (Operation not supported) To fix the issue, check that the return value is above zero. Signed-off-by: Mike Looijmans --- corelib/mtd-interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/corelib/mtd-interface.c b/corelib/mtd-interface.c index 7ea9bb4..ccbe178 100644 --- a/corelib/mtd-interface.c +++ b/corelib/mtd-interface.c @@ -83,7 +83,7 @@ int flash_erase(int mtdnum) } /* Unlock memory if required */ - if (mtd_is_locked(mtd, fd, eb)) { + if (mtd_is_locked(mtd, fd, eb) > 0) { if (mtd_unlock(mtd, fd, eb) != 0) { if (errno != EOPNOTSUPP) { TRACE("%s: MTD unlock failure", mtd_device);