Re: [patch 08/13] ptp: Split out PTP_PIN_GETFUNC ioctl code
From: Thomas Gleixner
Date: Tue Jun 24 2025 - 09:39:50 EST
On Tue, Jun 24 2025 at 11:22, Paolo Abeni wrote:
> On 6/20/25 3:24 PM, Thomas Gleixner wrote:
>> Continue the ptp_ioctl() cleanup by splitting out the PTP_PIN_GETFUNC ioctl
>> code into a helper function. Convert to lock guard while at it.
>>
>> No functional change intended.
>>
>> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>> ---
>> drivers/ptp/ptp_chardev.c | 52 ++++++++++++++++++++--------------------------
>> 1 file changed, 23 insertions(+), 29 deletions(-)
>>
>> --- a/drivers/ptp/ptp_chardev.c
>> +++ b/drivers/ptp/ptp_chardev.c
>> @@ -396,6 +396,28 @@ static long ptp_sys_offset(struct ptp_cl
>> return copy_to_user(arg, sysoff, sizeof(*sysoff)) ? -EFAULT : 0;
>> }
>>
>> +static long ptp_pin_getfunc(struct ptp_clock *ptp, unsigned int cmd, void __user *arg)
>> +{
>> + struct ptp_clock_info *ops = ptp->info;
>> + struct ptp_pin_desc pd;
>> +
>> + if (copy_from_user(&pd, arg, sizeof(pd)))
>> + return -EFAULT;
>> +
>> + if (cmd == PTP_PIN_GETFUNC2 && !mem_is_zero(pd.rsv, sizeof(pd.rsv)))
>> + return -EINVAL;
>> + else
>> + memset(pd.rsv, 0, sizeof(pd.rsv));
>
> Minor nit: I personally find the 'else' statement after return
> counter-intuitive and dropping it would save an additional LoC.
Of course ...