summaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2014-03-31 18:34:06 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2014-04-21 18:37:30 -0400
commitfcb45e6ab3c6de2054b13a976ad8d42cef35f529 (patch)
treefb84a944fb5e8a47cb71b222ab4e29896cdf400f /drivers/nfc
parent9bac75d0eceb8d7fea74f11a8b304aa1119681f2 (diff)
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.c42
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 = {
451 .disable = st21nfca_hci_i2c_disable, 451 .disable = st21nfca_hci_i2c_disable,
452}; 452};
453 453
454static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy, 454static int st21nfca_hci_i2c_request_resources(struct i2c_client *client)
455 struct i2c_client *client)
456{ 455{
457 struct st21nfca_nfc_platform_data *pdata; 456 struct st21nfca_nfc_platform_data *pdata;
457 struct st21nfca_i2c_phy *phy = i2c_get_clientdata(client);
458 int r; 458 int r;
459 459
460 pdata = client->dev.platform_data; 460 pdata = client->dev.platform_data;
@@ -467,7 +467,6 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy,
467 phy->gpio_irq = pdata->gpio_irq; 467 phy->gpio_irq = pdata->gpio_irq;
468 phy->gpio_ena = pdata->gpio_ena; 468 phy->gpio_ena = pdata->gpio_ena;
469 phy->irq_polarity = pdata->irq_polarity; 469 phy->irq_polarity = pdata->irq_polarity;
470 phy->i2c_dev = client;
471 470
472 r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up"); 471 r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up");
473 if (r) { 472 if (r) {
@@ -481,7 +480,7 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy,
481 return -ENODEV; 480 return -ENODEV;
482 } 481 }
483 482
484 if (phy->gpio_ena != 0) { 483 if (phy->gpio_ena > 0) {
485 r = devm_gpio_request(&client->dev, 484 r = devm_gpio_request(&client->dev,
486 phy->gpio_ena, "clf_enable"); 485 phy->gpio_ena, "clf_enable");
487 if (r) { 486 if (r) {
@@ -497,13 +496,7 @@ static int st21nfca_request_resources(struct st21nfca_i2c_phy *phy,
497 } 496 }
498 } 497 }
499 498
500 phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL); 499 return 0;
501 if (phy->pending_skb == NULL)
502 return -ENOMEM;
503
504 phy->current_read_len = 0;
505 phy->crc_trials = 0;
506 return r;
507} 500}
508 501
509static int st21nfca_hci_i2c_probe(struct i2c_client *client, 502static int st21nfca_hci_i2c_probe(struct i2c_client *client,
@@ -511,7 +504,8 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client,
511{ 504{
512 struct st21nfca_i2c_phy *phy; 505 struct st21nfca_i2c_phy *phy;
513 struct st21nfca_nfc_platform_data *pdata; 506 struct st21nfca_nfc_platform_data *pdata;
514 int r = 0; 507 int r;
508 int irq;
515 509
516 dev_dbg(&client->dev, "%s\n", __func__); 510 dev_dbg(&client->dev, "%s\n", __func__);
517 dev_dbg(&client->dev, "IRQ: %d\n", client->irq); 511 dev_dbg(&client->dev, "IRQ: %d\n", client->irq);
@@ -530,21 +524,36 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client,
530 } 524 }
531 525
532 phy->i2c_dev = client; 526 phy->i2c_dev = client;
527 phy->pending_skb = alloc_skb(ST21NFCA_HCI_LLC_MAX_SIZE * 2, GFP_KERNEL);
528 if (phy->pending_skb == NULL)
529 return -ENOMEM;
533 530
531 phy->current_read_len = 0;
532 phy->crc_trials = 0;
534 i2c_set_clientdata(client, phy); 533 i2c_set_clientdata(client, phy);
535 534
536 pdata = client->dev.platform_data; 535 pdata = client->dev.platform_data;
537 if (pdata == NULL) { 536 if (!pdata) {
538 nfc_err(&client->dev, "No platform data\n"); 537 nfc_err(&client->dev, "No platform data\n");
539 return -EINVAL; 538 return -EINVAL;
540 } 539 }
541 540
542 r = st21nfca_request_resources(phy, client); 541 r = st21nfca_hci_i2c_request_resources(client);
543 if (r) { 542 if (r) {
544 nfc_err(&client->dev, "Cannot get platform resources\n"); 543 nfc_err(&client->dev, "Cannot get platform resources\n");
545 return r; 544 return r;
546 } 545 }
547 546
547 /* IRQ */
548 irq = gpio_to_irq(phy->gpio_irq);
549 if (irq < 0) {
550 nfc_err(&client->dev,
551 "Unable to get irq number for GPIO %d error %d\n",
552 phy->gpio_irq, r);
553 return -ENODEV;
554 }
555 client->irq = irq;
556
548 st21nfca_hci_platform_init(phy); 557 st21nfca_hci_platform_init(phy);
549 r = devm_request_threaded_irq(&client->dev, client->irq, NULL, 558 r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
550 st21nfca_hci_irq_thread_fn, 559 st21nfca_hci_irq_thread_fn,
@@ -576,8 +585,9 @@ static int st21nfca_hci_i2c_remove(struct i2c_client *client)
576 585
577static struct i2c_driver st21nfca_hci_i2c_driver = { 586static struct i2c_driver st21nfca_hci_i2c_driver = {
578 .driver = { 587 .driver = {
579 .name = ST21NFCA_HCI_I2C_DRIVER_NAME, 588 .owner = THIS_MODULE,
580 }, 589 .name = ST21NFCA_HCI_I2C_DRIVER_NAME,
590 },
581 .probe = st21nfca_hci_i2c_probe, 591 .probe = st21nfca_hci_i2c_probe,
582 .id_table = st21nfca_hci_i2c_id_table, 592 .id_table = st21nfca_hci_i2c_id_table,
583 .remove = st21nfca_hci_i2c_remove, 593 .remove = st21nfca_hci_i2c_remove,