Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-24 Thread Mark Brown
On Tue, Jul 05, 2011 at 08:07:00PM +0530, ashishj3 wrote:

 +int da9052_set_bits(struct da9052 *da9052, unsigned char reg,
 +  unsigned char bit_mask)
 +{
 + unsigned char val;
 + int ret;
 +
 + if (reg  DA9052_MAX_REG_CNT) {
 + dev_err(da9052-dev, invalid reg %x\n, reg);
 + return -EINVAL;
 + }
 +
 + mutex_lock_interruptible(da9052-io_lock);

Linus has now merged the regmap code (include/linux/regmap.h and
drivers/base/regmap) which means that your register I/O code should 
probably be redone in terms of that - it shoud factor a lot of code out
of the driver.

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-23 Thread Arnd Bergmann
On Friday 22 July 2011, Mark Brown wrote:
 We went round this analysis already with the underlying I2C drivers
 (which also end up needing to take mutexes and so on) - it really does
 work out better to just make the I/O noninterruptible, the I/O is fast
 enough to not really be worth interrupting and the handling for actual
 I/O errors should normally be sufficiently different to that for user
 initiated aborts that it just adds complication.
 
 For example, if the user interrupts while we're in the middle of some
 lengthy series of operations or wait what we really want to do is to
 tear down the high level thing we're doing in an orderly fashion.  If
 we allow the interrupt to be noticed as part of an I/O operation then
 what we often end up doing is failing that and we then have to work out
 why the I/O failed, if actually happened on a physical level and how we
 deal with that.  Usually none of these paths will be well tested.
 
 The overall result is that the system generally becomes more complicated
 and less robust.

Yes, that makes sense. There are also cases where a mutex should really
be a spinlock (which is by definition not interruptible), or vice
versa. I don't know if this is one of them.

I agree that the safest solution here is to just make the mutex
uninterruptible.

Arnd

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-23 Thread Mark Brown
On Sat, Jul 23, 2011 at 11:50:30AM +0200, Arnd Bergmann wrote:

 Yes, that makes sense. There are also cases where a mutex should really
 be a spinlock (which is by definition not interruptible), or vice
 versa. I don't know if this is one of them.

We would be using spinlocks except the underlying buses sleep waiting
for the hardware to complete the transfer - the operations are quick
enough from a user perspective but at the very low level we want the CPU
to be able to go off and do other things while they're happening.

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-21 Thread Shawn Guo
On Tue, Jul 05, 2011 at 08:07:00PM +0530, ashishj3 wrote:
 The DA9052 is a highly integrated PMIC subsystem with supply domain 
 flexibility
 to support wide range of high performance application.
 
 It provides voltage regulators, GPIO controller, Touch Screen, RTC, Battery
 control and other functionality.
 
 Signed-off-by: David Dajun Chen dc...@diasemi.com
 Signed-off-by: Ashish Jangam ashish.jan...@kpitcummins.com
 ---
 Changes since v2:
 - Drop da9052_irqs[] table.
 - Move struct da9052_subdev_info[].
 - Remove initialization of static member.
 - Care for NULL pdata init().
 - Check removal of subdevices on errors.
 - Remove open source spi code.
 - Remove '_spi' from the driver name.
 - Move tbat_lookup table from header file.
 - Remove irq.h 
 - Remove num_gpio variable from pdata
 ---
  drivers/mfd/Kconfig   |   25 ++
  drivers/mfd/Makefile  |7 +
  drivers/mfd/da9052-core.c |  539 +
  drivers/mfd/da9052-i2c.c  |  168 
  drivers/mfd/da9052-irq.c  |  168 
  drivers/mfd/da9052-spi.c  |  132 +++
  include/linux/mfd/da9052/da9052.h |   91 +
  include/linux/mfd/da9052/pdata.h  |   43 ++
  include/linux/mfd/da9052/reg.h|  777 
 +
  9 files changed, 1950 insertions(+), 0 deletions(-)
  create mode 100755 drivers/mfd/da9052-core.c
  create mode 100755 drivers/mfd/da9052-i2c.c
  create mode 100755 drivers/mfd/da9052-irq.c
  create mode 100755 drivers/mfd/da9052-spi.c
  create mode 100755 include/linux/mfd/da9052/da9052.h
  create mode 100755 include/linux/mfd/da9052/pdata.h
  create mode 100755 include/linux/mfd/da9052/reg.h

[...]

 +int da9052_reg_update(struct da9052 *da9052, unsigned char reg,
 +unsigned char bit_mask, unsigned char reg_val)
 +{
 + int ret;
 + unsigned char val;
 +
 + if (reg  DA9052_MAX_REG_CNT) {
 + dev_err(da9052-dev, invalid reg %x\n, reg);
 + return -EINVAL;
 + }
 +
 + mutex_lock_interruptible(da9052-io_lock);

Compile warning as below.

warning: ignoring return value of ‘mutex_lock_interruptible’,
declared with attribute warn_unused_result

 +
 + if (da9052-read_dev == NULL || da9052-write_dev == NULL) {
 + ret = -ENODEV;
 + goto err;
 + }
 +
 + ret = da9052-read_dev(da9052, reg, 1, val);
 + if (ret  0)
 + goto err;
 +
 + val = ~bit_mask;
 + val |= reg_val;
 +
 + ret = da9052-write_dev(da9052, reg, 1, val);
 + if (ret  0)
 + goto err;
 +
 + mutex_unlock(da9052-io_lock);
 +
 + return 0;
 +
 +err:
 + mutex_unlock(da9052-io_lock);
 + return ret;
 +}
 +EXPORT_SYMBOL_GPL(da9052_reg_update);
 +
 +int da9052_set_bits(struct da9052 *da9052, unsigned char reg,
 +  unsigned char bit_mask)
 +{
 + unsigned char val;
 + int ret;
 +
 + if (reg  DA9052_MAX_REG_CNT) {
 + dev_err(da9052-dev, invalid reg %x\n, reg);
 + return -EINVAL;
 + }
 +
 + mutex_lock_interruptible(da9052-io_lock);

ditto

 +
 + if (da9052-read_dev == NULL || da9052-write_dev == NULL) {
 + ret = -ENODEV;
 + goto err;
 + }
 +
 + ret = da9052-read_dev(da9052, reg, 1, val);
 + if (ret  0)
 + goto err;
 +
 + val |= bit_mask;
 +
 + ret = da9052-write_dev(da9052, reg, 1, val);
 + if (ret  0)
 + goto err;
 +
 + mutex_unlock(da9052-io_lock);
 +
 + return 0;
 +
 +err:
 + mutex_unlock(da9052-io_lock);
 + return ret;
 +}
 +EXPORT_SYMBOL_GPL(da9052_set_bits);
 +
 +int da9052_clear_bits(struct da9052 *da9052, unsigned char reg,
 +unsigned char bit_mask)
 +{
 + unsigned char val;
 + int ret;
 +
 + if (reg  DA9052_MAX_REG_CNT) {
 + dev_err(da9052-dev, invalid reg %x\n, reg);
 + return -EINVAL;
 + }
 +
 + mutex_lock_interruptible(da9052-io_lock);

ditto

 +
 + if (da9052-read_dev == NULL || da9052-write_dev == NULL) {
 + ret = -ENODEV;
 + goto err;
 + }
 +
 + ret = da9052-read_dev(da9052, reg, 1, val);
 + if (ret  0)
 + goto err;
 +
 + val = ~bit_mask;
 +
 + ret = da9052-write_dev(da9052, reg, 1, val);
 + if (ret  0)
 + goto err;
 +
 + mutex_unlock(da9052-io_lock);
 +
 + return 0;
 +
 +err:
 + mutex_unlock(da9052-io_lock);
 + return ret;
 +}
 +EXPORT_SYMBOL_GPL(da9052_clear_bits);

[...]

 +static int __devinit da9052_i2c_probe(struct i2c_client *client,
 +const struct i2c_device_id *id)
 +{
 + struct i2c_adapter *adapter;
 + struct da9052 *da9052_i2c;
 + int ret;
 +
 + da9052_i2c = kzalloc(sizeof(struct da9052), GFP_KERNEL);
 + if (!da9052_i2c)
 + return -ENOMEM;
 +
 + adapter = to_i2c_adapter(client-dev.parent);
 +
 + if (!i2c_check_functionality(adapter, 

Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-21 Thread Shawn Guo
On Tue, Jul 05, 2011 at 08:07:00PM +0530, ashishj3 wrote:
 The DA9052 is a highly integrated PMIC subsystem with supply domain 
 flexibility
 to support wide range of high performance application.
 
 It provides voltage regulators, GPIO controller, Touch Screen, RTC, Battery
 control and other functionality.
 
 Signed-off-by: David Dajun Chen dc...@diasemi.com
 Signed-off-by: Ashish Jangam ashish.jan...@kpitcummins.com
 ---
[...]
 diff --git a/include/linux/mfd/da9052/pdata.h 
 b/include/linux/mfd/da9052/pdata.h
 new file mode 100755
 index 000..75d82a3
 --- /dev/null
 +++ b/include/linux/mfd/da9052/pdata.h
 @@ -0,0 +1,43 @@
 +/*
 + * Platform data declarations for DA9052 PMICs.
 + *
 + * Copyright(c) 2011 Dialog Semiconductor Ltd.
 + *
 + * Author: David Dajun Chen dc...@diasemi.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + *
 + */
 +
 +#ifndef __MFD_DA9052_PDATA_H__
 +#define __MFD_DA9052_PDATA_H__
 +
 +#define DA9052_MAX_REGULATORS15
 +
 +struct da9052;
 +
 +struct da9052_pdata {
 + struct led_platform_data *pled;
 + struct da9052_wdt_platform_data *pwdt;
 + struct da9052_tsi_platform_data *ptsi;
 + int (*init) (struct da9052 *da9052);

Do you have any actually example to demonstrate the necessity of
this hook?  Otherwise, I would suggest we drop it, since machine
code can always do whatever setup needed there.

I'm asking because this kind of hooks always get in the way of the
device tree conversion.

Regards,
Shawn

 + int irq;
 + int irq_base;
 + int num_regulators;
 + int gpio_base;
 + struct regulator_init_data *regulators[DA9052_MAX_REGULATORS];
 +};


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-21 Thread Mark Brown
On Thu, Jul 21, 2011 at 11:46:32PM +0800, Shawn Guo wrote:
 On Tue, Jul 05, 2011 at 08:07:00PM +0530, ashishj3 wrote:

  +   mutex_lock_interruptible(da9052-io_lock);

 Compile warning as below.

 warning: ignoring return value of ‘mutex_lock_interruptible’,
 declared with attribute warn_unused_result

Although the bigger problem is why are these interruptible?  That's
very unusual.

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


RE: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-11 Thread Ashish Jangam
 -Original Message-
 From: Arnd Bergmann [mailto:a...@arndb.de]
 Sent: Tuesday, July 05, 2011 8:25 PM
 To: Ashish Jangam
 Cc: Mark Brown; sa...@openedhand.com; linux-ker...@vger.kernel.org; Dajun;
 linaro-dev@lists.linaro.org
 Subject: Re: [PATCH 01/11] MFD: DA9052 MFD core module v2
 
 On Tuesday 05 July 2011, ashishj3 wrote:
  The DA9052 is a highly integrated PMIC subsystem with supply domain
 flexibility
  to support wide range of high performance application.
 
  It provides voltage regulators, GPIO controller, Touch Screen, RTC, Battery
  control and other functionality.
 
  Signed-off-by: David Dajun Chen dc...@diasemi.com
  Signed-off-by: Ashish Jangam ashish.jan...@kpitcummins.com
 
 Reviewed-by: Arnd Bergmann a...@arndb.de
Can anyone ack this patch?



___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-11 Thread Mark Brown
On Mon, Jul 11, 2011 at 12:27:46PM +0530, Ashish Jangam wrote:
  -Original Message-
  From: Arnd Bergmann [mailto:a...@arndb.de]
  Sent: Tuesday, July 05, 2011 8:25 PM

 Can anyone ack this patch?

You've only left it about a week for a response.  You cannot demand any
particular response from volunteers.  In the case of MFD Samuel normally
goes through things once a month or so.

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


Re: [PATCH 01/11] MFD: DA9052 MFD core module v2

2011-07-05 Thread Arnd Bergmann
On Tuesday 05 July 2011, ashishj3 wrote:
 The DA9052 is a highly integrated PMIC subsystem with supply domain 
 flexibility
 to support wide range of high performance application.
 
 It provides voltage regulators, GPIO controller, Touch Screen, RTC, Battery
 control and other functionality.
 
 Signed-off-by: David Dajun Chen dc...@diasemi.com
 Signed-off-by: Ashish Jangam ashish.jan...@kpitcummins.com

Reviewed-by: Arnd Bergmann a...@arndb.de

___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev