Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10755C61DA0 for ; Mon, 23 Jan 2023 17:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbjAWRRy (ORCPT ); Mon, 23 Jan 2023 12:17:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233558AbjAWRRq (ORCPT ); Mon, 23 Jan 2023 12:17:46 -0500 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CBB930182; Mon, 23 Jan 2023 09:17:14 -0800 (PST) Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30NEJN7P009518; Mon, 23 Jan 2023 18:16:41 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=R1aMUGjTbxhxY6hkyKRGBk4zxbzWjzxiNcedON6udFo=; b=Zm5ggXoNZruq7Bb3b8N1qmVGlQxdkRIHa80INaPpZBBpXyjLW8eCZLOi26l5A6+RB5/w Z+PZ3/cL4Va46yqtmJi5PORwYTY46FioxWKylbeuPxm436newkRnSC7hmZnYsKWHL2Kb E8O4kMxS5/CdwDsQ4mM0v4xIMFleF1b25tB/cNt2YL3f/fwzgGAIWdrLxxMD8SuKdWQu cPFgMv67SOjqXrPKNSoqvl1+YjTlQbFYmJvNya7GzzdG/j6Oyh9icv6JPWXR/j9Hrm2V cNegJauCMm20Z1Gl+nUL+NtrY2i2G1zVxWNtOmY+nTZipz1phWQlTPi0LXd8tXF5+ztP QA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3n89epk4d1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Jan 2023 18:16:41 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 995FC100038; Mon, 23 Jan 2023 18:16:37 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 89E49228A2B; Mon, 23 Jan 2023 18:16:37 +0100 (CET) Received: from [10.201.21.26] (10.201.21.26) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.13; Mon, 23 Jan 2023 18:16:34 +0100 Message-ID: Date: Mon, 23 Jan 2023 18:16:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 02/13] spi: Replace all spi->chip_select and spi->cs_gpiod references with function call To: Amit Kumar Mahapatra , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20230119185342.2093323-1-amit.kumar-mahapatra@amd.com> <20230119185342.2093323-3-amit.kumar-mahapatra@amd.com> Content-Language: en-US From: Patrice CHOTARD In-Reply-To: <20230119185342.2093323-3-amit.kumar-mahapatra@amd.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.201.21.26] X-ClientProxiedBy: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hi Amit On 1/19/23 19:53, Amit Kumar Mahapatra wrote: > Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod > members of struct spi_device to be an array. But changing the type of these > members to array would break the spi driver functionality. To make the > transition smoother introduced four new APIs to get/set the > spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and > spi->cs_gpiod references with get or set API calls. > While adding multi-cs support in further patches the chip_select & cs_gpiod > members of the spi_device structure would be converted to arrays & the > "idx" parameter of the APIs would be used as array index i.e., > spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. > > Signed-off-by: Amit Kumar Mahapatra > --- [...] > drivers/spi/spi-stm32-qspi.c | 12 ++++++------ [...] > diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c > index 9131660c1afb..b9e61372dcfb 100644 > --- a/drivers/spi/spi-stm32-qspi.c > +++ b/drivers/spi/spi-stm32-qspi.c > @@ -359,7 +359,7 @@ static int stm32_qspi_get_mode(u8 buswidth) > static int stm32_qspi_send(struct spi_device *spi, const struct spi_mem_op *op) > { > struct stm32_qspi *qspi = spi_controller_get_devdata(spi->master); > - struct stm32_qspi_flash *flash = &qspi->flash[spi->chip_select]; > + struct stm32_qspi_flash *flash = &qspi->flash[spi_get_chipselect(spi, 0)]; > u32 ccr, cr; > int timeout, err = 0, err_poll_status = 0; > > @@ -564,7 +564,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl, > struct spi_mem_op op; > int ret = 0; > > - if (!spi->cs_gpiod) > + if (!spi_get_csgpiod(spi, 0)) > return -EOPNOTSUPP; > > ret = pm_runtime_resume_and_get(qspi->dev); > @@ -573,7 +573,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl, > > mutex_lock(&qspi->lock); > > - gpiod_set_value_cansleep(spi->cs_gpiod, true); > + gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), true); > > list_for_each_entry(transfer, &msg->transfers, transfer_list) { > u8 dummy_bytes = 0; > @@ -626,7 +626,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl, > } > > end_of_transfer: > - gpiod_set_value_cansleep(spi->cs_gpiod, false); > + gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), false); > > mutex_unlock(&qspi->lock); > > @@ -669,8 +669,8 @@ static int stm32_qspi_setup(struct spi_device *spi) > > presc = DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1; > > - flash = &qspi->flash[spi->chip_select]; > - flash->cs = spi->chip_select; > + flash = &qspi->flash[spi_get_chipselect(spi, 0)]; > + flash->cs = spi_get_chipselect(spi, 0); > flash->presc = presc; > > mutex_lock(&qspi->lock); Reviewed-by: Patrice Chotard Thanks Patrice