From patchwork Thu Jul 4 13:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa X-Patchwork-Id: 13723773 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 17C951AB8EC for ; Thu, 4 Jul 2024 13:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100740; cv=none; b=Kac6EBK77Xw9e29JbRzmyn5YiDBpnGqdFmkBFjaMfkVDIC1I/PIptqDViERUXjJxlEBYqBJFhFOgtwyLbyQ0t0BTOT1hK+Zjn5/UL/VlHk5XDwG4QjdjEfZJTrBO2Zylklg/xIo/QYeUiihLWUK0n6zQF3KBxxCUvxaQLwnkAq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100740; c=relaxed/simple; bh=FRoksbWkdFTMpygH/8FiU5+DkCgqEbtWJFCYs/GlTcI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=LtIpGVR8oZE44nCGAf0nwyUp6jUdrztC0q9PagHGYicIuXAN+kI0AW1iSJPEIGUkekapRxqRlE6PUGy993WUygpe6Yx1tNkfPDSkqtEk5jkWZaxPAzqo1rDRN0uVG+y7j9vMBuOF2UwGPKlOAUk0kEiZ4Pp9+Wq29kg0e0ISCQI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=Cb8zQE0a; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="Cb8zQE0a" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 464AeiT7006973; Thu, 4 Jul 2024 09:45:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=r69CR OeUN+eBMHp2/UydgWo72gwsmm0DIvThB1Bqs9k=; b=Cb8zQE0a3Vk4Ryei5pk2Q 4e8kdeBpSELdlru0spsudU4hj/3tswoWVw1BKtb2XPlXIILzZHF5vPmOGyzfGriK RvTOeYfIryna2nX1Dz70Yo037DzzQsrwtut36wsSzxAycwgk8wLtiB+ry5B/GVk5 cb9AcQ67XIbRGd7DH3SChuZwHZonTJnm7swoGj/pMGIWSRZ8H8L+5r90vNzN/Ec8 ZV7LkxVKpL3NayNtQg1fk/1npn7jrdj4Slmc+vvWgFCg0TdkdmImwWyD3+1tLOkD DJqAu2geY6SvoSAuTFSAvSx9iW6DR2Emj5JhrJerHrRZj+H6nq9mw+8K5a+BCjJr A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 405n2p1jyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jul 2024 09:45:36 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 464DjZub000910 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Jul 2024 09:45:35 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:34 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:34 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 4 Jul 2024 09:45:34 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 464DjPu0032622; Thu, 4 Jul 2024 09:45:30 -0400 From: Nuno Sa Date: Thu, 4 Jul 2024 15:49:12 +0200 Subject: [PATCH 1/4] spi: xcomm: add gpiochip support Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240704-dev-spi-xcomm-gpiochip-v1-1-653db6fbef36@analog.com> References: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> In-Reply-To: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> To: CC: Mark Brown , Michael Hennerich X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720100959; l=2791; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=QSLZ8CE6IkBdWtLT3KtLIXcFjkET8zoa0PHj3gIFGYU=; b=dwUe7a76vjswRmq4mTbSrU1nT6egFKg+RWqJyc9ADEjQSqUHYtNgFma2DXUFbVNEfCTlMTNCk 1ph9KtRjn4MCpP1qsRIVB8MY9VzN7ce4hVKyPZ9J9jdFV3EeFbJWEfs X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: IxrE03UjnjZx-L9NOFzA4sHW7Ar_9Sc3 X-Proofpoint-GUID: IxrE03UjnjZx-L9NOFzA4sHW7Ar_9Sc3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-04_10,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxlogscore=705 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407040098 From: Michael Hennerich The hardware can expose one pin as a GPO. Hence, register a simple gpiochip to support it. Signed-off-by: Michael Hennerich Co-developed-by: Nuno Sa Signed-off-by: Nuno Sa --- drivers/spi/spi-xcomm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 63354dd3110f..358e0b84ee60 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -26,12 +27,16 @@ #define SPI_XCOMM_CMD_UPDATE_CONFIG 0x03 #define SPI_XCOMM_CMD_WRITE 0x04 +#define SPI_XCOMM_CMD_GPIO_SET 0x05 #define SPI_XCOMM_CLOCK 48000000 struct spi_xcomm { struct i2c_client *i2c; + struct gpio_chip gc; + int gpio_val; + uint16_t settings; uint16_t chipselect; @@ -40,6 +45,54 @@ struct spi_xcomm { uint8_t buf[63]; }; +static void spi_xcomm_gpio_set_value(struct gpio_chip *chip, + unsigned int offset, int val) +{ + struct spi_xcomm *spi_xcomm = gpiochip_get_data(chip); + unsigned char buf[2]; + int ret; + + buf[0] = SPI_XCOMM_CMD_GPIO_SET; + buf[1] = !!val; + ret = i2c_master_send(spi_xcomm->i2c, buf, 2); + if (ret < 0) + return; + + spi_xcomm->gpio_val = !!val; +} + +static int spi_xcomm_gpio_get_value(struct gpio_chip *chip, unsigned int offset) +{ + struct spi_xcomm *spi_xcomm = gpiochip_get_data(chip); + + return spi_xcomm->gpio_val; +} + +static int spi_xcomm_gpio_get_direction(struct gpio_chip *chip, + unsigned int offset) +{ + return GPIO_LINE_DIRECTION_OUT; +} + +static int spi_xcomm_gpio_add(struct spi_xcomm *spi_xcomm) +{ + struct device *dev = &spi_xcomm->i2c->dev; + + if (!IS_ENABLED(CONFIG_GPIOLIB)) + return 0; + + spi_xcomm->gc.get_direction = spi_xcomm_gpio_get_direction; + spi_xcomm->gc.get = spi_xcomm_gpio_get_value; + spi_xcomm->gc.set = spi_xcomm_gpio_set_value; + spi_xcomm->gc.can_sleep = 1; + spi_xcomm->gc.base = -1; + spi_xcomm->gc.ngpio = 1; + spi_xcomm->gc.label = spi_xcomm->i2c->name; + spi_xcomm->gc.owner = THIS_MODULE; + + return devm_gpiochip_add_data(dev, &spi_xcomm->gc, spi_xcomm); +} + static int spi_xcomm_sync_config(struct spi_xcomm *spi_xcomm, unsigned int len) { uint16_t settings; @@ -227,7 +280,7 @@ static int spi_xcomm_probe(struct i2c_client *i2c) if (ret < 0) spi_controller_put(host); - return ret; + return spi_xcomm_gpio_add(spi_xcomm); } static const struct i2c_device_id spi_xcomm_ids[] = { From patchwork Thu Jul 4 13:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa X-Patchwork-Id: 13723774 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 17C431822E2 for ; Thu, 4 Jul 2024 13:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100740; cv=none; b=s0BJcFRLspWNO+Il88qkF8aP/t5KxX14g7CBt8zlZ5Agu31c2mwcRj3HAbRw0yQgQsWTEm15S2z556nJuKvEg9oVx0GZpByMAWUXDOSipFI8FjKu7dIu/+5tz7y4xljoiuF52by8Afg2oU/7BZgwn09LDqQRfcHwZsNAXHYuZyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100740; c=relaxed/simple; bh=RrtTVpvwS/DE30xyPPUREkIz/Gyd1lqUJrSjAxJi4hM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=JJz3mhbeUeaxBB1jDgg8H7D2SlhFkURXlPstjJJupFPT1YL5TgKada/8DtFXFTqIVcVFO4fAOi1HNPJEJJe73bvvwIbhDdK9Z6SGbmZTxf+0fW2CSefwsvN6MkIYt0pe+H6BqTN0sf+NxXTZpbK47Dg83TImPMJXT+srbpue3K0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=WlCDewYo; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="WlCDewYo" Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 464D0KtF003575; Thu, 4 Jul 2024 09:45:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=fFkN0 zoZ55TaLNEL1zq0ORFIEK3OjrjS8Z8pNP3h0is=; b=WlCDewYoieCFXJr3Nlawh cdjpP7EcHkwnvLnps7RRkdf0SkuMP4RlDNHK6THEly/St4P3qAPdQWAjW1I/cUsi nPoO+saK3L/r4q8JBogtbNQprvTTVGQh8RLHuvdxc4hWqM/v2XgObGabrnAaYGNl 84HsFu57Z3qoMVf5ygkgugxY19uU+GntIAxQRueilBwy5v2ELAJKvrQojCKac6TV vcdpSR7bHl0e2Kf5hLV2A1TjV8kKPhbyNKf7wPQpDcOl4LcBPCD7yRL6YLvvZrA0 Aqc61/YpLs4zKoN3l+dgCr83GbNz9CCOLbuH9w7YA6OR8wUzg/xlYRoaGGTSzdiT g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 405a7nbjmb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jul 2024 09:45:36 -0400 (EDT) Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 464DjZlG000913 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Jul 2024 09:45:35 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:34 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:34 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 4 Jul 2024 09:45:34 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 464DjPu1032622; Thu, 4 Jul 2024 09:45:31 -0400 From: Nuno Sa Date: Thu, 4 Jul 2024 15:49:13 +0200 Subject: [PATCH 2/4] spi: xcomm: make use of devm_spi_alloc_host() Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240704-dev-spi-xcomm-gpiochip-v1-2-653db6fbef36@analog.com> References: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> In-Reply-To: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> To: CC: Mark Brown , Michael Hennerich X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720100959; l=937; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=RrtTVpvwS/DE30xyPPUREkIz/Gyd1lqUJrSjAxJi4hM=; b=g8Y36Hsb5MbzRiPPoHflVSTcQ+eeXgqqdjw0P2xoRkxyWxd9pU8yoPbtsaMQqsk1GBUjKn7ku jd3kql9hrYsCJvZmipWGzMXzAS6PPeTy+czP97mn0plhPwuR9NrMduy X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: 0GSUtJqCJ7zs9SRIgj3qznRxlSbvpcCU X-Proofpoint-GUID: 0GSUtJqCJ7zs9SRIgj3qznRxlSbvpcCU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-04_10,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 priorityscore=1501 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 mlxlogscore=593 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407040098 Use devm_spi_alloc_host() so that there's no need to call spi_controller_put() in the error path. Signed-off-by: Nuno Sa --- drivers/spi/spi-xcomm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 358e0b84ee60..5a27eaed4183 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -261,7 +261,7 @@ static int spi_xcomm_probe(struct i2c_client *i2c) struct spi_controller *host; int ret; - host = spi_alloc_host(&i2c->dev, sizeof(*spi_xcomm)); + host = devm_spi_alloc_host(&i2c->dev, sizeof(*spi_xcomm)); if (!host) return -ENOMEM; @@ -278,7 +278,7 @@ static int spi_xcomm_probe(struct i2c_client *i2c) ret = devm_spi_register_controller(&i2c->dev, host); if (ret < 0) - spi_controller_put(host); + return ret; return spi_xcomm_gpio_add(spi_xcomm); } From patchwork Thu Jul 4 13:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa X-Patchwork-Id: 13723776 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 8743B1AB8EC for ; Thu, 4 Jul 2024 13:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100742; cv=none; b=rgJKQuyyToPo7xD0Kcy2fQFCokxUphucDvrtz4Z7aAfAryPqv323tJOAueBxWEn3yEtV7OAil0wmR3OeKzK5Nb1Q/pP8ouund6ktLvxrBhAQKB0UJwOJLZcwgfU4CsMPjJ9RvQ9+sIwRAWwwSW5IDMHg9p31CArN4Xd6qsLTaLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100742; c=relaxed/simple; bh=YbhNBs1FAUTf6FdeaePslEmL9N+JT0z5OyIbcZct36I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=oqFIpiHrYzwMFoTkys7gi12NkqqxqNU5KD5p+Q4UTx3w+ACe6GKM6l5iJM63O3e2+MC7ckoAyiwcVzQLKxOzq1W5ZHGd5thYNMhJskEpwzMJX6VQhNS+yMVkdxxkfMGTZLesjqwmV2J4cB0I57ivMagvJaeQewT3Mk3jW/8oQtw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=YFvNK1Hc; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="YFvNK1Hc" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 464AxbCt006966; Thu, 4 Jul 2024 09:45:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=6jFxA GcVE8FDWb34Q0bP7ZGVnZ9f3pQk3AXUldfxcrQ=; b=YFvNK1HcpzNTLWpB/Jw5y ZncP6THbibmRz7o/N+79lIsmu1JyV/T3igFsgj2B4Kw50Thepo69R8m6dLK/C4bX I/Md+pfY/+qfy0wWv6bIkXtVwcbol6SnKeneX1rk35tg5erZbFqQLcXQfTmJPA9d cWAcAVl9g68AjRt+z0EnaCYve4asjdQ5U+trdOMJ0D2l25i1me2ZYcs53PlKQUa9 +AtYt2J71nw5DMoQVkTh97XZEt0GFb1BxoRASilwFWkPwnzU6oq8Qv1zHrEDDNu1 vQ+1YUaBGTyjB0OuqCS2SDCiVsu98Z5IKDSv7+3gKOI5M0KI7PcyD1XRT+3EPQ8K A== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 405n2p1jyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jul 2024 09:45:39 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 464DjbOb000919 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Jul 2024 09:45:37 -0400 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:36 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 4 Jul 2024 09:45:36 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 464DjPu2032622; Thu, 4 Jul 2024 09:45:31 -0400 From: Nuno Sa Date: Thu, 4 Jul 2024 15:49:14 +0200 Subject: [PATCH 3/4] spi: xcomm: remove i2c_set_clientdata() Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240704-dev-spi-xcomm-gpiochip-v1-3-653db6fbef36@analog.com> References: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> In-Reply-To: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> To: CC: Mark Brown , Michael Hennerich X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720100959; l=717; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=YbhNBs1FAUTf6FdeaePslEmL9N+JT0z5OyIbcZct36I=; b=MuKb28kAWKixH40qYUYh0905O2z+h3A0DYEpvq08BMt8aabi8aJFQxJ6nBOf30xZLRaYYH1q9 JS9NBnm4CfuD1AaAhYAPJrUtXGNuhLuWFCSgAxbVwceyMP1KAR/I5Bb X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: dcqCyOLRuiFeuKDf1K7HsH8F2f6BTnRh X-Proofpoint-GUID: dcqCyOLRuiFeuKDf1K7HsH8F2f6BTnRh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-04_10,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxlogscore=598 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407040098 i2c_get_clientdata() is not being called anywhere so that we do not need to set clientdata. Signed-off-by: Nuno Sa --- drivers/spi/spi-xcomm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 5a27eaed4183..136d81fb5f56 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -274,7 +274,6 @@ static int spi_xcomm_probe(struct i2c_client *i2c) host->flags = SPI_CONTROLLER_HALF_DUPLEX; host->transfer_one_message = spi_xcomm_transfer_one; host->dev.of_node = i2c->dev.of_node; - i2c_set_clientdata(i2c, host); ret = devm_spi_register_controller(&i2c->dev, host); if (ret < 0) From patchwork Thu Jul 4 13:49:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nuno Sa X-Patchwork-Id: 13723775 Received: from mx0b-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) (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 569791AE0B9 for ; Thu, 4 Jul 2024 13:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100741; cv=none; b=IL8w7DaPN5GQLzI/0ZkHM4sJFZvW98Jm92JBxEuVSA4zEWkJEr2jXgjsneWv2HGXv1yvbU/gM5DoPPnbxPUm0EU0DMd00PFXz6bRZRb3a0Q0ehYRQS9nPlLPVRvZ+CjCczqiPYtg5OFsmkP/dGesvi8dJMX5+W39STV9az47iwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720100741; c=relaxed/simple; bh=ZXi1XBghFTCRJBmNlnEz0KpOTovl8UOXAZFaQB9NdyQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fl2FVJXx2E40uVPInyiaMwdW21LkQ+E0YVyfbR+rYHgNQ+ZvG7ORYnTGbcurvmbWs2EnVlxt8EpgtGT3Hgdvj2SBbsshWYdpP5nQcbyZfnQT8W88t7EXCD/XJxn8mMYrcjT2zPTtBHJDZdqLkI+livVXtueaEcFL1RH6aYeA7XY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com; spf=pass smtp.mailfrom=analog.com; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b=MnVHotRr; arc=none smtp.client-ip=148.163.135.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=analog.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=analog.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=analog.com header.i=@analog.com header.b="MnVHotRr" Received: from pps.filterd (m0375855.ppops.net [127.0.0.1]) by mx0b-00128a01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 464B0MjU007099; Thu, 4 Jul 2024 09:45:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=DKIM; bh=Yo8Uj pNjs6NcB0j4+DVHNcYtkWKgjlvri391ntuAG/A=; b=MnVHotRrIqLY5WOA9ncC5 2TH0XHxnd/q+2ck3qjbyzrDbvLAS9FvLBIbYPC7c8/ogpK+gxRmhkmaeML4N8BZu 4Jy/2CbBfVZyvwZv7Y9vwZiRntFg/Rs3JGcJyjlfx4WmTiX2MAmeWoL7/X5QGNAn HFtKXXNfVYsuTMKO09XUZw+yNFsopAksRNksu909qPwxMZ0HJHj9Bxcv/827P62j xrHwOcV9HWQhgl491UTNIOA53/3lcrWiWyRXgw1o/V8kDQyIH0ZjCCXOfZU16xlf NF70znRNgO/ozOWEIoLCR3u0I+TUmdZkmUfELNQ2514PVH/7wr79fA8YTsNxsjwM g== Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0b-00128a01.pphosted.com (PPS) with ESMTPS id 405n2p1jyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Jul 2024 09:45:37 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 464Dja5V000916 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 4 Jul 2024 09:45:36 -0400 Received: from ASHBCASHYB5.ad.analog.com (10.64.17.133) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:35 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB5.ad.analog.com (10.64.17.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Thu, 4 Jul 2024 09:45:35 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Thu, 4 Jul 2024 09:45:35 -0400 Received: from [127.0.0.1] ([10.44.3.56]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 464DjPu3032622; Thu, 4 Jul 2024 09:45:32 -0400 From: Nuno Sa Date: Thu, 4 Jul 2024 15:49:15 +0200 Subject: [PATCH 4/4] spi: xcomm: fix coding style Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240704-dev-spi-xcomm-gpiochip-v1-4-653db6fbef36@analog.com> References: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> In-Reply-To: <20240704-dev-spi-xcomm-gpiochip-v1-0-653db6fbef36@analog.com> To: CC: Mark Brown , Michael Hennerich X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720100959; l=3486; i=nuno.sa@analog.com; s=20231116; h=from:subject:message-id; bh=ZXi1XBghFTCRJBmNlnEz0KpOTovl8UOXAZFaQB9NdyQ=; b=RIU2nUSOHwVpQuFcja1H3l8dgcymLcrB8yLTT4jpNL5lHI9jDXZ5V+R/illb9FPq+05Y8yKMn iAvlIfAGSikBv/7v5DO+XVr5fBpgNVx5VysW8g4WQ2qzSyq9+i1APun X-Developer-Key: i=nuno.sa@analog.com; a=ed25519; pk=3NQwYA013OUYZsmDFBf8rmyyr5iQlxV/9H4/Df83o1E= X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: ypXkZGGLM67e_NtSg8MBDHrPXzkBmWut X-Proofpoint-GUID: ypXkZGGLM67e_NtSg8MBDHrPXzkBmWut X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-04_10,2024-07-03_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 spamscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxlogscore=826 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407040098 Just cosmetics. No functional change intended. While at it, removed a couple of redundant else if() statements. Signed-off-by: Nuno Sa --- drivers/spi/spi-xcomm.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c index 136d81fb5f56..9052bddedd10 100644 --- a/drivers/spi/spi-xcomm.c +++ b/drivers/spi/spi-xcomm.c @@ -37,12 +37,12 @@ struct spi_xcomm { struct gpio_chip gc; int gpio_val; - uint16_t settings; - uint16_t chipselect; + u16 settings; + u16 chipselect; unsigned int current_speed; - uint8_t buf[63]; + u8 buf[63]; }; static void spi_xcomm_gpio_set_value(struct gpio_chip *chip, @@ -95,8 +95,8 @@ static int spi_xcomm_gpio_add(struct spi_xcomm *spi_xcomm) static int spi_xcomm_sync_config(struct spi_xcomm *spi_xcomm, unsigned int len) { - uint16_t settings; - uint8_t *buf = spi_xcomm->buf; + u16 settings; + u8 *buf = spi_xcomm->buf; settings = spi_xcomm->settings; settings |= len << SPI_XCOMM_SETTINGS_LEN_OFFSET; @@ -109,10 +109,10 @@ static int spi_xcomm_sync_config(struct spi_xcomm *spi_xcomm, unsigned int len) } static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, - struct spi_device *spi, int is_active) + struct spi_device *spi, int is_active) { unsigned long cs = spi_get_chipselect(spi, 0); - uint16_t chipselect = spi_xcomm->chipselect; + u16 chipselect = spi_xcomm->chipselect; if (is_active) chipselect |= BIT(cs); @@ -123,7 +123,8 @@ static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm, } static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, - struct spi_device *spi, struct spi_transfer *t, unsigned int *settings) + struct spi_device *spi, struct spi_transfer *t, + unsigned int *settings) { if (t->len > 62) return -EINVAL; @@ -161,7 +162,7 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm, } static int spi_xcomm_txrx_bufs(struct spi_xcomm *spi_xcomm, - struct spi_device *spi, struct spi_transfer *t) + struct spi_device *spi, struct spi_transfer *t) { int ret; @@ -172,13 +173,13 @@ static int spi_xcomm_txrx_bufs(struct spi_xcomm *spi_xcomm, ret = i2c_master_send(spi_xcomm->i2c, spi_xcomm->buf, t->len + 1); if (ret < 0) return ret; - else if (ret != t->len + 1) + if (ret != t->len + 1) return -EIO; } else if (t->rx_buf) { ret = i2c_master_recv(spi_xcomm->i2c, t->rx_buf, t->len); if (ret < 0) return ret; - else if (ret != t->len) + if (ret != t->len) return -EIO; } @@ -186,12 +187,12 @@ static int spi_xcomm_txrx_bufs(struct spi_xcomm *spi_xcomm, } static int spi_xcomm_transfer_one(struct spi_controller *host, - struct spi_message *msg) + struct spi_message *msg) { struct spi_xcomm *spi_xcomm = spi_controller_get_devdata(host); unsigned int settings = spi_xcomm->settings; struct spi_device *spi = msg->spi; - unsigned cs_change = 0; + unsigned int cs_change = 0; struct spi_transfer *t; bool is_first = true; int status = 0; @@ -200,7 +201,6 @@ static int spi_xcomm_transfer_one(struct spi_controller *host, spi_xcomm_chipselect(spi_xcomm, spi, true); list_for_each_entry(t, &msg->transfers, transfer_list) { - if (!t->tx_buf && !t->rx_buf && t->len) { status = -EINVAL; break;