Skip to content

Commit 745e3c7

Browse files
KAGA-KOKOkuba-moo
authored andcommitted
ptp: Split out PTP_MASK_EN_SINGLE ioctl code
Finish the ptp_ioctl() cleanup by splitting out the PTP_MASK_EN_SINGLE ioctl code and removing the remaining local variables and return statements. No functional change intended. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6a0f480 commit 745e3c7

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

drivers/ptp/ptp_chardev.c

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -441,22 +441,28 @@ static long ptp_mask_clear_all(struct timestamp_event_queue *tsevq)
441441
return 0;
442442
}
443443

444+
static long ptp_mask_en_single(struct timestamp_event_queue *tsevq, void __user *arg)
445+
{
446+
unsigned int channel;
447+
448+
if (copy_from_user(&channel, arg, sizeof(channel)))
449+
return -EFAULT;
450+
if (channel >= PTP_MAX_CHANNELS)
451+
return -EFAULT;
452+
set_bit(channel, tsevq->mask);
453+
return 0;
454+
}
455+
444456
long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
445457
unsigned long arg)
446458
{
447-
struct ptp_clock *ptp =
448-
container_of(pccontext->clk, struct ptp_clock, clock);
449-
struct timestamp_event_queue *tsevq;
459+
struct ptp_clock *ptp = container_of(pccontext->clk, struct ptp_clock, clock);
450460
void __user *argptr;
451-
unsigned int i;
452-
int err = 0;
453461

454462
if (in_compat_syscall() && cmd != PTP_ENABLE_PPS && cmd != PTP_ENABLE_PPS2)
455463
arg = (unsigned long)compat_ptr(arg);
456464
argptr = (void __force __user *)arg;
457465

458-
tsevq = pccontext->private_clkdata;
459-
460466
switch (cmd) {
461467
case PTP_CLOCK_GETCAPS:
462468
case PTP_CLOCK_GETCAPS2:
@@ -506,22 +512,11 @@ long ptp_ioctl(struct posix_clock_context *pccontext, unsigned int cmd,
506512
return ptp_mask_clear_all(pccontext->private_clkdata);
507513

508514
case PTP_MASK_EN_SINGLE:
509-
if (copy_from_user(&i, (void __user *)arg, sizeof(i))) {
510-
err = -EFAULT;
511-
break;
512-
}
513-
if (i >= PTP_MAX_CHANNELS) {
514-
err = -EFAULT;
515-
break;
516-
}
517-
set_bit(i, tsevq->mask);
518-
break;
515+
return ptp_mask_en_single(pccontext->private_clkdata, argptr);
519516

520517
default:
521-
err = -ENOTTY;
522-
break;
518+
return -ENOTTY;
523519
}
524-
return err;
525520
}
526521

527522
__poll_t ptp_poll(struct posix_clock_context *pccontext, struct file *fp,

0 commit comments

Comments
 (0)