Re: [PATCH 11/65] media: Replace file->private_data access with custom functions
Lukasz Stelmach <[email protected]> Mon, 18 Aug 2025 16:10:40 +0200
| Newsgroups | gmane.linux.ports.tegra,gmane.linux.drivers.video-input-infrastructure,gmane.linux.kernel,gmane.linux.documentation,gmane.linux.ports.arm.kernel,gmane.linux.ports.arm.mediatek,gmane.linux.kernel.renesas-soc,gmane.linux.ports.arm.msm,gmane.linux.kernel.samsung-soc,gmane.linux.usb.general,gmane.linux.ports.arm.rockchip,gmane.comp.video.mjpeg.user |
|---|---|
| Message-ID | <oypijda53wra8v.fsf%[email protected]> |
--=-=-= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable It was <2025-08-02 sob 11:22>, when Jacopo Mondi wrote: > From: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]> > > Accessing file->private_data manually to retrieve the v4l2_fh pointer is > error-prone, as the field is a void * and will happily cast implicitly > to any pointer type. > > Replace all remaining locations that read the v4l2_fh pointer directly > from file->private_data and cast it to driver-specific file handle > structures with driver-specific functions that use file_to_v4l2_fh() and > perform the same cast. > > No functional change is intended, this only paves the way to remove > direct accesses to file->private_data and make V4L2 drivers safer. > Other accesses to the field will be addressed separately. > > Signed-off-by: Laurent Pinchart <laurent.pinchart-ryLnwIuWjnjg/[email protected]> > Signed-off-by: Jacopo Mondi <jacopo.mondi-ryLnwIuWjnjg/[email protected]> > --- [...] > diff --git a/drivers/media/platform/samsung/s5p-g2d/g2d.c b/drivers/media= /platform/samsung/s5p-g2d/g2d.c > index ffed16a34493be2edbdaee13619467417487c1e7..44fcedbbc90a9863827aacbcd= 5f56d850cb552ea 100644 > --- a/drivers/media/platform/samsung/s5p-g2d/g2d.c > +++ b/drivers/media/platform/samsung/s5p-g2d/g2d.c > @@ -25,7 +25,10 @@ > #include "g2d.h" > #include "g2d-regs.h" >=20=20 > -#define fh2ctx(__fh) container_of(__fh, struct g2d_ctx, fh) > +static inline struct g2d_ctx *file2ctx(struct file *filp) > +{ > + return container_of(file_to_v4l2_fh(filp), struct g2d_ctx, fh); > +} >=20=20 > static struct g2d_fmt formats[] =3D { > { > @@ -272,7 +275,7 @@ static int g2d_open(struct file *file) > static int g2d_release(struct file *file) > { > struct g2d_dev *dev =3D video_drvdata(file); > - struct g2d_ctx *ctx =3D fh2ctx(file->private_data); > + struct g2d_ctx *ctx =3D file2ctx(file); >=20=20 > mutex_lock(&dev->mutex); > v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); Acked-by: Lukasz Stelmach <[email protected]> [...] =2D-=20 =C5=81ukasz Stelmach Samsung R&D Institute Poland Samsung Electronics --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEXpuyqjq9kGEVr9UQsK4enJilgBAFAmijNGAACgkQsK4enJil gBDoIQgAm0zhFQfQO2pDJE9DC0t6P4lrJ//jtdrQJtVSYpcaXDYP9Oq1iygQ3s54 2wjf/n/+kXlE2cUM5pvbFc0c1qeuZipb+lexBpwBdogDE3njAsinDf4ohsWPGhJC TMOuWPadHmM0CXjuSWpeF+MoKtOJYJjdyVizq8ZoFwgGHssYApRxGVuXx6DRlsZK aqNXp4P9HNaVsxLl5JOCaeEaJLBkU++5rhIooxbmm/jPuM6WuOWil+jQKADaODeJ UfkLjfRCLFc4WdsXOBZuwqUiyU4imB8qJOlrjosCChiqKqr7up+cyr3YZ7PJEXPv jN4MErP/mPjxbYUi+bON3CbY2FlWfw== =alRq -----END PGP SIGNATURE----- --=-=-=--