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: <6ED8E3B22081A4459DAC7699F3695FB7018CCE7CB6@SW-EX-MBX02.diasemi.com>
Date:   Mon, 7 Nov 2016 15:25:00 +0000
From:   Steve Twiss <stwiss.opensource@...semi.com>
To:     Lee Jones <lee.jones@...aro.org>
CC:     LINUX-KERNEL <linux-kernel@...r.kernel.org>,
        DEVICETREE <devicetree@...r.kernel.org>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Eduardo Valentin <edubezval@...il.com>,
        Guenter Roeck <linux@...ck-us.net>,
        LINUX-INPUT <linux-input@...r.kernel.org>,
        LINUX-PM <linux-pm@...r.kernel.org>,
        LINUX-WATCHDOG <linux-watchdog@...r.kernel.org>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        "Mark Rutland" <mark.rutland@....com>,
        Rob Herring <robh+dt@...nel.org>,
        "Support Opensource" <Support.Opensource@...semi.com>,
        Wim Van Sebroeck <wim@...ana.be>,
        Zhang Rui <rui.zhang@...el.com>
Subject: RE: [PATCH V3 5/9] mfd: da9061: MFD core support

On 02 November 2016 14:29, Lee Jones wrote:

> On Mon, 31 Oct 2016, Steve Twiss wrote:
> > From: Steve Twiss <stwiss.opensource@...semi.com>
> > 
> > @@ -475,7 +855,25 @@ static int da9062_i2c_probe(struct i2c_client *i2c,
> >  		return -EINVAL;
> >  	}
> >
> > -	chip->regmap = devm_regmap_init_i2c(i2c, &da9062_regmap_config);
> > +	switch (chip->chip_type) {
> > +	case(COMPAT_TYPE_DA9061):
> > +		cell = da9061_devs;
> > +		cell_num = ARRAY_SIZE(da9061_devs);
> > +		irq_chip = &da9061_irq_chip;
> > +		config = &da9061_regmap_config;
> > +		break;
> > +	case(COMPAT_TYPE_DA9062):
> > +		cell = da9062_devs;
> > +		cell_num = ARRAY_SIZE(da9062_devs);
> > +		irq_chip = &da9062_irq_chip;
> > +		config = &da9062_regmap_config;
> > +		break;
> > +	default:
> > +		dev_err(chip->dev, "Unrecognised chip type\n");
> > +		return -ENODEV;
> > +	}
> 
> I very much dislike when MFD and OF functionality is mixed.
> 
> In your case you can use da9062_get_device_type() to dynamically
> interrogate the device and register using the correct MFD cells that
> way.

Hi Lee,

It's the device tree that decides what the chip type is. It's not chip
interrogation in this case. The ordering dictates this I think: to access the
hardware ID register, a regmap definition is needed first. But because the
correct I2C register map requires a knowledge of what chip is being used,
it becomes a circular dependency.

To solve this dependency, I define the chip type (DA9061 or DA9062) in the
device tree and assign the correct regmap first before accessing any registers.

> > +	chip->regmap = devm_regmap_init_i2c(i2c, config);
> >  	if (IS_ERR(chip->regmap)) {
> >  		ret = PTR_ERR(chip->regmap);
> >  		dev_err(chip->dev, "Failed to allocate register map: %d\n",
> > @@ -493,7 +891,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c,
> >
> >  	ret = regmap_add_irq_chip(chip->regmap, i2c->irq,
> >  			IRQF_TRIGGER_LOW | IRQF_ONESHOT |IRQF_SHARED,
> > -			-1, &da9062_irq_chip,
> > +			-1, irq_chip,
> 
> What is -1?

.. it's a request for an irq_base.
http://lxr.free-electrons.com/source/kernel/irq/irqdesc.c#L477

Is there a reason I shouldn't be doing that?
There doesn't seem to be a #define anywhere, and using -1 seems
to be the standard in the kernel at the moment.

Regards,
Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ