static int st21nfcb_nci_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct st21nfcb_i2c_phy *phy; struct st21nfcb_nfc_platform_data *pdata; int r; dev_dbg(&client->dev, "%s\n", __func__); dev_dbg(&client->dev, "IRQ: %d\n", client->irq); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { nfc_err(&client->dev, "Need I2C_FUNC_I2C\n"); return -ENODEV; } phy = devm_kzalloc(&client->dev, sizeof(struct st21nfcb_i2c_phy), GFP_KERNEL); if (!phy) { nfc_err(&client->dev, "Cannot allocate memory for st21nfcb i2c phy.\n"); return -ENOMEM; } phy->i2c_dev = client; i2c_set_clientdata(client, phy); pdata = client->dev.platform_data; if (!pdata && client->dev.of_node) { r = st21nfcb_nci_i2c_of_request_resources(client); if (r) { nfc_err(&client->dev, "No platform data\n"); return r; } } else if (pdata) { r = st21nfcb_nci_i2c_request_resources(client); if (r) { nfc_err(&client->dev, "Cannot get platform resources\n"); return r; } } else { nfc_err(&client->dev, "st21nfcb platform resources not available\n"); return -ENODEV; } r = devm_request_threaded_irq(&client->dev, client->irq, NULL, st21nfcb_nci_irq_thread_fn, phy->irq_polarity | IRQF_ONESHOT, ST21NFCB_NCI_DRIVER_NAME, phy); if (r < 0) { nfc_err(&client->dev, "Unable to register IRQ handler\n"); return r; } return ndlc_probe(phy, &i2c_phy_ops, &client->dev, ST21NFCB_FRAME_HEADROOM, ST21NFCB_FRAME_TAILROOM, &phy->ndlc); }
static int st_nci_spi_probe(struct spi_device *dev) { struct st_nci_spi_phy *phy; int r; dev_dbg(&dev->dev, "%s\n", __func__); dev_dbg(&dev->dev, "IRQ: %d\n", dev->irq); /* Check SPI platform functionnalities */ if (!dev) { pr_debug("%s: dev is NULL. Device is not accessible.\n", __func__); return -ENODEV; } phy = devm_kzalloc(&dev->dev, sizeof(struct st_nci_spi_phy), GFP_KERNEL); if (!phy) return -ENOMEM; phy->spi_dev = dev; spi_set_drvdata(dev, phy); r = devm_acpi_dev_add_driver_gpios(&dev->dev, acpi_st_nci_gpios); if (r) dev_dbg(&dev->dev, "Unable to add GPIO mapping table\n"); /* Get RESET GPIO */ phy->gpiod_reset = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(phy->gpiod_reset)) { nfc_err(&dev->dev, "Unable to get RESET GPIO\n"); return PTR_ERR(phy->gpiod_reset); } phy->se_status.is_ese_present = device_property_read_bool(&dev->dev, "ese-present"); phy->se_status.is_uicc_present = device_property_read_bool(&dev->dev, "uicc-present"); r = ndlc_probe(phy, &spi_phy_ops, &dev->dev, ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM, &phy->ndlc, &phy->se_status); if (r < 0) { nfc_err(&dev->dev, "Unable to register ndlc layer\n"); return r; } phy->irq_active = true; r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL, st_nci_irq_thread_fn, IRQF_ONESHOT, ST_NCI_SPI_DRIVER_NAME, phy); if (r < 0) nfc_err(&dev->dev, "Unable to register IRQ handler\n"); return r; }
static int st_nci_spi_probe(struct spi_device *dev) { struct st_nci_spi_phy *phy; struct st_nci_nfc_platform_data *pdata; int r; dev_dbg(&dev->dev, "%s\n", __func__); dev_dbg(&dev->dev, "IRQ: %d\n", dev->irq); /* Check SPI platform functionnalities */ if (!dev) { pr_debug("%s: dev is NULL. Device is not accessible.\n", __func__); return -ENODEV; } phy = devm_kzalloc(&dev->dev, sizeof(struct st_nci_spi_phy), GFP_KERNEL); if (!phy) return -ENOMEM; phy->spi_dev = dev; spi_set_drvdata(dev, phy); pdata = dev->dev.platform_data; if (!pdata && dev->dev.of_node) { r = st_nci_spi_of_request_resources(dev); if (r) { nfc_err(&dev->dev, "No platform data\n"); return r; } } else if (pdata) { r = st_nci_spi_request_resources(dev); if (r) { nfc_err(&dev->dev, "Cannot get platform resources\n"); return r; } } else { nfc_err(&dev->dev, "st_nci platform resources not available\n"); return -ENODEV; } r = ndlc_probe(phy, &spi_phy_ops, &dev->dev, ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM, &phy->ndlc, &phy->se_status); if (r < 0) { nfc_err(&dev->dev, "Unable to register ndlc layer\n"); return r; } phy->irq_active = true; r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL, st_nci_irq_thread_fn, phy->irq_polarity | IRQF_ONESHOT, ST_NCI_SPI_DRIVER_NAME, phy); if (r < 0) nfc_err(&dev->dev, "Unable to register IRQ handler\n"); return r; }