From patchwork Wed May 22 14:52:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13670910 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 DC01A18645 for ; Wed, 22 May 2024 14:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389586; cv=none; b=t6NQl+1nDr2m9ImgqWEK3lYo0DR0m2NsdAi4m9whM3VKNm0nRbG+BiNUb50iSOHsrodZf/ynyqT4QNOJHOYw4TtB5+UaDD5Xk4kKY3CF3Nbt9KI5eSa1La9pQzCR7FtoKfoyAJxb27P3i78DNLo+2CgOvXGp18IAPesIO+0+vqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389586; c=relaxed/simple; bh=cHsLDnIFM6cGXLl/mTrYK0SMWcluyeiGdD9kJN8/Tys=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SYzMpRIaHeMxwJwn482FNtz7yq7gNZyKJj9vyFZTp9RN/xiBTmqew8GsMnpa56UFM8EHMPRz68sW+msnyZCWkbBr+z2ZJaDIYshrTlP+8ZO2pGI1rBNR0xwjoMhdtJH2Kia2/AYbxAeDypwPGp8fUA6TpR+MGBDBrLQF5FpZEgs= 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=kkHEfkgR; arc=none smtp.client-ip=217.70.183.195 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kkHEfkgR" Received: by mail.gandi.net (Postfix) with ESMTPSA id 14A9B60007; Wed, 22 May 2024 14:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716389577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yiJ8+52qzPzJhiZXAoVRGuwroXBLtuhBrnUsdkuLofI=; b=kkHEfkgRcSejbG46aRF34vUmzBfcI79bApNfNfQhGhIh15giaJsOa+Fssmypvhve+SJ+kv g8OmNBmChkqqjQQffgZ4UVICfuddVM4TW5r3TXK2EVmajXopGhuaECRj05hne77XGieskp U6iyIshtZ3v442IX/14mfVj2BgkyqsYcFqz6AjPh8xqmzG3wbGjRstR/BKufO7Xu64/kzX wXJRj8NggpUPyT2fqKYK97fing8wppcU/5XcsmeKA64SJMl7iLhbPH1JFwI2+BPZaTiOnh U0BwlB2QQzI7BcAfcC/gmm8yNBdz7D8woZilhI9zVvUDk/Q5F6bNOrjS03A+bA== From: Miquel Raynal To: Mark Brown , Cc: Serge Semin , j.neuschaefer@gmx.net, Julien Su , Alvin Zhou , Thomas Petazzoni , Miquel Raynal Subject: [PATCH 1/4] spi: dw: differentiate between unsupported and invalid requests Date: Wed, 22 May 2024 16:52:52 +0200 Message-Id: <20240522145255.995778-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240522145255.995778-1-miquel.raynal@bootlin.com> References: <20240522145255.995778-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com The driver does not support dirmap write operations, return -EOPTNOTSUPP in this case. Most controllers have a maximum linear mapping area. Requests beyond this limit can be considered invalid, rather than unsupported. From a caller (and reviewer) point of view, distinguising between the two may be helpful because somehow one can be "fixed" while the other will always be refused no matter how hard we try. As part of a wider work to bring spi-nand continuous reads, it was useful to easily catch the upper limit direct mapping boundaries for each controller, with the idea of enlarging this area from a page to an eraseblock, without risking too many regressions. Signed-off-by: Miquel Raynal Reviewed-by: Serge Semin --- drivers/spi/spi-dw-bt1.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-dw-bt1.c b/drivers/spi/spi-dw-bt1.c index 5391bcac305c..4577e8096cd9 100644 --- a/drivers/spi/spi-dw-bt1.c +++ b/drivers/spi/spi-dw-bt1.c @@ -55,13 +55,15 @@ static int dw_spi_bt1_dirmap_create(struct spi_mem_dirmap_desc *desc) !dwsbt1->dws.mem_ops.supports_op(desc->mem, &desc->info.op_tmpl)) return -EOPNOTSUPP; + if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN) + return -EOPNOTSUPP; + /* * Make sure the requested region doesn't go out of the physically - * mapped flash memory bounds and the operation is read-only. + * mapped flash memory bounds. */ - if (desc->info.offset + desc->info.length > dwsbt1->map_len || - desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN) - return -EOPNOTSUPP; + if (desc->info.offset + desc->info.length > dwsbt1->map_len) + return -EINVAL; return 0; } From patchwork Wed May 22 14:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13670912 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 867A91C694 for ; Wed, 22 May 2024 14:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389587; cv=none; b=VKvNpBfboQ8W3EfQaqeSB1d0NuYKYiiPo/QL4ZyAh+VzN/y8q5GcP95UfT1C5z6Ikz5sLK+uA0XDq08RcfY4IJURHJIjJh/+okNV13wXLfybUIJEGsv2WSN/ZQhUj8X73z1fNaKr2G4tnAer5QC9e5OpkCdEVzSERt6hMyEp8vI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389587; c=relaxed/simple; bh=mEnTvtAtNzZxsg2CVtceiOZ1xONw8v+MdMWLL5+Pmg0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C0s67QOfYD+WKgQA2PGwrUXJW0wT/2clo+kgP+rbcoJJDGtmVNGnF6/0+l8ajGVdc3BMNGajkpmVELj8YSiBo+mx5Zo44xzGI3vy99hqO+IzfucQTFKBOQBindXSiwr/EZf/IS14BxTM9KiwRdEvF5Hyq7fVQcFUbybBfPlJfJ8= 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=GNx5SFn0; arc=none smtp.client-ip=217.70.183.195 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GNx5SFn0" Received: by mail.gandi.net (Postfix) with ESMTPSA id 8046260009; Wed, 22 May 2024 14:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716389577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IRQfo211pDzLhnjQrRk/5xMC5CrZJdpHPQsiNLKisI0=; b=GNx5SFn0dzrqKTH2GadTmU1XS/hDzQNPapcf87tP2+Qe+d3mpb0jhaFwZL9boDq2n/IZLz taQteEWYP2hPm3X021W4kbAfLB78A1nwLVf8EvQQW3TO5sIiN9iF7EOH2bb1DeqXv0znLX ZWG5X8/9XxENQPQi4BChfCrV/h1YLMYHwzFShKuKQRYxZzP32ORVP6opwnmUw2Hu8Roq4+ UAx1gAmvzIUqZTQmvJ4i2KJ7XNZTpfkz6FRzIVfFl1g7fJoAxXlBb2ekt90PYkJ6tvfUa8 fGKsRGs8sKQfsQxkU9ZufgD7RDwVzCM5Bx7eRNZbO26qlAeaYzwrAYebxnifNw== From: Miquel Raynal To: Mark Brown , Cc: Serge Semin , j.neuschaefer@gmx.net, Julien Su , Alvin Zhou , Thomas Petazzoni , Miquel Raynal Subject: [PATCH 2/4] spi: mxic: differentiate between unsupported and invalid requests Date: Wed, 22 May 2024 16:52:53 +0200 Message-Id: <20240522145255.995778-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240522145255.995778-1-miquel.raynal@bootlin.com> References: <20240522145255.995778-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com If the request is out of range, returning -EINVAL seems sensible. However if there is no direct mapping available (which is a possible case), no direct mapping will ever be allowed, hence -EOPNOTSUP is probably more relevant in this case. From a caller (and reviewer) point of view, distinguising between the two may be helpful because somehow one can be "fixed" while the other will always be refused no matter how hard we try. As part of a wider work to bring spi-nand continuous reads, it was useful to easily catch the upper limit direct mapping boundaries for each controller, with the idea of enlarging this area from a page to an eraseblock, without risking too many regressions. Signed-off-by: Miquel Raynal --- drivers/spi/spi-mxic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-mxic.c b/drivers/spi/spi-mxic.c index 60c9f3048ac9..6156d691630a 100644 --- a/drivers/spi/spi-mxic.c +++ b/drivers/spi/spi-mxic.c @@ -496,7 +496,7 @@ static int mxic_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc) struct mxic_spi *mxic = spi_controller_get_devdata(desc->mem->spi->controller); if (!mxic->linear.map) - return -EINVAL; + return -EOPNOTSUPP; if (desc->info.offset + desc->info.length > U32_MAX) return -EINVAL; From patchwork Wed May 22 14:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13670911 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 8676F1C683 for ; Wed, 22 May 2024 14:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389587; cv=none; b=mO0PmdQaaT5AvMirixxMjPYH9c+YhmQbRmYDUsd8JiDADHimVGiCm3GtnH0+YJHWchwjoTi4mLBIswrUpVEPuA/DpyiznjjVKNuAkC+eDoRtoLoZhuto6tYiruSn7z/A8WwyxImEPbbrctr8hMXN6GP/31hR2xGCEzBHGMW3QVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389587; c=relaxed/simple; bh=Zrqq3v+gWeA4mFC2n5UPdzePnpObTzWZ1ZYSmifSyYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pKli0AlGKNLilI7G8gcOT2R1HxkZ/EINVSI9EdbLnVkaH/zl6jDqjChXsG+rIMAIJZcq276fBbi3pjOQV4/4l5EwUkmZlirAC7EfOXXE5zoBKXFR3y5bC38yxMDP3VvDoKEhDwNgvJ7SrIMiMpZVEvmkFwYjlRc7DR8VlciaDOE= 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=E2ME/nBK; arc=none smtp.client-ip=217.70.183.195 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="E2ME/nBK" Received: by mail.gandi.net (Postfix) with ESMTPSA id 0232E6000B; Wed, 22 May 2024 14:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716389578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+bST3qn/qVYTYtwFvPSVOnQ/ZhNC2iNknto2WIVA8Qs=; b=E2ME/nBKQad0QetS16bfwCcmpGVa37z1yMFCF+8LxPk/pr+OZoqgRNp2AqJQGOYqkhlGS1 fQiqa9sc5BR+L3ryPWCtI52h9+RBjikmMnslb1EKOR9TeE/N2zX5J+cw9CCA92zmGMNB9G 4I7rW9DbWGv9FrFFjTuU37BhnDw1SFrlhpISuhHvN8fzhYMuhdZbKel/dp/BGxp8sCqk9N Qs0lFC72JmO8lhypgelT25H/4R0odgCW8gGFCPLKGaiATyMFQ1rwvBSsQpQUYUxW9ngVm9 YvDrDPEMnMQfIh26ew+VinpLvNFtPmkCHRyuUfkG1kldnuYhmlA/tWMJVMWn8w== From: Miquel Raynal To: Mark Brown , Cc: Serge Semin , j.neuschaefer@gmx.net, Julien Su , Alvin Zhou , Thomas Petazzoni , Miquel Raynal Subject: [PATCH 3/4] spi: rpc-if: differentiate between unsupported and invalid requests Date: Wed, 22 May 2024 16:52:54 +0200 Message-Id: <20240522145255.995778-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240522145255.995778-1-miquel.raynal@bootlin.com> References: <20240522145255.995778-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com If the request is out of range, returning -EINVAL seems a better pick than -ENOTSUPP. From a caller (and reviewer) point of view, distinguising between the two may be helpful because somehow one can be "fixed" while the other will always be refused no matter how hard we try. As part of a wider work to bring spi-nand continuous reads, it was useful to easily catch the upper limit direct mapping boundaries for each controller, with the idea of enlarging this area from a page to an eraseblock, without risking too many regressions. In all other cases, as part of a wider work towards using -EOPNOTSUP rather than -ENOTSUPP (which is not a SUSV4 code), let's change the error code to be uniform across spi-mem controller drivers. Finally, reword a little bit the conditions to clarify what is intended (ie. checking for the presence of a direct mapping, and also ensuring we create a dirmap only on DATA_IN flows). Signed-off-by: Miquel Raynal --- drivers/spi/spi-rpc-if.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c index e11146932828..d3f07fd719bd 100644 --- a/drivers/spi/spi-rpc-if.c +++ b/drivers/spi/spi-rpc-if.c @@ -95,16 +95,16 @@ static int rpcif_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc) spi_controller_get_devdata(desc->mem->spi->controller); if (desc->info.offset + desc->info.length > U32_MAX) - return -ENOTSUPP; + return -EINVAL; if (!rpcif_spi_mem_supports_op(desc->mem, &desc->info.op_tmpl)) - return -ENOTSUPP; + return -EOPNOTSUPP; - if (!rpc->dirmap && desc->info.op_tmpl.data.dir == SPI_MEM_DATA_IN) - return -ENOTSUPP; + if (!rpc->dirmap) + return -EOPNOTSUPP; - if (desc->info.op_tmpl.data.dir == SPI_MEM_DATA_OUT) - return -ENOTSUPP; + if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN) + return -EOPNOTSUPP; return 0; } From patchwork Wed May 22 14:52:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13670913 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 8D2271C6A8 for ; Wed, 22 May 2024 14:53:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389588; cv=none; b=OC032NXpIdZJGEttkXuyEBAd++cUMWylfWTwALbt1LPNNUemQHsLesLV777bmIj2V8vrVGp3c+Y9S8UXjIIc7iDaFhzHOxb+L6DFn+HgPj35DSMARyROpY2UhXkyM014rk4r4qrbSCKB946kHg2UV3cAwSdSEzARUII5+ZJ3WbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716389588; c=relaxed/simple; bh=AgUSMnmGCua8oGCi0zoty5SNG3aQYMN/dZBvaLMxVgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nMyWkJxu8esXxfO/qvZByvdEPqGGvO+/U6J4dOoT0AvXemBfTZmrUN9TQ41GPe7FhkCJWQ2x16tAoTrg3Z7kEuPDmIjCHZU2yw6IoBvVdpSvokfdf7CmIpeBYzRwaFsEdMpgtgE92AZTUQ1uwfOOxCHFkZ5rzah7GaOB+Pyefjs= 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=VFi3MRDk; arc=none smtp.client-ip=217.70.183.195 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="VFi3MRDk" Received: by mail.gandi.net (Postfix) with ESMTPSA id 7FE1B6000C; Wed, 22 May 2024 14:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1716389578; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SJS15LpTyO/Mn6MuShtlvqeOX+2BEpSp812b1sn4VxQ=; b=VFi3MRDkJkFQen464eqe54iZRppSMPUB9ZxU+WjE4aob924s9BQkPqwjLCWfuGzVCPkZA8 aafySvnd4tcpPkIWoUiHwC0QLbBBhg1czNJ2+JGZ37ezTEZ2T2SfQ3S2BsjY4ol/PJ4F5M DcHznmcBsZD05+mNOpf+8WbxdW4RES91uxTJgKtWbdUg8gJwcwus0veC85ZuXo0D/3P43b Hs6oeX3yC4z+SvjI25Be6eiyap1oi+91iFo46tt8+tJpzYilEL/R/nae9ZPIy5Cq+5aYnG 29rdtLzpiOTQKzbHNYKVFtlbPciFjt//cIOSzqrmWRy+GIROgTFVHhn9hg9Abw== From: Miquel Raynal To: Mark Brown , Cc: Serge Semin , j.neuschaefer@gmx.net, Julien Su , Alvin Zhou , Thomas Petazzoni , Miquel Raynal Subject: [PATCH 4/4] spi: wpcm-fiu: differentiate between unsupported and invalid requests Date: Wed, 22 May 2024 16:52:55 +0200 Message-Id: <20240522145255.995778-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240522145255.995778-1-miquel.raynal@bootlin.com> References: <20240522145255.995778-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com When the requested dirmap accesses are outside of the window, it is probably more sensible to return -EINVAL rather than an "unsupported" error code. If however the operation in itself is not supported, then -EOPNOTSUP is likely going to be preferred as it is a standard error code. From a caller (and reviewer) point of view, distinguising between the two may be helpful because somehow one can be "fixed" while the other will always be refused no matter how hard we try. As part of a wider work to bring spi-nand continuous reads, it was useful to easily catch the upper limit direct mapping boundaries for each controller, with the idea of enlarging this area from a page to an eraseblock, without risking too many regressions. Signed-off-by: Miquel Raynal --- drivers/spi/spi-wpcm-fiu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-wpcm-fiu.c b/drivers/spi/spi-wpcm-fiu.c index 6b16a22cc3a4..886d6d7771d4 100644 --- a/drivers/spi/spi-wpcm-fiu.c +++ b/drivers/spi/spi-wpcm-fiu.c @@ -378,7 +378,7 @@ static int wpcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc) int cs = spi_get_chipselect(desc->mem->spi, 0); if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN) - return -ENOTSUPP; + return -EOPNOTSUPP; /* * Unfortunately, FIU only supports a 16 MiB direct mapping window (per @@ -387,11 +387,11 @@ static int wpcm_fiu_dirmap_create(struct spi_mem_dirmap_desc *desc) * flashes that are bigger than 16 MiB. */ if (desc->info.offset + desc->info.length > MAX_MEMORY_SIZE_PER_CS) - return -ENOTSUPP; + return -EINVAL; /* Don't read past the memory window */ if (cs * MAX_MEMORY_SIZE_PER_CS + desc->info.offset + desc->info.length > fiu->memory_size) - return -ENOTSUPP; + return -EINVAL; return 0; }