lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YjRIxGb0MAJ0f6WT@aptenodytes>
Date:   Fri, 18 Mar 2022 09:54:28 +0100
From:   Paul Kocialkowski <paul.kocialkowski@...tlin.com>
To:     Jernej Škrabec <jernej.skrabec@...il.com>
Cc:     linux-kernel@...r.kernel.org, linux-media@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
        Yong Deng <yong.deng@...ewell.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Chen-Yu Tsai <wens@...e.org>,
        Samuel Holland <samuel@...lland.org>,
        Laurent Pinchart <laurent.pinchart@...asonboard.com>,
        Maxime Ripard <mripard@...nel.org>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>
Subject: Re: [PATCH v3 06/46] media: sun6i-csi: Define and use variant to get
 module clock rate

Hi Jernej,

On Tue 15 Mar 22, 20:31, Jernej Škrabec wrote:
> Dne petek, 11. marec 2022 ob 15:34:52 CET je Paul Kocialkowski napisal(a):
> > Introduce a proper variant structure with the module clock rate
> > instead of hardcoding it with a manual check on the compatible.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
> > ---
> >  .../platform/sunxi/sun6i-csi/sun6i_csi.c      | 48 ++++++++++++++-----
> >  .../platform/sunxi/sun6i-csi/sun6i_csi.h      |  4 ++
> >  2 files changed, 40 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/
> media/platform/sunxi/sun6i-csi/sun6i_csi.c
> > index 2355088fdc37..4a0d08e0ac25 100644
> > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> > @@ -811,11 +811,17 @@ static int sun6i_csi_resources_setup(struct 
> sun6i_csi_device *csi_dev,
> >  				     struct platform_device 
> *platform_dev)
> >  {
> >  	struct device *dev = csi_dev->dev;
> > -	unsigned long clk_mod_rate;
> > +	const struct sun6i_csi_variant *variant;
> 
> Ideally, this should be sorted from longest to shortest.

I typically try to have definitions with affectations first and then
just definitions, sorted longest to shortest unless there is some dependency
between definitions.

> >  	void __iomem *io_base;
> >  	int ret;
> >  	int irq;
> >  
> > +	/* Variant */
> 
> I don't think this comment is very useful (nor one below for that matter.) 
> Please remove it.

It's not really a comment per-se, but rather a section header.
I have similar ones for Clocks / Reset / Interrupt / Runtime PM so
that's why it felt consistent to add one for Variant too.

The point is to keep related topics grouped together and I'd rather keep it.

Cheers,

Paul

> With that:
> Reviewed-by: Jernej Skrabec <jernej.skrabec@...il.com>
> 
> Best regards,
> Jernej
> 
> > +
> > +	variant = of_device_get_match_data(dev);
> > +	if (!variant)
> > +		return -EINVAL;
> > +
> >  	/* Registers */
> >  
> >  	io_base = devm_platform_ioremap_resource(platform_dev, 0);
> > @@ -849,12 +855,7 @@ static int sun6i_csi_resources_setup(struct 
> sun6i_csi_device *csi_dev,
> >  		return PTR_ERR(csi_dev->clk_ram);
> >  	}
> >  
> > -	if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-
> csi"))
> > -		clk_mod_rate = 300000000;
> > -	else
> > -		clk_mod_rate = 297000000;
> > -
> > -	ret = clk_set_rate_exclusive(csi_dev->clk_mod, clk_mod_rate);
> > +	ret = clk_set_rate_exclusive(csi_dev->clk_mod, variant-
> >clk_mod_rate);
> >  	if (ret) {
> >  		dev_err(dev, "failed to set mod clock rate\n");
> >  		return ret;
> > @@ -937,12 +938,35 @@ static int sun6i_csi_remove(struct platform_device 
> *pdev)
> >  	return 0;
> >  }
> >  
> > +static const struct sun6i_csi_variant sun6i_a31_csi_variant = {
> > +	.clk_mod_rate	= 297000000,
> > +};
> > +
> > +static const struct sun6i_csi_variant sun50i_a64_csi_variant = {
> > +	.clk_mod_rate	= 300000000,
> > +};
> > +
> >  static const struct of_device_id sun6i_csi_of_match[] = {
> > -	{ .compatible = "allwinner,sun6i-a31-csi", },
> > -	{ .compatible = "allwinner,sun8i-a83t-csi", },
> > -	{ .compatible = "allwinner,sun8i-h3-csi", },
> > -	{ .compatible = "allwinner,sun8i-v3s-csi", },
> > -	{ .compatible = "allwinner,sun50i-a64-csi", },
> > +	{
> > +		.compatible	= "allwinner,sun6i-a31-csi",
> > +		.data		= &sun6i_a31_csi_variant,
> > +	},
> > +	{
> > +		.compatible	= "allwinner,sun8i-a83t-csi",
> > +		.data		= &sun6i_a31_csi_variant,
> > +	},
> > +	{
> > +		.compatible	= "allwinner,sun8i-h3-csi",
> > +		.data		= &sun6i_a31_csi_variant,
> > +	},
> > +	{
> > +		.compatible	= "allwinner,sun8i-v3s-csi",
> > +		.data		= &sun6i_a31_csi_variant,
> > +	},
> > +	{
> > +		.compatible	= "allwinner,sun50i-a64-csi",
> > +		.data		= &sun50i_a64_csi_variant,
> > +	},
> >  	{},
> >  };
> >  
> > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/
> media/platform/sunxi/sun6i-csi/sun6i_csi.h
> > index 356661b413f8..3c4a3af6b897 100644
> > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
> > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
> > @@ -59,6 +59,10 @@ struct sun6i_csi_device {
> >  	int				planar_offset[3];
> >  };
> >  
> > +struct sun6i_csi_variant {
> > +	unsigned long	clk_mod_rate;
> > +};
> > +
> >  /**
> >   * sun6i_csi_is_format_supported() - check if the format supported by csi
> >   * @csi:	pointer to the csi
> > -- 
> > 2.35.1
> > 
> > 
> 
> 

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ