Skip to content

Commit 2990f3a

Browse files
andy-shevrafaeljw
authored andcommitted
spi: pxa2xx: Refactor _UID handling to use acpi_dev_uid_to_integer()
ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as an integer. Use it instead of custom approach. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 9cde625 commit 2990f3a

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

drivers/spi/spi-pxa2xx.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,31 +1441,6 @@ static const struct of_device_id pxa2xx_spi_of_match[] = {
14411441
};
14421442
MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match);
14431443

1444-
#ifdef CONFIG_ACPI
1445-
1446-
static int pxa2xx_spi_get_port_id(struct device *dev)
1447-
{
1448-
struct acpi_device *adev;
1449-
unsigned int devid;
1450-
int port_id = -1;
1451-
1452-
adev = ACPI_COMPANION(dev);
1453-
if (adev && adev->pnp.unique_id &&
1454-
!kstrtouint(adev->pnp.unique_id, 0, &devid))
1455-
port_id = devid;
1456-
return port_id;
1457-
}
1458-
1459-
#else /* !CONFIG_ACPI */
1460-
1461-
static int pxa2xx_spi_get_port_id(struct device *dev)
1462-
{
1463-
return -1;
1464-
}
1465-
1466-
#endif /* CONFIG_ACPI */
1467-
1468-
14691444
#ifdef CONFIG_PCI
14701445

14711446
static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param)
@@ -1479,13 +1454,16 @@ static struct pxa2xx_spi_controller *
14791454
pxa2xx_spi_init_pdata(struct platform_device *pdev)
14801455
{
14811456
struct pxa2xx_spi_controller *pdata;
1457+
struct device *dev = &pdev->dev;
1458+
struct device *parent = dev->parent;
14821459
struct ssp_device *ssp;
14831460
struct resource *res;
1484-
struct device *parent = pdev->dev.parent;
14851461
struct pci_dev *pcidev = dev_is_pci(parent) ? to_pci_dev(parent) : NULL;
14861462
const struct pci_device_id *pcidev_id = NULL;
14871463
enum pxa_ssp_type type;
14881464
const void *match;
1465+
int status;
1466+
u64 uid;
14891467

14901468
if (pcidev)
14911469
pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, pcidev);
@@ -1529,7 +1507,12 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev)
15291507

15301508
ssp->type = type;
15311509
ssp->dev = &pdev->dev;
1532-
ssp->port_id = pxa2xx_spi_get_port_id(&pdev->dev);
1510+
1511+
status = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid);
1512+
if (status)
1513+
ssp->port_id = -1;
1514+
else
1515+
ssp->port_id = uid;
15331516

15341517
pdata->is_slave = device_property_read_bool(&pdev->dev, "spi-slave");
15351518
pdata->num_chipselect = 1;

0 commit comments

Comments
 (0)