[PATCH v2 6/6] serial: 8250: make port operations work on struct uart_8250_port

Andy Shevchenko andriy.shevchenko at linux.intel.com
Tue Oct 13 02:09:18 PDT 2026


On Tue, Oct 13, 2026 at 09:53:26AM +0200, Jiri Slaby wrote:
> On 13. 10. 26, 9:33, Andy Shevchenko wrote:
> > On Tue, Oct 13, 2026 at 08:48:51AM +0200, Jiri Slaby (SUSE) wrote:

...

> > > -	rc = serial8250_register_8250_port(&port);
> > > -	if (rc < 0)
> > > +	struct uart_8250_port *uport = serial8250_register_8250_port(&port);
> > > +	if (IS_ERR(uport)) {
> > > +		rc = PTR_ERR(uport);
> > >   		goto err_sysfs_remove;
> > > +	}
> 
> > Also do not define
> > variables in the middle of the code (it's only allowed for auto cleanup
> > variables and for-loop iterators).
> 
> Why, actually?

Because it's the style. Linus also told it many times (I am tired to repeat
this, I leave it to you to find his words on lore.kernel.org).

> First, it is used in the kernel quite a few times already
> [1]. Second, while it is sort of c++ism (and I like to use modern c++), it
> makes the life of the variable a lot more obvious.
> 
> [1] eg. see output of: rg -U -C 5 '}\n+\s+struct .*\*.*=' drivers/

(you made me to install something I haven't heard about, it's better to use
 `git grep` though)

Note excluded __free() if I get regexp correctly

$ rg -U -l '}\n+\s+struct .*\*[^)]*=' drivers/ | less
drivers/ufs/host/ufs-qcom.c
drivers/dma/xilinx/xilinx_dma.c
drivers/dma/idxd/init.c
drivers/media/platform/raspberrypi/rp1-cfe/csi2.c
drivers/gpib/agilent_82357a/agilent_82357a.c
drivers/gpib/ni_usb/ni_usb_gpib.c
drivers/tty/serial/samsung_tty.c
drivers/s390/scsi/zfcp_scsi.c
drivers/gpio/gpiolib-shared.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
drivers/gpu/drm/msm/msm_gem_vma.c
drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

So, less than dozen of drivers doing wrong is not an argument, try something
better. But thanks, I will check and address this in some of the above.

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list