[PATCH v3 3/8] serial: exar: added a exar_get_nr_ports function

Parker Newman posted 8 patches 1 year, 10 months ago
There is a newer version of this series
[PATCH v3 3/8] serial: exar: added a exar_get_nr_ports function
Posted by Parker Newman 1 year, 10 months ago
From: Parker Newman <pnewman@connecttech.com>

Moved code for getting number of ports from exar_pci_probe() to a
separate exar_get_nr_ports() function.

Chnages in v3:
- Only moved existing code in this patch, will add CTI code in subsequent
  patch

Signed-off-by: Parker Newman <pnewman@connecttech.com>
---
 drivers/tty/serial/8250/8250_exar.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 3565b880f512..388dd60ad23a 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -703,6 +703,21 @@ static irqreturn_t exar_misc_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }

+static unsigned int exar_get_nr_ports(struct exar8250_board *board,
+					struct pci_dev *pcidev)
+{
+	unsigned int nr_ports = 0;
+
+	if (pcidev->vendor == PCI_VENDOR_ID_ACCESSIO)
+		nr_ports = BIT(((pcidev->device & 0x38) >> 3) - 1);
+	else if (board->num_ports)
+		nr_ports = board->num_ports;
+	else
+		nr_ports = pcidev->device & 0x0f;
+
+	return nr_ports;
+}
+
 static int
 exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 {
@@ -722,12 +737,12 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)

 	maxnr = pci_resource_len(pcidev, bar) >> (board->reg_shift + 3);

-	if (pcidev->vendor == PCI_VENDOR_ID_ACCESSIO)
-		nr_ports = BIT(((pcidev->device & 0x38) >> 3) - 1);
-	else if (board->num_ports)
-		nr_ports = board->num_ports;
-	else
-		nr_ports = pcidev->device & 0x0f;
+	nr_ports = exar_get_nr_ports(board, pcidev);
+	if (nr_ports == 0) {
+		dev_err_probe(&pcidev->dev, -ENODEV,
+				"failed to get number of ports\n");
+		return -ENODEV;
+	}

 	priv = devm_kzalloc(&pcidev->dev, struct_size(priv, line, nr_ports), GFP_KERNEL);
 	if (!priv)
--
2.43.2
Re: [PATCH v3 3/8] serial: exar: added a exar_get_nr_ports function
Posted by Greg Kroah-Hartman 1 year, 9 months ago
On Tue, Apr 16, 2024 at 08:55:30AM -0400, Parker Newman wrote:
> From: Parker Newman <pnewman@connecttech.com>
> 
> Moved code for getting number of ports from exar_pci_probe() to a
> separate exar_get_nr_ports() function.
> 
> Chnages in v3:
> - Only moved existing code in this patch, will add CTI code in subsequent
>   patch

Nit, the "changes" need to go below the --- line, otherwise it shows up
in the change logs.

So when you resend this, can you put these below the --- line please?

thanks,

greg k-h
Re: [PATCH v3 3/8] serial: exar: added a exar_get_nr_ports function
Posted by Parker Newman 1 year, 9 months ago
On Wed, 17 Apr 2024 13:15:41 +0200
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> On Tue, Apr 16, 2024 at 08:55:30AM -0400, Parker Newman wrote:
> > From: Parker Newman <pnewman@connecttech.com>
> >
> > Moved code for getting number of ports from exar_pci_probe() to a
> > separate exar_get_nr_ports() function.
> >
> > Chnages in v3:
> > - Only moved existing code in this patch, will add CTI code in subsequent
> >   patch
>
> Nit, the "changes" need to go below the --- line, otherwise it shows up
> in the change logs.
>
> So when you resend this, can you put these below the --- line please?
>

Yes sorry see that note online now. Will do in next version.

Thanks,
Parker

> thanks,
>
> greg k-h