Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1060637rdb; Mon, 19 Feb 2024 03:04:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUTFo2//pg+mw83H+b0HKuCZmXHVsvxH4cEHFXMK9kfteEFhYwL5R6BVV5BsoG2/UOy0+I8avyzpUJnVQNbzX1V9DJyutvhV9WTIhDMuw== X-Google-Smtp-Source: AGHT+IFgbJcu7R7alw71rFI7ngUBfobmmnrqlJW4Oep5z+N6XwRaKfReC/dcazMSidPUcugQ7hNF X-Received: by 2002:a05:622a:c9:b0:42e:1265:71e6 with SMTP id p9-20020a05622a00c900b0042e126571e6mr2424805qtw.4.1708340671303; Mon, 19 Feb 2024 03:04:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708340671; cv=pass; d=google.com; s=arc-20160816; b=QPhbN5D2ImO5HmFx8mjGLykFYq4s+Xq18amq1O89svuiz3ZUZC0IdJFtLzfJGcFbI3 q/0iaAMrzTSUOmld1KSZPPxP3T/uKEI+jfRGpI3NspJYpjfSAaWHLDE27pAafxAt7uVO rZCm4UZyE1X5ytAOGIKn+qsgHtefjNK8q3jk57a4K9LkZuUXGFQJaOzTFQ9/7u4Jwn0P 8zitqzqraixPjho3d4ALx+nDsqokqUtFZ+dHosXRI8wrU0zpYWfyLQSngoZuzPX7OSL9 9S2l/XEbA4Z+gs/iv6qA3Q5zitwIkUSYqTJyoCyxTDvgz6fUJbOjyQcphgv1ahwzjLYC brhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=x8NgPd3ichHUKUe1/b2p+TzQDwQB7pbYETz/ptF4PXI=; fh=oEu9yxd4afSsqF9Yx4ceXHjjjc+0kAMvn2S+63QfsW0=; b=Z26penhnQtAWEcQyb9ttcYdlM9fU+KjiROc5pWesraK2ubthnMXYqadUdxqwQq5fNJ stymdwkiVIjEmaYDcZwaTJBsZOY9xzXnM7Ryx6/v96ESXn9TXumpFTT0q/3SEMPDg8Yx ShOl4EK0QKjt/QIiI5JgJcBRdfQzqknG6yD7XYj96NjlI7WLWi8GxhbEy1+DN/975rF3 tHNf2+3ms5HCOT8uyE29WGnkKbks6pzspu+2DdI5dhblSS+1CBtW/v6UI8SAY6XasT40 geuPZY3HOESMj2sQi2pKkOJ4GIUSL1eXP/VVdPMcfcMFihyDaXlx/3HrSbXdoX0JzPXa 9QCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XoPxeI8r; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-71172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y8-20020ac85248000000b0042c80daaf72si5456274qtn.747.2024.02.19.03.04.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 03:04:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XoPxeI8r; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-71172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0C8C21C221F9 for ; Mon, 19 Feb 2024 11:04:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDDDD29408; Mon, 19 Feb 2024 11:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XoPxeI8r" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ED861C10 for ; Mon, 19 Feb 2024 11:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708340666; cv=none; b=DKW2omc7c1WbLDcEl5SYsc0K72yQ1M5iLVUYTWhcXlu9hNHpChq/o4CDs7MlVqpY+u53sQLbYoaKNGbvlQ/K6gt/h6cuDG1e7zIaaejN/vGzrVBw5zP9WX37Sft8IPYYLIXyeypMlgxiRvRDicQ5WH060om+0wneVHtR/3+4wKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708340666; c=relaxed/simple; bh=/w0iYygLzqoKWkoa611dONSmQSfaIjtKlgKCivWQdS0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mBvb3zHCXB83QcjYn+uEFfs4P7grfjJVXCizRZsCrKj0wK70Ua9U7Lwi90QLzeQH/FfeU08vycyAQKaTDNMbYaS6nRD1G/lXq76ACNVg7HwUH6fBRmhOWottp7qiO3a5q+yV+kA24uS/tzlovJP2+L8AW0VfGtmq0WShUmRt5SM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=XoPxeI8r; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 97AD4E000E; Mon, 19 Feb 2024 11:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708340656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8NgPd3ichHUKUe1/b2p+TzQDwQB7pbYETz/ptF4PXI=; b=XoPxeI8rJLGBVbcQ6ynl63IreWXv4XK5NDJha/2Xm5BetwHusMR0B8bUU87kdPC+3i2VW9 wYF+jzFrrzbrAH1d3iimT/oAb0HJko4hmhyKvtEkZUSdqyy2+P9seIiuFqETb+w1ZXGNl1 SIPtsa+2fwlowOpH/G9dTu/JLTMlPxBQ63p7Qaa2G8A6qiy7cSZV1/RJDXi0Q8BDmQDuo6 C2lZp3T9l1sQYdd6YzzjjnW4NYMLex3rrktEeQoTOmoU/ECONU7VjC5T9JiLSf1m4BF++w YgmsMBuhSMt1GeTjH8vf30JOPqyM4f/xcjyW9XSDAIs6OqrXW9Scg1pBUvRXnw== Date: Mon, 19 Feb 2024 12:04:14 +0100 From: Miquel Raynal To: Marco Felsch Cc: Michael Walle , srinivas.kandagatla@linaro.org, gregkh@linuxfoundation.org, rafal@milecki.pl, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [RFC PATCH] nvmem: core: add sysfs cell write support Message-ID: <20240219120414.32395299@xps-13> In-Reply-To: <20240216100750.zxl4wncbgpulr2cc@pengutronix.de> References: <20240215211401.1201004-1-m.felsch@pengutronix.de> <20240216100750.zxl4wncbgpulr2cc@pengutronix.de> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com Hi Marco, m.felsch@pengutronix.de wrote on Fri, 16 Feb 2024 11:07:50 +0100: > Hi Michael, >=20 > On 24-02-16, Michael Walle wrote: > > Hi, > >=20 > > On Thu Feb 15, 2024 at 10:14 PM CET, Marco Felsch wrote: =20 > > > @@ -432,6 +466,7 @@ static int nvmem_populate_sysfs_cells(struct nvme= m_device *nvmem) > > > struct bin_attribute **cells_attrs, *attrs; > > > struct nvmem_cell_entry *entry; > > > unsigned int ncells =3D 0, i =3D 0; > > > + umode_t mode; > > > int ret =3D 0; > > > =20 > > > mutex_lock(&nvmem_mutex); > > > @@ -456,15 +491,18 @@ static int nvmem_populate_sysfs_cells(struct nv= mem_device *nvmem) > > > goto unlock_mutex; > > > } > > > =20 > > > + mode =3D nvmem_bin_attr_get_umode(nvmem); > > > + > > > /* Initialize each attribute to take the name and size of the cell = */ > > > list_for_each_entry(entry, &nvmem->cells, node) { > > > sysfs_bin_attr_init(&attrs[i]); > > > attrs[i].attr.name =3D devm_kasprintf(&nvmem->dev, GFP_KERNEL, > > > "%s@%x", entry->name, > > > entry->offset); > > > - attrs[i].attr.mode =3D 0444; =20 > >=20 > > cells are not writable if there is a read post process hook, see > > __nvmem_cell_entry_write(). > >=20 > > if (entry->read_post_processing) > > mode &=3D ~0222; =20 >=20 > good point, thanks for the hint :) I will add this and send a non-rfc > version if write-support is something you would like to have. I like the idea but, what about mtd devices (and soon maybe UBI devices)? This may only work on EEPROM-like devices I guess, where each area is fully independent and where no erasure is actually expected. Thanks, Miqu=C3=A8l