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]
Date:	Mon, 30 Mar 2015 16:05:19 +0800
From:	Eddie Huang <eddie.huang@...iatek.com>
To:	Sascha Hauer <s.hauer@...gutronix.de>
CC:	Mark Rutland <mark.rutland@....com>,
	Wolfram Sang <wsa@...-dreams.de>,
	Doug Anderson <dianders@...omium.org>,
	<linux-i2c@...r.kernel.org>,
	David Box <david.e.box@...ux.intel.com>,
	Lee Jones <lee.jones@...aro.org>,
	Jean Delvare <jdelvare@...e.de>,
	Xudong Chen <xudong.chen@...iatek.com>,
	Boris BREZILLON <boris.brezillon@...e-electrons.com>,
	Pawel Moll <pawel.moll@....com>,
	Liguo Zhang <liguo.zhang@...iatek.com>,
	Wei Yan <sledge.yanwei@...wei.com>,
	Bjorn Andersson <bjorn.andersson@...ymobile.com>,
	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>,
	Neelesh Gupta <neelegup@...ux.vnet.ibm.com>,
	<devicetree@...r.kernel.org>, Arnd Bergmann <arnd@...db.de>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Beniamino Galvani <b.galvani@...il.com>,
	Rob Herring <robh+dt@...nel.org>,
	<linux-mediatek@...ts.infradead.org>,
	Matthias Brugger <matthias.bgg@...il.com>,
	<linux-arm-kernel@...ts.infradead.org>,
	<srv_heupstream@...iatek.com>,
	Anders Berg <anders.berg@...gotech.com>,
	Jim Cromie <jim.cromie@...il.com>,
	Simon Glass <sjg@...omium.org>,
	Max Schwarz <max.schwarz@...ine.de>,
	<linux-kernel@...r.kernel.org>,
	Sascha Hauer <kernel@...gutronix.de>,
	Kumar Gala <galak@...eaurora.org>
Subject: Re: [PATCH v5 3/3] I2C: mediatek: Add driver for MediaTek MT8173
 I2C controller

Hi Sascha,

On Mon, 2015-03-23 at 08:39 +0100, Sascha Hauer wrote:
> On Sat, Mar 21, 2015 at 02:05:22PM +0800, Eddie Huang wrote:
> > Add mediatek MT8173 I2C controller driver. Compare to I2C controller
> > of earlier mediatek SoC, MT8173 fix write-then-read limitation, and
> > also increase message size to 64kb.
> > 
> 
> [...]
> 
> > +static const struct i2c_adapter_quirks mt8173_i2c_quirks = {
> > +	.max_num_msgs = MAX_MSG_NUM_MT8173,
> > +	.max_write_len = MAX_DMA_TRANS_SIZE_MT8173,
> > +	.max_read_len = MAX_DMA_TRANS_SIZE_MT8173,
> > +	.max_comb_1st_msg_len = MAX_DMA_TRANS_SIZE_MT8173,
> > +	.max_comb_2nd_msg_len = MAX_WRRD_TRANS_SIZE_MT8173,
> > +};
> > +
> >  static int mtk_i2c_probe(struct platform_device *pdev)
> >  {
> >  	int ret = 0;
> > @@ -587,7 +626,8 @@ static int mtk_i2c_probe(struct platform_device *pdev)
> >  		return -EINVAL;
> >  
> >  	i2c->platform_compat = mtk_get_device_prop(pdev);
> > -	if (i2c->have_pmic && (i2c->platform_compat & COMPAT_MT6577))
> > +	if (i2c->have_pmic && (i2c->platform_compat &
> > +			(COMPAT_MT6577 | COMPAT_MT8173)))
> >  		return -EINVAL;
> >  
> >  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > @@ -613,7 +653,10 @@ static int mtk_i2c_probe(struct platform_device *pdev)
> >  	i2c->adap.dev.parent = &pdev->dev;
> >  	i2c->adap.owner = THIS_MODULE;
> >  	i2c->adap.algo = &mtk_i2c_algorithm;
> > -	i2c->adap.quirks = &mt6577_i2c_quirks;
> > +	if (i2c->platform_compat & COMPAT_MT8173)
> > +		i2c->adap.quirks = &mt8173_i2c_quirks;
> > +	else
> > +		i2c->adap.quirks = &mt6577_i2c_quirks;
> 
> Instead of putting an integer into struct of_device_id you should
> introduce a
> 
> struct mtk_i2c_data {
> 	struct i2c_adapter_quirks quirks;
> 	int compat;
> 	/* Additional SoC specific data */
> };
> 
> and put a pointer to this directly into the of_device_id. This way you
> need less casting and can put newly discovered differences diretly into
> some data struct and don't have to introduce if(socxy) ... else ...
> everytime.
> 

Thanks your suggestion. I will use capability struct like 

struct mtk_i2c_compatible {
	unsigned char pmic_i2c;
	unsigned char dcm;
	unsigned char auto_restart;
	const struct i2c_adapter_quirks *quirks;
};

And pass in of_device_id, then remove all if(socxy).... else ... in
driver.

Eddie





--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ