mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 23:58:05 +00:00
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>
This commit is contained in:
parent
9bac75d0ec
commit
fcb45e6ab3
1 changed files with 26 additions and 16 deletions
|
@ -451,10 +451,10 @@ static struct nfc_phy_ops i2c_phy_ops = {
|
||||||
.disable = st21nfca_hci_i2c_disable,
|
.disable = st21nfca_hci_i2c_disable,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy,
|
static int st21nfca_hci_i2c_request_resources(struct i2c_client *client)
|
||||||
struct i2c_client *client)
|
|
||||||
{
|
{
|
||||||
struct st21nfca_nfc_platform_data *pdata;
|
struct st21nfca_nfc_platform_data *pdata;
|
||||||
|
struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
pdata = client->dev.platform_data;
|
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_irq = pdata->gpio_irq;
|
||||||
phy->gpio_ena = pdata->gpio_ena;
|
phy->gpio_ena = pdata->gpio_ena;
|
||||||
phy->irq_polarity = pdata->irq_polarity;
|
phy->irq_polarity = pdata->irq_polarity;
|
||||||
phy->i2c_dev = client;
|
|
||||||
|
|
||||||
r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up");
|
r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up");
|
||||||
if (r) {
|
if (r) {
|
||||||
|
@ -481,7 +480,7 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy,
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phy->gpio_ena != 0) {
|
if (phy->gpio_ena > 0) {
|
||||||
r = devm_gpio_request(&client->dev,
|
r = devm_gpio_request(&client->dev,
|
||||||
phy->gpio_ena, "clf_enable");
|
phy->gpio_ena, "clf_enable");
|
||||||
if (r) {
|
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);
|
return 0;
|
||||||
if (phy->pending_skb == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
phy->current_read_len = 0;
|
|
||||||
phy->crc_trials = 0;
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int st21nfca_hci_i2c_probe(struct i2c_client *client,
|
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_i2c_phy *phy;
|
||||||
struct st21nfca_nfc_platform_data *pdata;
|
struct st21nfca_nfc_platform_data *pdata;
|
||||||
int r = 0;
|
int r;
|
||||||
|
int irq;
|
||||||
|
|
||||||
dev_dbg(&client->dev, "%s\n", __func__);
|
dev_dbg(&client->dev, "%s\n", __func__);
|
||||||
dev_dbg(&client->dev, "IRQ: %d\n", client->irq);
|
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->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);
|
i2c_set_clientdata(client, phy);
|
||||||
|
|
||||||
pdata = client->dev.platform_data;
|
pdata = client->dev.platform_data;
|
||||||
if (pdata == NULL) {
|
if (!pdata) {
|
||||||
nfc_err(&client->dev, "No platform data\n");
|
nfc_err(&client->dev, "No platform data\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = st21nfca_request_resources(phy, client);
|
r = st21nfca_hci_i2c_request_resources(client);
|
||||||
if (r) {
|
if (r) {
|
||||||
nfc_err(&client->dev, "Cannot get platform resources\n");
|
nfc_err(&client->dev, "Cannot get platform resources\n");
|
||||||
return r;
|
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);
|
st21nfca_hci_platform_init(phy);
|
||||||
r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
|
r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
|
||||||
st21nfca_hci_irq_thread_fn,
|
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 = {
|
static struct i2c_driver st21nfca_hci_i2c_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = ST21NFCA_HCI_I2C_DRIVER_NAME,
|
.owner = THIS_MODULE,
|
||||||
},
|
.name = ST21NFCA_HCI_I2C_DRIVER_NAME,
|
||||||
|
},
|
||||||
.probe = st21nfca_hci_i2c_probe,
|
.probe = st21nfca_hci_i2c_probe,
|
||||||
.id_table = st21nfca_hci_i2c_id_table,
|
.id_table = st21nfca_hci_i2c_id_table,
|
||||||
.remove = st21nfca_hci_i2c_remove,
|
.remove = st21nfca_hci_i2c_remove,
|
||||||
|
|
Loading…
Reference in a new issue