All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antti Palosaari <crope@iki.fi>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH RFC 3/3] dvb_frontend: do not allow statistic IOCTLs when sleeping
Date: Sun, 12 Aug 2012 19:28:45 +0300	[thread overview]
Message-ID: <5027D9BD.9020108@iki.fi> (raw)
In-Reply-To: <5027CB8A.1020204@redhat.com>

On 08/12/2012 06:28 PM, Mauro Carvalho Chehab wrote:
> Em 09-08-2012 19:25, Antti Palosaari escreveu:
>> Demodulator cannot perform statistic IOCTLs when it is not tuned.
>> Return -EPERM in such case.
>
> While, in general, doing it makes sense, -EPERM is a very bad return code.
> It is used to indicate when accessing some resources would require root access.

OK, makes sense. As I mentioned in coder letter I selected that due to 
V4L2 usage to keep consistent.
VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD
VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD

Cover letter also lists all the other error codes I found suitable. 
Which one you prefer?


>> Signed-off-by: Antti Palosaari <crope@iki.fi>
>> ---
>>   drivers/media/dvb/dvb-core/dvb_frontend.c | 34 +++++++++++++++++++++++--------
>>   1 file changed, 25 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
>> index 4fc11eb..40efcde 100644
>> --- a/drivers/media/dvb/dvb-core/dvb_frontend.c
>> +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
>> @@ -2157,27 +2157,43 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
>>   			err = fe->ops.read_status(fe, status);
>>   		break;
>>   	}
>> +
>>   	case FE_READ_BER:
>> -		if (fe->ops.read_ber)
>> -			err = fe->ops.read_ber(fe, (__u32*) parg);
>> +		if (fe->ops.read_ber) {
>> +			if (fepriv->thread)
>> +				err = fe->ops.read_ber(fe, (__u32 *) parg);
>> +			else
>> +				err = -EPERM;
>> +		}
>>   		break;
>>
>>   	case FE_READ_SIGNAL_STRENGTH:
>> -		if (fe->ops.read_signal_strength)
>> -			err = fe->ops.read_signal_strength(fe, (__u16*) parg);
>> +		if (fe->ops.read_signal_strength) {
>> +			if (fepriv->thread)
>> +				err = fe->ops.read_signal_strength(fe, (__u16 *) parg);
>> +			else
>> +				err = -EPERM;
>> +		}
>>   		break;
>
> Signal strength can still be available even without locking.

So it is correct. :)
It checks if frontend thread is running, not demodulator lock flags.

Actually, my original plan was to use demod lock flags but after looking 
various demod drivers I ended-up conclusion it is not wise. Many demod 
drivers just set all flags at the same time when there is full lock 
gained and never provide more accurate info - all or nothing.

Anyhow, that solution prevents I/O errors when demod is so deep sleep 
state (like reset) it cannot even answer at all.


>>   	case FE_READ_SNR:
>> -		if (fe->ops.read_snr)
>> -			err = fe->ops.read_snr(fe, (__u16*) parg);
>> +		if (fe->ops.read_snr) {
>> +			if (fepriv->thread)
>> +				err = fe->ops.read_snr(fe, (__u16 *) parg);
>> +			else
>> +				err = -EPERM;
>> +		}
>>   		break;
>>
>>   	case FE_READ_UNCORRECTED_BLOCKS:
>> -		if (fe->ops.read_ucblocks)
>> -			err = fe->ops.read_ucblocks(fe, (__u32*) parg);
>> +		if (fe->ops.read_ucblocks) {
>> +			if (fepriv->thread)
>> +				err = fe->ops.read_ucblocks(fe, (__u32 *) parg);
>> +			else
>> +				err = -EPERM;
>> +		}
>>   		break;
>>
>> -
>>   	case FE_DISEQC_RESET_OVERLOAD:
>>   		if (fe->ops.diseqc_reset_overload) {
>>   			err = fe->ops.diseqc_reset_overload(fe);
>>
>
> Regards,
> Mauro

regards
Antti


-- 
http://palosaari.fi/

      reply	other threads:[~2012-08-12 16:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 22:24 [PATCH RFC 0/3] dvb-frontend statistic IOCTL validation Antti Palosaari
2012-08-09 22:24 ` [PATCH RFC 1/3] dvb_frontend: use Kernel dev_* logging Antti Palosaari
2012-08-12 15:37   ` Mauro Carvalho Chehab
2012-08-09 22:25 ` [PATCH RFC 2/3] dvb_frontend: return -ENOTTY for unimplement IOCTL Antti Palosaari
2012-08-12 15:30   ` Mauro Carvalho Chehab
2012-08-09 22:25 ` [PATCH RFC 3/3] dvb_frontend: do not allow statistic IOCTLs when sleeping Antti Palosaari
2012-08-12 15:28   ` Mauro Carvalho Chehab
2012-08-12 16:28     ` Antti Palosaari [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5027D9BD.9020108@iki.fi \
    --to=crope@iki.fi \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.