diff options
| author | Wei Yongjun <yongjun_wei@trendmicro.com.cn> | 2012-09-10 00:42:31 -0400 |
|---|---|---|
| committer | Felipe Balbi <balbi@ti.com> | 2012-09-10 12:26:14 -0400 |
| commit | 58add6ca84c4815feef45008c41274b6df41ede8 (patch) | |
| tree | a8704503fdfe11b1808faff89c7c89e0c7bdf7eb /drivers/usb/otg | |
| parent | c9e4412ab8eb8ef82d645d8749c4ce96ad490007 (diff) | |
usb: otg: move the dereference below the NULL test
The dereference should be moved below the NULL test.
spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/otg')
| -rw-r--r-- | drivers/usb/otg/fsl_otg.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c index 23c798cb2d7f..c19d1d7173a9 100644 --- a/drivers/usb/otg/fsl_otg.c +++ b/drivers/usb/otg/fsl_otg.c | |||
| @@ -544,9 +544,13 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) | |||
| 544 | */ | 544 | */ |
| 545 | static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | 545 | static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
| 546 | { | 546 | { |
| 547 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 547 | struct fsl_otg *otg_dev; |
| 548 | |||
| 549 | if (!otg) | ||
| 550 | return -ENODEV; | ||
| 548 | 551 | ||
| 549 | if (!otg || otg_dev != fsl_otg_dev) | 552 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
| 553 | if (otg_dev != fsl_otg_dev) | ||
| 550 | return -ENODEV; | 554 | return -ENODEV; |
| 551 | 555 | ||
| 552 | otg->host = host; | 556 | otg->host = host; |
| @@ -590,12 +594,15 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
| 590 | static int fsl_otg_set_peripheral(struct usb_otg *otg, | 594 | static int fsl_otg_set_peripheral(struct usb_otg *otg, |
| 591 | struct usb_gadget *gadget) | 595 | struct usb_gadget *gadget) |
| 592 | { | 596 | { |
| 593 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 597 | struct fsl_otg *otg_dev; |
| 594 | 598 | ||
| 599 | if (!otg) | ||
| 600 | return -ENODEV; | ||
| 601 | |||
| 602 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); | ||
| 595 | VDBG("otg_dev 0x%x\n", (int)otg_dev); | 603 | VDBG("otg_dev 0x%x\n", (int)otg_dev); |
| 596 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); | 604 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); |
| 597 | 605 | if (otg_dev != fsl_otg_dev) | |
| 598 | if (!otg || otg_dev != fsl_otg_dev) | ||
| 599 | return -ENODEV; | 606 | return -ENODEV; |
| 600 | 607 | ||
| 601 | if (!gadget) { | 608 | if (!gadget) { |
| @@ -660,10 +667,13 @@ static void fsl_otg_event(struct work_struct *work) | |||
| 660 | /* B-device start SRP */ | 667 | /* B-device start SRP */ |
| 661 | static int fsl_otg_start_srp(struct usb_otg *otg) | 668 | static int fsl_otg_start_srp(struct usb_otg *otg) |
| 662 | { | 669 | { |
| 663 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 670 | struct fsl_otg *otg_dev; |
| 671 | |||
| 672 | if (!otg || otg->phy->state != OTG_STATE_B_IDLE) | ||
| 673 | return -ENODEV; | ||
| 664 | 674 | ||
| 665 | if (!otg || otg_dev != fsl_otg_dev | 675 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
| 666 | || otg->phy->state != OTG_STATE_B_IDLE) | 676 | if (otg_dev != fsl_otg_dev) |
| 667 | return -ENODEV; | 677 | return -ENODEV; |
| 668 | 678 | ||
| 669 | otg_dev->fsm.b_bus_req = 1; | 679 | otg_dev->fsm.b_bus_req = 1; |
| @@ -675,9 +685,13 @@ static int fsl_otg_start_srp(struct usb_otg *otg) | |||
| 675 | /* A_host suspend will call this function to start hnp */ | 685 | /* A_host suspend will call this function to start hnp */ |
| 676 | static int fsl_otg_start_hnp(struct usb_otg *otg) | 686 | static int fsl_otg_start_hnp(struct usb_otg *otg) |
| 677 | { | 687 | { |
| 678 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); | 688 | struct fsl_otg *otg_dev; |
| 689 | |||
| 690 | if (!otg) | ||
| 691 | return -ENODEV; | ||
| 679 | 692 | ||
| 680 | if (!otg || otg_dev != fsl_otg_dev) | 693 | otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
| 694 | if (otg_dev != fsl_otg_dev) | ||
| 681 | return -ENODEV; | 695 | return -ENODEV; |
| 682 | 696 | ||
| 683 | DBG("start_hnp...n"); | 697 | DBG("start_hnp...n"); |
