All of lore.kernel.org
 help / color / mirror / Atom feed
From: Onkalo Samu <samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
To: ext Sundar <sunder.svit-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org"
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH 1/3] drivers: misc: ak8974 / ami305 magnetometer driver
Date: Mon, 30 Aug 2010 10:12:41 +0300	[thread overview]
Message-ID: <1283152361.16404.22.camel@4fid08082> (raw)
In-Reply-To: <AANLkTim=Zq7Pxixdwe_H-659cLZ2yybediDURGwvoO3=@mail.gmail.com>

Hi Sundar,

On Sat, 2010-08-28 at 18:10 +0200, ext Sundar wrote:
> Hi Samu,
> 
> few minor comments,
> 
> On Fri, Aug 27, 2010 at 5:24 PM, Samu Onkalo <samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org> wrote:
> > +
> > +struct ak8974_chip {
> > +       struct miscdevice       miscdev;
> > +       struct mutex            lock;   /* Serialize access to chip */
> > +       struct mutex            users_lock;
> > +       struct i2c_client       *client;
> > +       struct regulator_bulk_data regs[2];
> > +       struct work_struct      work;
> > +       wait_queue_head_t       misc_wait;
> > +       loff_t                  offset;
> > +
> > +       int                     max_range;
> > +       int                     users;
> > +
> > +       const char              *id;
> > +       u8                      info[2];
> > +
> > +       s16                     x, y, z; /* Latest measurements */
> > +       s8                      axis_x;
> > +       s8                      axis_y;
> > +       s8                      axis_z;
> > +       bool                    valid;
> > +
> > +       char                    name[20];
> > +};
> 
> This can be static ?

It is filled based on the detected chip type.

> 
> > +
> > +       ak8974_regulators_off(chip);
> > +
> 
> [..]
> 
> > +       if (err < 0) {
> > +               dev_err(&chip->client->dev, "Device registration failed\n");
> > +               goto fail3;
> > +       }
> 
> [..]
> 
> > +       return 0;
> > +fail4:
> > +       misc_deregister(&chip->miscdev);
> > +fail3:
> > +       ak8974_regulators_off(chip);
> 
> in case of fail3, regulators get disabled twice. i think we will have
> unbalanced calls to the supplies then.
> 

Yes, you are correct.


> > +
> > +
> > +#ifdef CONFIG_PM
> > +static int ak8974_suspend(struct i2c_client *client, pm_message_t mesg)
> > +{
> > +       struct ak8974_chip *chip = i2c_get_clientdata(client);
> > +       mutex_lock(&chip->users_lock);
> > +       if (chip->users > 0)
> > +               ak8974_enable(chip, AK8974_PWR_OFF);
> > +       mutex_unlock(&chip->users_lock);
> > +       return 0;
> > +}
> 
> Can we disable the regulators here too?

It would require some more operations since the chip would loose its
state totally. But yes, it could be done.

-Samu

WARNING: multiple messages have this Message-ID (diff)
From: Onkalo Samu <samu.p.onkalo@nokia.com>
To: ext Sundar <sunder.svit@gmail.com>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: Re: [PATCH 1/3] drivers: misc: ak8974 / ami305 magnetometer driver
Date: Mon, 30 Aug 2010 10:12:41 +0300	[thread overview]
Message-ID: <1283152361.16404.22.camel@4fid08082> (raw)
In-Reply-To: <AANLkTim=Zq7Pxixdwe_H-659cLZ2yybediDURGwvoO3=@mail.gmail.com>

Hi Sundar,

On Sat, 2010-08-28 at 18:10 +0200, ext Sundar wrote:
> Hi Samu,
> 
> few minor comments,
> 
> On Fri, Aug 27, 2010 at 5:24 PM, Samu Onkalo <samu.p.onkalo@nokia.com> wrote:
> > +
> > +struct ak8974_chip {
> > +       struct miscdevice       miscdev;
> > +       struct mutex            lock;   /* Serialize access to chip */
> > +       struct mutex            users_lock;
> > +       struct i2c_client       *client;
> > +       struct regulator_bulk_data regs[2];
> > +       struct work_struct      work;
> > +       wait_queue_head_t       misc_wait;
> > +       loff_t                  offset;
> > +
> > +       int                     max_range;
> > +       int                     users;
> > +
> > +       const char              *id;
> > +       u8                      info[2];
> > +
> > +       s16                     x, y, z; /* Latest measurements */
> > +       s8                      axis_x;
> > +       s8                      axis_y;
> > +       s8                      axis_z;
> > +       bool                    valid;
> > +
> > +       char                    name[20];
> > +};
> 
> This can be static ?

It is filled based on the detected chip type.

> 
> > +
> > +       ak8974_regulators_off(chip);
> > +
> 
> [..]
> 
> > +       if (err < 0) {
> > +               dev_err(&chip->client->dev, "Device registration failed\n");
> > +               goto fail3;
> > +       }
> 
> [..]
> 
> > +       return 0;
> > +fail4:
> > +       misc_deregister(&chip->miscdev);
> > +fail3:
> > +       ak8974_regulators_off(chip);
> 
> in case of fail3, regulators get disabled twice. i think we will have
> unbalanced calls to the supplies then.
> 

Yes, you are correct.


> > +
> > +
> > +#ifdef CONFIG_PM
> > +static int ak8974_suspend(struct i2c_client *client, pm_message_t mesg)
> > +{
> > +       struct ak8974_chip *chip = i2c_get_clientdata(client);
> > +       mutex_lock(&chip->users_lock);
> > +       if (chip->users > 0)
> > +               ak8974_enable(chip, AK8974_PWR_OFF);
> > +       mutex_unlock(&chip->users_lock);
> > +       return 0;
> > +}
> 
> Can we disable the regulators here too?

It would require some more operations since the chip would loose its
state totally. But yes, it could be done.

-Samu



  reply	other threads:[~2010-08-30  7:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-27 11:54 [PATCH 0/3] ak8974 / ami305 magnetometer driver Samu Onkalo
2010-08-27 11:54 ` Samu Onkalo
     [not found] ` <1282910083-8629-1-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-08-27 11:54   ` [PATCH 1/3] drivers: misc: " Samu Onkalo
2010-08-27 11:54     ` Samu Onkalo
     [not found]     ` <1282910083-8629-2-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-08-27 12:31       ` Alan Cox
2010-08-27 12:31         ` Alan Cox
     [not found]         ` <20100827133109.1eb974ed-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-08-27 16:59           ` Onkalo Samu
2010-08-27 16:59             ` Onkalo Samu
     [not found]             ` <1282928353.2194.27.camel-Vo7XL3ix0D0UEupzmRo7jhl4MBrZKKet0E9HWUfgJXw@public.gmane.org>
2010-08-27 18:08               ` Dmitry Torokhov
2010-08-27 18:08                 ` Dmitry Torokhov
2010-08-28 13:44                 ` Jonathan Cameron
2010-08-27 18:53             ` Mark Brown
     [not found]               ` <20100827185343.GA6626-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2010-08-30  6:55                 ` Onkalo Samu
2010-08-30  6:55                   ` Onkalo Samu
2010-08-31 11:11                   ` Mark Brown
2010-08-28 16:10       ` Sundar
2010-08-28 16:10         ` Sundar
2010-08-30  7:12         ` Onkalo Samu [this message]
2010-08-30  7:12           ` Onkalo Samu
2010-08-31  7:13           ` Sundar
2010-08-27 11:54 ` [PATCH 2/3] drivers: misc: ak8974 support to Kconfig and Makefile Samu Onkalo
2010-08-27 11:54 ` [PATCH 3/3] Documentation: Documentation for ak8974 magnetometer chip driver Samu Onkalo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1283152361.16404.22.camel@4fid08082 \
    --to=samu.p.onkalo-xnzwkgviw5gavxtiumwx3w@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sunder.svit-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.