diff options
author | Christophe Ricard <christophe.ricard@gmail.com> | 2014-04-01 02:34:06 +0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-04-22 02:37:30 +0400 |
commit | fcb45e6ab3c6de2054b13a976ad8d42cef35f529 (patch) | |
tree | fb84a944fb5e8a47cb71b222ab4e29896cdf400f /drivers/nfc | |
parent | 9bac75d0eceb8d7fea74f11a8b304aa1119681f2 (diff) | |
download | linux-fcb45e6ab3c6de2054b13a976ad8d42cef35f529.tar.xz |
NFC: st21nfca: Reworked st21nfca_request_resources
Remove struct st21nfca_i2c_phy* as this parameter can be retrieve
through i2c_get_clientdata(client)
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/st21nfca/i2c.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c index aafe70e9abea..4cbd8fba4b95 100644 --- a/drivers/nfc/st21nfca/i2c.c +++ b/drivers/nfc/st21nfca/i2c.c @@ -451,10 +451,10 @@ static struct nfc_phy_ops i2c_phy_ops = { .disable = st21nfca_hci_i2c_disable, }; -static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy, - struct i2c_client *client) +static int st21nfca_hci_i2c_request_resources(struct i2c_client *client) { struct st21nfca_nfc_platform_data *pdata; + struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client); int r; pdata = client->dev.platform_data; @@ -467,7 +467,6 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy, phy->gpio_irq = pdata->gpio_irq; phy->gpio_ena = pdata->gpio_ena; phy->irq_polarity = pdata->irq_polarity; - phy->i2c_dev = client; r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up"); if (r) { @@ -481,7 +480,7 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy, return -ENODEV; } - if (phy->gpio_ena != 0) { + if (phy->gpio_ena > 0) { r = devm_gpio_request(&client->dev, phy->gpio_ena, "clf_enable"); if (r) { @@ -497,13 +496,7 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy, } } - phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL); - if (phy->pending_skb == NULL) - return -ENOMEM; - - phy->current_read_len = 0; - phy->crc_trials = 0; - return r; + return 0; } static int st21nfca_hci_i2c_probe(struct i2c_client *client, @@ -511,7 +504,8 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client, { struct st21nfca_i2c_phy *phy; struct st21nfca_nfc_platform_data *pdata; - int r = 0; + int r; + int irq; dev_dbg(&client->dev, "%s\n", __func__); dev_dbg(&client->dev, "IRQ: %d\n", client->irq); @@ -530,21 +524,36 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client, } phy->i2c_dev = client; + phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL); + if (phy->pending_skb == NULL) + return -ENOMEM; + phy->current_read_len = 0; + phy->crc_trials = 0; i2c_set_clientdata(client, phy); pdata = client->dev.platform_data; - if (pdata == NULL) { + if (!pdata) { nfc_err(&client->dev, "No platform data\n"); return -EINVAL; } - r = st21nfca_request_resources(phy, client); + r = st21nfca_hci_i2c_request_resources(client); if (r) { nfc_err(&client->dev, "Cannot get platform resources\n"); return r; } + /* IRQ */ + irq = gpio_to_irq(phy->gpio_irq); + if (irq < 0) { + nfc_err(&client->dev, + "Unable to get irq number for GPIO %d error %d\n", + phy->gpio_irq, r); + return -ENODEV; + } + client->irq = irq; + st21nfca_hci_platform_init(phy); r = devm_request_threaded_irq(&client->dev, client->irq, NULL, st21nfca_hci_irq_thread_fn, @@ -576,8 +585,9 @@ static int st21nfca_hci_i2c_remove(struct i2c_client *client) static struct i2c_driver st21nfca_hci_i2c_driver = { .driver = { - .name = ST21NFCA_HCI_I2C_DRIVER_NAME, - }, + .owner = THIS_MODULE, + .name = ST21NFCA_HCI_I2C_DRIVER_NAME, + }, .probe = st21nfca_hci_i2c_probe, .id_table = st21nfca_hci_i2c_id_table, .remove = st21nfca_hci_i2c_remove, |