mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Md Sadre Alam <quic_mdalam@quicinc.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: <andersson@kernel.org>, <konrad.dybcio@linaro.org>,
	<broonie@kernel.org>, <robh@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
	<miquel.raynal@bootlin.com>, <richard@nod.at>, <vigneshr@ti.com>,
	<manivannan.sadhasivam@linaro.org>,
	<linux-arm-msm@vger.kernel.org>, <linux-spi@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-mtd@lists.infradead.org>, <quic_srichara@quicinc.com>,
	<quic_varada@quicinc.com>
Subject: Re: [PATCH 2/5] drivers: mtd: nand: Add qpic_common API file
Date: Tue, 20 Feb 2024 21:29:02 +0530	[thread overview]
Message-ID: <c574c9ab-0a47-2dc8-9ddd-c08f1b770d7e@quicinc.com> (raw)
In-Reply-To: <CAA8EJpquDwDg+OrZKeJrTWEtokCF7uyHMyzCFK2etSsDip8_6Q@mail.gmail.com>



On 2/15/2024 8:30 PM, Dmitry Baryshkov wrote:
> On Thu, 15 Feb 2024 at 15:53, Md Sadre Alam <quic_mdalam@quicinc.com> wrote:
>>
>> Add qpic_common.c file which hold all the common
>> qpic APIs which will be used by both qpic raw nand
>> driver and qpic spi nand driver.
>>
>> Co-developed-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
>> Signed-off-by: Sricharan Ramabadhran <quic_srichara@quicinc.com>
>> Co-developed-by: Varadarajan Narayanan <quic_varada@quicinc.com>
>> Signed-off-by: Varadarajan Narayanan <quic_varada@quicinc.com>
>> Signed-off-by: Md Sadre Alam <quic_mdalam@quicinc.com>
>> ---
>>   drivers/mtd/nand/Makefile            |    1 +
>>   drivers/mtd/nand/qpic_common.c       |  786 +++++++++++++++++
>>   drivers/mtd/nand/raw/qcom_nandc.c    | 1226 +-------------------------
>>   include/linux/mtd/nand-qpic-common.h |  488 ++++++++++
>>   4 files changed, 1291 insertions(+), 1210 deletions(-)
>>   create mode 100644 drivers/mtd/nand/qpic_common.c
>>   create mode 100644 include/linux/mtd/nand-qpic-common.h
>>
>> diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
>> index 19e1291ac4d5..131707a41293 100644
>> --- a/drivers/mtd/nand/Makefile
>> +++ b/drivers/mtd/nand/Makefile
>> @@ -12,3 +12,4 @@ nandcore-$(CONFIG_MTD_NAND_ECC) += ecc.o
>>   nandcore-$(CONFIG_MTD_NAND_ECC_SW_HAMMING) += ecc-sw-hamming.o
>>   nandcore-$(CONFIG_MTD_NAND_ECC_SW_BCH) += ecc-sw-bch.o
>>   nandcore-$(CONFIG_MTD_NAND_ECC_MXIC) += ecc-mxic.o
>> +obj-y += qpic_common.o
>> diff --git a/drivers/mtd/nand/qpic_common.c b/drivers/mtd/nand/qpic_common.c
>> new file mode 100644
>> index 000000000000..4d74ba888028
>> --- /dev/null
>> +++ b/drivers/mtd/nand/qpic_common.c
>> @@ -0,0 +1,786 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * QPIC Controller common API file.
>> + * Copyright (C) 2023  Qualcomm Inc.
>> + * Authors:    Md sadre Alam           <quic_mdalam@quicinc.com>
>> + *             Sricharan R             <quic_srichara@quicinc.com>
>> + *             Varadarajan Narayanan   <quic_varada@quicinc.com>
> 
> This is a bit of an exaggeration. You are moving code, not writing new
> code. Please retain the existing copyrights for the moved code.
Ok
> 
>> + *
>> + */
>> +
>> +#include <linux/mtd/nand-qpic-common.h>
>> +
>> +struct qcom_nand_controller *
>> +get_qcom_nand_controller(struct nand_chip *chip)
>> +{
>> +       return container_of(chip->controller, struct qcom_nand_controller,
>> +                           controller);
>> +}
>> +EXPORT_SYMBOL(get_qcom_nand_controller);
> 
> NAK for adding functions to the global export namespace without a
> proper driver-specific prefix.
Ok, will fix in next patch
> 
> Also, a bunch of the code here seems not so well thought. It was fine
> for an internal interface, but it doesn't look so good as a common
> wrapper. Please consider defining a sensible common code module
> interface instead.

  QPIC controller will support both raw NAND as well Serial nand interface.
  This common API file was the part of raw NAND driver , since for serial
  nand most of the APIs from raw nand driver will be re-used that's why i
  have created this common API file, so that QPIC serial nand driver
  drivers/spi/spi-qpic-snand.c and QPIC raw NAND driver
  drivers/mtd/nand/raw/qcom_nandc.c can used these common APIs.

  Could you please suggest how I should handle this in batter way.
> 
> At least each function that is being exported should get a kerneldoc.
Ok
> 
> Last, but not least, please use EXPORT_SYMBOL_GPL.
Ok
> 
>> +
>> +/*
>> + * Helper to prepare DMA descriptors for configuring registers
>> + * before reading a NAND page.
>> + */
>> +void config_nand_page_read(struct nand_chip *chip)
>> +{
>> +       struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
>> +
>> +       write_reg_dma(nandc, NAND_ADDR0, 2, 0);
>> +       write_reg_dma(nandc, NAND_DEV0_CFG0, 3, 0);
>> +       if (!nandc->props->qpic_v2)
>> +               write_reg_dma(nandc, NAND_EBI2_ECC_BUF_CFG, 1, 0);
>> +       write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1, 0);
>> +       write_reg_dma(nandc, NAND_ERASED_CW_DETECT_CFG, 1,
>> +                     NAND_ERASED_CW_SET | NAND_BAM_NEXT_SGL);
>> +}
>> +EXPORT_SYMBOL(config_nand_page_read);
>> +
>> +/* Frees the BAM transaction memory */
>> +void free_bam_transaction(struct qcom_nand_controller *nandc)
>> +{
>> +       struct bam_transaction *bam_txn = nandc->bam_txn;
>> +
>> +       devm_kfree(nandc->dev, bam_txn);
> 
> devm_kfree is usually a bad sign. Either the devm_kfree should be
> dropped (because the memory area is allocated only during probe / init
> and doesn't need to be freed manually) or use kalloc/kfree directly
> without devres wrapping.
Ok
> 
>> +}
>> +EXPORT_SYMBOL(free_bam_transaction);
>> +
> 
> [skipped the rest]
> 
>> --
>> 2.34.1
>>
>>
> 
> 
> --
> With best wishes
> Dmitry

Thanks for reviewing, Will fix all the comments in next patch.

Regards,
Alam.

  reply	other threads:[~2024-02-20 15:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 13:48 [PATCH 0/5] Add QPIC SPI NAND driver Md Sadre Alam
2024-02-15 13:48 ` [PATCH 1/5] spi: dt-bindings: add binding doc for spi-qpic-snand Md Sadre Alam
2024-02-15 14:22   ` Mark Brown
2024-02-20 12:05     ` Md Sadre Alam
2024-02-15 14:24   ` Conor Dooley
2024-02-20 12:06     ` Md Sadre Alam
2024-02-15 19:02   ` Krzysztof Kozlowski
2024-02-20 12:28     ` Md Sadre Alam
2024-02-15 13:48 ` [PATCH 2/5] drivers: mtd: nand: Add qpic_common API file Md Sadre Alam
2024-02-15 15:00   ` Dmitry Baryshkov
2024-02-20 15:59     ` Md Sadre Alam [this message]
2024-02-20 16:07       ` Dmitry Baryshkov
2024-02-21 10:38         ` Md Sadre Alam
2024-02-15 17:55   ` Konrad Dybcio
2024-02-20 12:21     ` Md Sadre Alam
2024-02-16 15:29   ` Kathiravan Thirumoorthy
2024-02-20 12:30     ` Md Sadre Alam
2024-02-15 13:48 ` [PATCH 3/5] spi: spi-qpic: Add qpic spi nand driver support Md Sadre Alam
2024-02-15 14:14   ` Mark Brown
2024-02-20 11:54     ` Md Sadre Alam
2024-02-20 16:04       ` Mark Brown
2024-02-21 10:36         ` Md Sadre Alam
2024-02-15 17:57   ` Konrad Dybcio
2024-02-20 12:14     ` Md Sadre Alam
2024-03-06  6:01       ` Md Sadre Alam
2024-03-06 16:27         ` Konrad Dybcio
2024-03-07  4:10           ` Md Sadre Alam
2024-02-17 13:48   ` kernel test robot
2024-02-17 18:41   ` kernel test robot
2024-02-18  8:14   ` kernel test robot
2024-02-15 13:48 ` [PATCH 4/5] arm64: dts: qcom: ipq9574: Add SPI nand support Md Sadre Alam
2024-02-16 15:40   ` Kathiravan Thirumoorthy
2024-02-20 12:31     ` Md Sadre Alam
2024-02-15 13:48 ` [PATCH 5/5] arm64: dts: qcom: ipq9574: Disable eMMC node Md Sadre Alam
2024-02-15 15:00   ` Dmitry Baryshkov
2024-02-15 17:58     ` Konrad Dybcio
2024-02-20 12:16       ` Md Sadre Alam
2024-02-20 12:12     ` Md Sadre Alam
2024-02-16 15:43   ` Kathiravan Thirumoorthy
2024-02-20 12:33     ` Md Sadre Alam
2024-02-19 13:04 ` [PATCH 0/5] Add QPIC SPI NAND driver Manivannan Sadhasivam
2024-02-20 11:32   ` Md Sadre Alam
2024-02-20 11:36     ` Krzysztof Kozlowski
2024-02-21 10:34       ` Md Sadre Alam
2024-02-21 11:01         ` Krzysztof Kozlowski
2024-02-21 11:08           ` Md Sadre Alam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c574c9ab-0a47-2dc8-9ddd-c08f1b770d7e@quicinc.com \
    --to=quic_mdalam@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=quic_srichara@quicinc.com \
    --cc=quic_varada@quicinc.com \
    --cc=richard@nod.at \
    --cc=robh@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®