aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorAnton Tikhomirov <av.tikhomirov@samsung.com>2013-10-03 12:42:04 +0900
committerFelipe Balbi <balbi@ti.com>2013-10-04 09:44:45 -0500
commit737cc66eac350d674c72a3f903541644098ec47e (patch)
treef01b1673e6cdb67d3772d6e3a545c014fdfec2c9 /drivers/usb/phy
parentusb: phy: Pass OTG FSM pointer to callback functions (diff)
downloadlinux-dev-737cc66eac350d674c72a3f903541644098ec47e.tar.xz
linux-dev-737cc66eac350d674c72a3f903541644098ec47e.zip
usb: phy: Check OTG FSM callback existance in helper functions
Existence of callback must be checked to avoid NULL pointer dereferncing. Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/phy')
-rw-r--r--drivers/usb/phy/phy-fsm-usb.h35
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/usb/phy/phy-fsm-usb.h b/drivers/usb/phy/phy-fsm-usb.h
index 75344bec4679..0f3f7d87f887 100644
--- a/drivers/usb/phy/phy-fsm-usb.h
+++ b/drivers/usb/phy/phy-fsm-usb.h
@@ -95,48 +95,69 @@ struct otg_fsm_ops {
};
-static inline void otg_chrg_vbus(struct otg_fsm *fsm, int on)
+static inline int otg_chrg_vbus(struct otg_fsm *fsm, int on)
{
+ if (!fsm->ops->chrg_vbus)
+ return -EOPNOTSUPP;
fsm->ops->chrg_vbus(fsm, on);
+ return 0;
}
-static inline void otg_drv_vbus(struct otg_fsm *fsm, int on)
+static inline int otg_drv_vbus(struct otg_fsm *fsm, int on)
{
+ if (!fsm->ops->drv_vbus)
+ return -EOPNOTSUPP;
if (fsm->drv_vbus != on) {
fsm->drv_vbus = on;
fsm->ops->drv_vbus(fsm, on);
}
+ return 0;
}
-static inline void otg_loc_conn(struct otg_fsm *fsm, int on)
+static inline int otg_loc_conn(struct otg_fsm *fsm, int on)
{
+ if (!fsm->ops->loc_conn)
+ return -EOPNOTSUPP;
if (fsm->loc_conn != on) {
fsm->loc_conn = on;
fsm->ops->loc_conn(fsm, on);
}
+ return 0;
}
-static inline void otg_loc_sof(struct otg_fsm *fsm, int on)
+static inline int otg_loc_sof(struct otg_fsm *fsm, int on)
{
+ if (!fsm->ops->loc_sof)
+ return -EOPNOTSUPP;
if (fsm->loc_sof != on) {
fsm->loc_sof = on;
fsm->ops->loc_sof(fsm, on);
}
+ return 0;
}
-static inline void otg_start_pulse(struct otg_fsm *fsm)
+static inline int otg_start_pulse(struct otg_fsm *fsm)
{
+ if (!fsm->ops->start_pulse)
+ return -EOPNOTSUPP;
fsm->ops->start_pulse(fsm);
+ return 0;
}
-static inline void otg_add_timer(struct otg_fsm *fsm, void *timer)
+static inline int otg_add_timer(struct otg_fsm *fsm, void *timer)
{
+ if (!fsm->ops->add_timer)
+ return -EOPNOTSUPP;
fsm->ops->add_timer(fsm, timer);
+ return 0;
}
-static inline void otg_del_timer(struct otg_fsm *fsm, void *timer)
+static inline int otg_del_timer(struct otg_fsm *fsm, void *timer)
{
+ if (!fsm->ops->del_timer)
+ return -EOPNOTSUPP;
fsm->ops->del_timer(fsm, timer);
+ return 0;
}
int otg_statemachine(struct otg_fsm *fsm);