Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp346006ybl; Fri, 9 Aug 2019 06:55:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh5P0EwVhwvgseH1hwoDeqMymHcwysF1qkLP3ncavwyugzEx+Db53DgPOtLI5HTnG2SMoi X-Received: by 2002:a65:6401:: with SMTP id a1mr17679105pgv.42.1565358956443; Fri, 09 Aug 2019 06:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565358956; cv=none; d=google.com; s=arc-20160816; b=QdQBtoCSlYjg4OwKWkdvWEb3ZCNDK3smduSSAptF4c6MBLkcBY6TON7DfLtZsCxle5 Mgh6HZIVPjIXK55pX71EC4UUjkTHnPStGFal7lVKZjsQCueHmqDvOsWLL1a0lrsK2j4u Wxlb0CKEsj4hPmEH69GGqT720qBWIzX4OBtXO3Ld7DSverv6T7/sukr08gSQp4PddfRH uKHzoeXK7tn1ZQkVdndX+CqJ5/9hyacghwFMpWbSoh7+nYdWXrvV3LJZNwLVAZT8wr5g p0MT26Ic55MxsLGTSjx1jEcamx+3oCB+KCsjXRAwsRRU0h+0eGoMtVFnmy99/ij/PpBP tSHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=OI9zDGHGeCGGvtODdLcpKp6iIHLFrOLDzUoLKiAKTWs=; b=x5tIwrVHdqVseF1qyjC3dJMJ1uvSXOklADsIIfaH+loonbCrLclsCbpLuAa8Mlso9w 4So3nRmCHLDLTOPM0fxGdpX+oDh6ysFyzbDeRkDDlMZjlAU6J30fTfGvGJ+6sEeZjo10 AmPFg226HSIm44ke+SkwCPSvO+8JQd+j4F+PqzHhmMvtU+5ex/8p8C2vS7BQ7i+XFkuA 7ZH9dDZUK6qO1HlTeqJV5aCu2srSgbPnjWyfc4YcLGzh0hPFkFcwoFilqSBTQFWkfKk7 xGhJESu37d03z4aPsfVCDnH1Lz+gZkHTZ8mt8mn4umjun9yBzWL3ZZjN0zyAw8+dKbjo begg== 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 i11si20974663pgk.309.2019.08.09.06.55.39; Fri, 09 Aug 2019 06:55:56 -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 S2406722AbfHINyo (ORCPT + 99 others); Fri, 9 Aug 2019 09:54:44 -0400 Received: from foss.arm.com ([217.140.110.172]:47700 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726216AbfHINyo (ORCPT ); Fri, 9 Aug 2019 09:54:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0363C1596; Fri, 9 Aug 2019 06:54:44 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BCE773F706; Fri, 9 Aug 2019 06:54:42 -0700 (PDT) Date: Fri, 9 Aug 2019 14:54:40 +0100 From: Mark Rutland To: Joe Burmeister Cc: Rob Herring , Arnd Bergmann , Greg Kroah-Hartman , Srinivas Kandagatla , YueHaibing , Bartosz Golaszewski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Add optional chip erase functionality to AT25 EEPROM driver. Message-ID: <20190809135440.GI48423@lakrids.cambridge.arm.com> References: <20190809125358.24440-1-joe.burmeister@devtank.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190809125358.24440-1-joe.burmeister@devtank.co.uk> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 09, 2019 at 01:53:55PM +0100, Joe Burmeister wrote: > Many, though not all, AT25s have an instruction for chip erase. > If there is one in the datasheet, it can be added to device tree. > Erase can then be done in userspace via the sysfs API with a new > "erase" device attribute. This matches the eeprom_93xx46 driver's > "erase". > > Signed-off-by: Joe Burmeister > --- > .../devicetree/bindings/eeprom/at25.txt | 2 + > drivers/misc/eeprom/at25.c | 83 ++++++++++++++++++- > 2 files changed, 82 insertions(+), 3 deletions(-) > > diff --git a/Documentation/devicetree/bindings/eeprom/at25.txt b/Documentation/devicetree/bindings/eeprom/at25.txt > index b3bde97dc199..c65d11e14c7a 100644 > --- a/Documentation/devicetree/bindings/eeprom/at25.txt > +++ b/Documentation/devicetree/bindings/eeprom/at25.txt > @@ -19,6 +19,7 @@ Optional properties: > - spi-cpha : SPI shifted clock phase, as per spi-bus bindings. > - spi-cpol : SPI inverse clock polarity, as per spi-bus bindings. > - read-only : this parameter-less property disables writes to the eeprom > +- chip_erase_instruction : Chip erase instruction for this AT25, often 0xc7 or 0x62. This should be using '-' rather than '_', as per general DT conventions and as with the existing properties. > Obsolete legacy properties can be used in place of "size", "pagesize", > "address-width", and "read-only": > @@ -39,4 +40,5 @@ Example: > pagesize = <64>; > size = <32768>; > address-width = <16>; > + chip_erase_instruction = <0x62>; [...] > + /* Optional chip erase instruction */ > + device_property_read_u8(&spi->dev, "chip_erase_instruction", &at25->erase_instr); This will not behave as you expect, since you didn't mark the property as 8-bits. Read this as a u32 into the existing val temporary variable, as is done for pagesize. You can add a warnign if it's out-of-range. Thanks, Mark.