diff options
Diffstat (limited to 'drivers/nfc/st21nfca/i2c.c')
-rw-r--r-- | drivers/nfc/st21nfca/i2c.c | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c index ff31939978ae..0ea756b77519 100644 --- a/drivers/nfc/st21nfca/i2c.c +++ b/drivers/nfc/st21nfca/i2c.c | |||
@@ -271,6 +271,7 @@ static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb) | |||
271 | static int get_frame_size(u8 *buf, int buflen) | 271 | static int get_frame_size(u8 *buf, int buflen) |
272 | { | 272 | { |
273 | int len = 0; | 273 | int len = 0; |
274 | |||
274 | if (buf[len + 1] == ST21NFCA_SOF_EOF) | 275 | if (buf[len + 1] == ST21NFCA_SOF_EOF) |
275 | return 0; | 276 | return 0; |
276 | 277 | ||
@@ -311,6 +312,7 @@ static int check_crc(u8 *buf, int buflen) | |||
311 | static int st21nfca_hci_i2c_repack(struct sk_buff *skb) | 312 | static int st21nfca_hci_i2c_repack(struct sk_buff *skb) |
312 | { | 313 | { |
313 | int i, j, r, size; | 314 | int i, j, r, size; |
315 | |||
314 | if (skb->len < 1 || (skb->len > 1 && skb->data[1] != 0)) | 316 | if (skb->len < 1 || (skb->len > 1 && skb->data[1] != 0)) |
315 | return -EBADMSG; | 317 | return -EBADMSG; |
316 | 318 | ||
@@ -525,24 +527,19 @@ static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client) | |||
525 | } | 527 | } |
526 | 528 | ||
527 | /* GPIO request and configuration */ | 529 | /* GPIO request and configuration */ |
528 | r = devm_gpio_request(&client->dev, gpio, "clf_enable"); | 530 | r = devm_gpio_request_one(&client->dev, gpio, GPIOF_OUT_INIT_HIGH, |
531 | "clf_enable"); | ||
529 | if (r) { | 532 | if (r) { |
530 | nfc_err(&client->dev, "Failed to request enable pin\n"); | 533 | nfc_err(&client->dev, "Failed to request enable pin\n"); |
531 | return -ENODEV; | 534 | return -ENODEV; |
532 | } | 535 | } |
533 | 536 | ||
534 | r = gpio_direction_output(gpio, 1); | ||
535 | if (r) { | ||
536 | nfc_err(&client->dev, "Failed to set enable pin direction as output\n"); | ||
537 | return -ENODEV; | ||
538 | } | ||
539 | phy->gpio_ena = gpio; | 537 | phy->gpio_ena = gpio; |
540 | 538 | ||
541 | /* IRQ */ | 539 | /* IRQ */ |
542 | r = irq_of_parse_and_map(pp, 0); | 540 | r = irq_of_parse_and_map(pp, 0); |
543 | if (r < 0) { | 541 | if (r < 0) { |
544 | nfc_err(&client->dev, | 542 | nfc_err(&client->dev, "Unable to get irq, error: %d\n", r); |
545 | "Unable to get irq, error: %d\n", r); | ||
546 | return r; | 543 | return r; |
547 | } | 544 | } |
548 | 545 | ||
@@ -576,32 +573,20 @@ static int st21nfca_hci_i2c_request_resources(struct i2c_client *client) | |||
576 | phy->gpio_ena = pdata->gpio_ena; | 573 | phy->gpio_ena = pdata->gpio_ena; |
577 | phy->irq_polarity = pdata->irq_polarity; | 574 | phy->irq_polarity = pdata->irq_polarity; |
578 | 575 | ||
579 | r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up"); | 576 | r = devm_gpio_request_one(&client->dev, phy->gpio_irq, GPIOF_IN, |
577 | "wake_up"); | ||
580 | if (r) { | 578 | if (r) { |
581 | pr_err("%s : gpio_request failed\n", __FILE__); | 579 | pr_err("%s : gpio_request failed\n", __FILE__); |
582 | return -ENODEV; | 580 | return -ENODEV; |
583 | } | 581 | } |
584 | 582 | ||
585 | r = gpio_direction_input(phy->gpio_irq); | ||
586 | if (r) { | ||
587 | pr_err("%s : gpio_direction_input failed\n", __FILE__); | ||
588 | return -ENODEV; | ||
589 | } | ||
590 | |||
591 | if (phy->gpio_ena > 0) { | 583 | if (phy->gpio_ena > 0) { |
592 | r = devm_gpio_request(&client->dev, | 584 | r = devm_gpio_request_one(&client->dev, phy->gpio_ena, |
593 | phy->gpio_ena, "clf_enable"); | 585 | GPIOF_OUT_INIT_HIGH, "clf_enable"); |
594 | if (r) { | 586 | if (r) { |
595 | pr_err("%s : ena gpio_request failed\n", __FILE__); | 587 | pr_err("%s : ena gpio_request failed\n", __FILE__); |
596 | return -ENODEV; | 588 | return -ENODEV; |
597 | } | 589 | } |
598 | r = gpio_direction_output(phy->gpio_ena, 1); | ||
599 | |||
600 | if (r) { | ||
601 | pr_err("%s : ena gpio_direction_output failed\n", | ||
602 | __FILE__); | ||
603 | return -ENODEV; | ||
604 | } | ||
605 | } | 590 | } |
606 | 591 | ||
607 | /* IRQ */ | 592 | /* IRQ */ |
@@ -711,7 +696,6 @@ static struct i2c_driver st21nfca_hci_i2c_driver = { | |||
711 | .driver = { | 696 | .driver = { |
712 | .owner = THIS_MODULE, | 697 | .owner = THIS_MODULE, |
713 | .name = ST21NFCA_HCI_I2C_DRIVER_NAME, | 698 | .name = ST21NFCA_HCI_I2C_DRIVER_NAME, |
714 | .owner = THIS_MODULE, | ||
715 | .of_match_table = of_match_ptr(of_st21nfca_i2c_match), | 699 | .of_match_table = of_match_ptr(of_st21nfca_i2c_match), |
716 | }, | 700 | }, |
717 | .probe = st21nfca_hci_i2c_probe, | 701 | .probe = st21nfca_hci_i2c_probe, |