From: Manjunatha Venkatesh <manjunatha.venkatesh@nxp.com>
To: Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Will Deacon <will@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Rob Herring <robh+dt@kernel.org>
Cc: mb@lightnvm.io, ckeepax@opensource.cirrus.com, arnd@arndb.d,
"Michael S. Tsirkin" <mst@redhat.com>,
javier@javigon.com,
"Michael Kelley (LINUX)" <mikelley@microsoft.com>,
Jason Wang <jasowang@redhat.com>,
sunilmut@microsoft.com, bjorn.andersson@linaro.org,
krzysztof.kozlowski+dt@linaro.org, devicetree@vger.kernel.org,
ashish.deshpande@nxp.com, rvmanjumce@gmail.com
Subject: Re: [EXT] Re: [PATCH v5 2/2] misc: nxp-sr1xx: UWB driver support for sr1xx series chip
Date: Wed, 30 Nov 2022 09:25:26 +0530 [thread overview]
Message-ID: <cbe2baaf-5529-a9c8-b1d1-b22ef294a1e7@nxp.com> (raw)
In-Reply-To: <ab5721fb-bb58-47f7-863f-a6c0ba3c5280@app.fastmail.com>
On 10/7/2022 7:41 PM, Arnd Bergmann wrote:
> Caution: EXT Email
>
> On Fri, Oct 7, 2022, at 4:04 PM, Manjunatha Venkatesh wrote:
>> sr1xx_dev_open(struct inode *inode, struct file *filp)
>>>> +{
>>>> + struct sr1xx_dev *sr1xx_dev =
>>>> + container_of(filp->private_data, struct sr1xx_dev, sr1xx_device);
>>>> +
>>>> + filp->private_data = sr1xx_dev;
>>> This looks dangerous if the file gets opened more than once
>>> and filp->private_data can have two different values.
>> Do you suggest us to use mutex lock inside open api?
>
>>>> +
>>>> + sr1xx_dev->spi = spi;
>>>> + sr1xx_dev->sr1xx_device.minor = MISC_DYNAMIC_MINOR;
>>>> + sr1xx_dev->sr1xx_device.name = "sr1xx";
>>>> + sr1xx_dev->sr1xx_device.fops = &sr1xx_dev_fops;
>>>> + sr1xx_dev->sr1xx_device.parent = &spi->dev;
>>>> + sr1xx_dev->irq_gpio = desc_to_gpio(platform_data.gpiod_irq);
>>>> + sr1xx_dev->ce_gpio = desc_to_gpio(platform_data.gpiod_ce);
>>>> + sr1xx_dev->spi_handshake_gpio =
>>>> + desc_to_gpio(platform_data.gpiod_spi_handshake);
>>> The temporary 'platform_data' structure seems useless here,
>>> just fold its members into the sr1xx_dev structure itself.
>>> No need to store both a gpio descriptor and a number, you
>>> can simplify this to always use the descriptor.
>> Just to keep separate function(sr1xx_hw_setup) for better readability
>> we have added intermediate platform_data structure.
> I'm fairly sure it adds nothing to readability if every reader has
> to wonder about why you have a platform_data structure here when
> the device was never used without devicetree.
Will fix this in the next patch submission.
>>>> + sr1xx_dev->tx_buffer = kzalloc(SR1XX_TXBUF_SIZE, GFP_KERNEL);
>>>> + sr1xx_dev->rx_buffer = kzalloc(SR1XX_RXBUF_SIZE, GFP_KERNEL);
>>>> + if (!sr1xx_dev->tx_buffer) {
>>>> + ret = -ENOMEM;
>>>> + goto err_exit;
>>>> + }
>>>> + if (!sr1xx_dev->rx_buffer) {
>>>> + ret = -ENOMEM;
>>>> + goto err_exit;
>>>> + }
>>>> +
>>>> + sr1xx_dev->spi->irq = gpio_to_irq(sr1xx_dev->irq_gpio);
>>>> + if (sr1xx_dev->spi->irq < 0) {
>>>> + dev_err(&spi->dev, "gpio_to_irq request failed gpio = 0x%x\n",
>>>> + sr1xx_dev->irq_gpio);
>>>> + goto err_exit;
>>>> + }
>>> Instead of gpio_to_irq(), the DT binding should probably
>>> list the interrupt directly using the "interrupts" property
>>> pointing to the gpio controller. Since, we are configured this as generic GPIO in DT binding. So, we
>> are using gpio_to_irq() to use as IRQ pin.
> I meant you should change the binding first, and then adapt the
> code to match. Remove all references to gpio numbers from
> the code.
Will work on this suggestion and update in the next patch submission.
> Arnd
next prev parent reply other threads:[~2022-11-30 3:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 14:29 [PATCH v5 0/2] Uwb: Nxp: Driver for SR1XX SOCs Patch Series Manjunatha Venkatesh
2022-09-14 14:29 ` [PATCH v5 1/2] dt-bindings: uwb: Device tree information for Nxp SR1XX SOCs Manjunatha Venkatesh
2022-09-14 14:36 ` Arnd Bergmann
2022-10-07 11:39 ` [EXT] " Manjunatha Venkatesh
2022-10-07 12:30 ` Krzysztof Kozlowski
2022-09-16 19:26 ` Rob Herring
2022-09-14 14:29 ` [PATCH v5 2/2] misc: nxp-sr1xx: UWB driver support for sr1xx series chip Manjunatha Venkatesh
2022-09-14 14:53 ` Greg KH
2022-11-30 3:40 ` [EXT] " Manjunatha Venkatesh
2022-11-30 7:27 ` Greg KH
2022-12-20 14:09 ` Manjunatha Venkatesh
2022-12-20 14:30 ` Greg KH
2022-12-20 14:43 ` Manjunatha Venkatesh
2022-09-14 14:55 ` Greg KH
2022-10-07 14:19 ` [EXT] " Manjunatha Venkatesh
2022-09-14 15:09 ` Arnd Bergmann
[not found] ` <cd397721-f549-5c65-2c65-35b09c3ea7f9@nxp.com>
2022-10-07 14:11 ` [EXT] " Arnd Bergmann
2022-11-30 3:55 ` Manjunatha Venkatesh [this message]
2022-10-07 14:57 ` Greg Kroah-Hartman
2022-11-30 4:09 ` Manjunatha Venkatesh
2022-11-30 7:23 ` Greg Kroah-Hartman
2022-12-20 14:33 ` Manjunatha Venkatesh
2022-12-20 14:51 ` Greg Kroah-Hartman
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=cbe2baaf-5529-a9c8-b1d1-b22ef294a1e7@nxp.com \
--to=manjunatha.venkatesh@nxp.com \
--cc=arnd@arndb.d \
--cc=arnd@arndb.de \
--cc=ashish.deshpande@nxp.com \
--cc=axboe@kernel.dk \
--cc=bjorn.andersson@linaro.org \
--cc=ckeepax@opensource.cirrus.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jasowang@redhat.com \
--cc=javier@javigon.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
--cc=mikelley@microsoft.com \
--cc=mst@redhat.com \
--cc=robh+dt@kernel.org \
--cc=rvmanjumce@gmail.com \
--cc=sunilmut@microsoft.com \
--cc=will@kernel.org \
/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®