Caution: EXT EmailWill fix this in the next patch submission.
On Fri, Oct 7, 2022, at 4:04 PM, Manjunatha Venkatesh wrote:
sr1xx_dev_open(struct inode *inode, struct file *filp)
Do you suggest us to use mutex lock inside open api?+{This looks dangerous if the file gets opened more than once
+ struct sr1xx_dev *sr1xx_dev =
+ container_of(filp->private_data, struct sr1xx_dev, sr1xx_device);
+
+ filp->private_data = sr1xx_dev;
and filp->private_data can have two different values.
I'm fairly sure it adds nothing to readability if every reader hasJust to keep separate function(sr1xx_hw_setup) for better readability+The temporary 'platform_data' structure seems useless here,
+ 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);
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.
we have added intermediate platform_data structure.
to wonder about why you have a platform_data structure here when
the device was never used without devicetree.
Will work on this suggestion and update in the next patch submission.I meant you should change the binding first, and then adapt theare using gpio_to_irq() to use as IRQ pin.+ sr1xx_dev->tx_buffer = kzalloc(SR1XX_TXBUF_SIZE, GFP_KERNEL);Instead of gpio_to_irq(), the DT binding should probably
+ 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;
+ }
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
code to match. Remove all references to gpio numbers from
the code.
Arnd