[patch V2 00/13] ptp: Belated spring cleaning of the chardev driver

Thomas Gleixner posted 13 patches 3 months, 2 weeks ago
ptp_chardev.c |  734 ++++++++++++++++++++++++++--------------------------------
1 file changed, 341 insertions(+), 393 deletions(-)
[patch V2 00/13] ptp: Belated spring cleaning of the chardev driver
Posted by Thomas Gleixner 3 months, 2 weeks ago
This is V2 of the series. V1 can be found here:

     https://lore.kernel.org/all/20250620130144.351492917@linutronix.de

When looking into supporting auxiliary clocks in the PTP ioctl, the
inpenetrable ptp_ioctl() letter soup bothered me enough to clean it up.

The code (~400 lines!) is really hard to follow due to a gazillion of
local variables, which are only used in certain case scopes, and a
mixture of gotos, breaks and direct error return paths.

Clean it up by splitting out the IOCTL functionality into seperate
functions, which contain only the required local variables and are trivial
to follow. Complete the cleanup by converting the code to lock guards and
get rid of all gotos.

That reduces the code size by 48 lines and also the binary text size is
80 bytes smaller than the current maze.

The series is split up into one patch per IOCTL command group for easy
review.

Changes vs. V1:

  - Picked up Reviewed tags as appropriate

  - Dropped the pointless memset()s in GETFUNC/SETFUNC - Paolo

  - Dropped the __free() in ptp_open/read() - Jakub

Applies against v6.16-rc1 and also cleanly against next. It's also
available from git:

     git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git timers/ptp/driver

Thanks,

	tglx
---
 ptp_chardev.c |  734 ++++++++++++++++++++++++++--------------------------------
 1 file changed, 341 insertions(+), 393 deletions(-)
Re: [patch V2 00/13] ptp: Belated spring cleaning of the chardev driver
Posted by Richard Cochran 3 months, 2 weeks ago
On Wed, Jun 25, 2025 at 01:52:23PM +0200, Thomas Gleixner wrote:
> The code (~400 lines!) is really hard to follow due to a gazillion of
> local variables, which are only used in certain case scopes, and a
> mixture of gotos, breaks and direct error return paths.

But it is 100% organically grown and therefore healthy for you!

Thanks,
Richard
Re: [patch V2 00/13] ptp: Belated spring cleaning of the chardev driver
Posted by Thomas Gleixner 3 months, 2 weeks ago
On Wed, Jun 25 2025 at 07:40, Richard Cochran wrote:

> On Wed, Jun 25, 2025 at 01:52:23PM +0200, Thomas Gleixner wrote:
>> The code (~400 lines!) is really hard to follow due to a gazillion of
>> local variables, which are only used in certain case scopes, and a
>> mixture of gotos, breaks and direct error return paths.
>
> But it is 100% organically grown and therefore healthy for you!

You sure there were no forbidden plants involved?
Re: [patch V2 00/13] ptp: Belated spring cleaning of the chardev driver
Posted by Richard Cochran 3 months, 2 weeks ago
On Wed, Jun 25, 2025 at 06:05:44PM +0200, Thomas Gleixner wrote:
> You sure there were no forbidden plants involved?

Not in Calyfornia :^)

Cheers,
Richard