diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2017-08-06 07:04:05 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-08-09 09:41:44 -0400 |
commit | c33da628de92dc64c11009b885871f963278469a (patch) | |
tree | 4146aa17944cdc78f383b15262fd76c287ffab0e /drivers/media/cec | |
parent | 73a167452454e0da25287ef1c5bf16188f4697bf (diff) | |
download | linux-stable-c33da628de92dc64c11009b885871f963278469a.tar.gz linux-stable-c33da628de92dc64c11009b885871f963278469a.tar.bz2 linux-stable-c33da628de92dc64c11009b885871f963278469a.zip |
media: cec-api: log the reason for the -EINVAL in cec_s_mode
If cec_debug >= 1 then log why the requested mode returned -EINVAL.
It can be hard to debug this since -EINVAL can be returned for many
reasons. So this should help.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/cec')
-rw-r--r-- | drivers/media/cec/cec-api.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c index 8dd16e263452..00d43d74020f 100644 --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -357,34 +357,47 @@ static long cec_s_mode(struct cec_adapter *adap, struct cec_fh *fh, if (copy_from_user(&mode, parg, sizeof(mode))) return -EFAULT; - if (mode & ~(CEC_MODE_INITIATOR_MSK | CEC_MODE_FOLLOWER_MSK)) + if (mode & ~(CEC_MODE_INITIATOR_MSK | CEC_MODE_FOLLOWER_MSK)) { + dprintk(1, "%s: invalid mode bits set\n", __func__); return -EINVAL; + } mode_initiator = mode & CEC_MODE_INITIATOR_MSK; mode_follower = mode & CEC_MODE_FOLLOWER_MSK; if (mode_initiator > CEC_MODE_EXCL_INITIATOR || - mode_follower > CEC_MODE_MONITOR_ALL) + mode_follower > CEC_MODE_MONITOR_ALL) { + dprintk(1, "%s: unknown mode\n", __func__); return -EINVAL; + } if (mode_follower == CEC_MODE_MONITOR_ALL && - !(adap->capabilities & CEC_CAP_MONITOR_ALL)) + !(adap->capabilities & CEC_CAP_MONITOR_ALL)) { + dprintk(1, "%s: MONITOR_ALL not supported\n", __func__); return -EINVAL; + } if (mode_follower == CEC_MODE_MONITOR_PIN && - !(adap->capabilities & CEC_CAP_MONITOR_PIN)) + !(adap->capabilities & CEC_CAP_MONITOR_PIN)) { + dprintk(1, "%s: MONITOR_PIN not supported\n", __func__); return -EINVAL; + } /* Follower modes should always be able to send CEC messages */ if ((mode_initiator == CEC_MODE_NO_INITIATOR || !(adap->capabilities & CEC_CAP_TRANSMIT)) && mode_follower >= CEC_MODE_FOLLOWER && - mode_follower <= CEC_MODE_EXCL_FOLLOWER_PASSTHRU) + mode_follower <= CEC_MODE_EXCL_FOLLOWER_PASSTHRU) { + dprintk(1, "%s: cannot transmit\n", __func__); return -EINVAL; + } /* Monitor modes require CEC_MODE_NO_INITIATOR */ - if (mode_initiator && mode_follower >= CEC_MODE_MONITOR_PIN) + if (mode_initiator && mode_follower >= CEC_MODE_MONITOR_PIN) { + dprintk(1, "%s: monitor modes require NO_INITIATOR\n", + __func__); return -EINVAL; + } /* Monitor modes require CAP_NET_ADMIN */ if (mode_follower >= CEC_MODE_MONITOR_PIN && !capable(CAP_NET_ADMIN)) |