All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ]hmc5843: Convert to dev pm ops
@ 2011-01-18  6:59 shubhrajyoti
  2011-01-18  6:59 ` [PATCH ] hmc5843: Trivial optimisation shubhrajyoti
  2011-01-18 11:09 ` [PATCH ]hmc5843: Convert to dev pm ops Jonathan Cameron
  0 siblings, 2 replies; 6+ messages in thread
From: shubhrajyoti @ 2011-01-18  6:59 UTC (permalink / raw)
  To: linux-iio; +Cc: Shubhrajyoti Datta

From: Shubhrajyoti Datta <shubhrajyoti@ti.com>


Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com>
---
 drivers/staging/iio/magnetometer/hmc5843.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index 5168917..b1c26d8 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -583,20 +583,25 @@ static int hmc5843_remove(struct i2c_client *client)
 	kfree(i2c_get_clientdata(client));
 	return 0;
 }
-
-static int hmc5843_suspend(struct i2c_client *client, pm_message_t mesg)
+#ifdef CONFIG_PM
+static int hmc5843_suspend(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
 	hmc5843_configure(client, MODE_SLEEP);
 	return 0;
 }
 
-static int hmc5843_resume(struct i2c_client *client)
+static int hmc5843_resume(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
 	struct hmc5843_data *data = i2c_get_clientdata(client);
 	hmc5843_configure(client, data->operating_mode);
 	return 0;
 }
-
+static SIMPLE_DEV_PM_OPS(hmc5843_pm, hmc5843_suspend, hmc5843_resume);
+#else
+#define hmc5843_pm NULL
+#endif
 static const struct i2c_device_id hmc5843_id[] = {
 	{ "hmc5843", 0 },
 	{ }
@@ -605,14 +610,15 @@ static const struct i2c_device_id hmc5843_id[] = {
 static struct i2c_driver hmc5843_driver = {
 	.driver = {
 		.name	= "hmc5843",
+#ifdef CONFIG_PM
+		.pm	= &hmc5843_pm,
+#endif
 	},
 	.id_table	= hmc5843_id,
 	.probe		= hmc5843_probe,
 	.remove		= hmc5843_remove,
 	.detect		= hmc5843_detect,
 	.address_list	= normal_i2c,
-	.suspend	= hmc5843_suspend,
-	.resume		= hmc5843_resume,
 };
 
 static int __init hmc5843_init(void)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH ] hmc5843: Trivial optimisation
  2011-01-18  6:59 [PATCH ]hmc5843: Convert to dev pm ops shubhrajyoti
@ 2011-01-18  6:59 ` shubhrajyoti
  2011-01-18 11:14   ` Jonathan Cameron
  2011-01-18 11:09 ` [PATCH ]hmc5843: Convert to dev pm ops Jonathan Cameron
  1 sibling, 1 reply; 6+ messages in thread
From: shubhrajyoti @ 2011-01-18  6:59 UTC (permalink / raw)
  To: linux-iio; +Cc: Shubhrajyoti Datta

From: Shubhrajyoti Datta <shubhrajyoti@ti.com>

Free the memory that is used only at init


Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com>
---
 drivers/staging/iio/magnetometer/hmc5843.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index b1c26d8..9df66cd 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -529,7 +529,7 @@ static void hmc5843_init_client(struct i2c_client *client)
 	pr_info("HMC5843 initialized\n");
 }
 
-static int hmc5843_probe(struct i2c_client *client,
+static int __devinit hmc5843_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
 	struct hmc5843_data *data;
@@ -574,7 +574,7 @@ exit:
 	return err;
 }
 
-static int hmc5843_remove(struct i2c_client *client)
+static int __devexit hmc5843_remove(struct i2c_client *client)
 {
 	struct hmc5843_data *data = i2c_get_clientdata(client);
 	 /*  sleep mode to save power */
@@ -616,7 +616,7 @@ static struct i2c_driver hmc5843_driver = {
 	},
 	.id_table	= hmc5843_id,
 	.probe		= hmc5843_probe,
-	.remove		= hmc5843_remove,
+	.remove		=  __devexit_p(hmc5843_remove),
 	.detect		= hmc5843_detect,
 	.address_list	= normal_i2c,
 };
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH ]hmc5843: Convert to dev pm ops
  2011-01-18  6:59 [PATCH ]hmc5843: Convert to dev pm ops shubhrajyoti
  2011-01-18  6:59 ` [PATCH ] hmc5843: Trivial optimisation shubhrajyoti
@ 2011-01-18 11:09 ` Jonathan Cameron
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2011-01-18 11:09 UTC (permalink / raw)
  To: shubhrajyoti; +Cc: linux-iio

On 01/18/11 06:59, shubhrajyoti@ti.com wrote:
> From: Shubhrajyoti Datta <shubhrajyoti@ti.com>
> 
> 
One quick query inline.
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com>
> ---
>  drivers/staging/iio/magnetometer/hmc5843.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
> index 5168917..b1c26d8 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843.c
> @@ -583,20 +583,25 @@ static int hmc5843_remove(struct i2c_client *client)
>  	kfree(i2c_get_clientdata(client));
>  	return 0;
>  }
> -
> -static int hmc5843_suspend(struct i2c_client *client, pm_message_t mesg)
> +#ifdef CONFIG_PM
> +static int hmc5843_suspend(struct device *dev)
>  {
> +	struct i2c_client *client = to_i2c_client(dev);
>  	hmc5843_configure(client, MODE_SLEEP);
>  	return 0;
>  }
>  
> -static int hmc5843_resume(struct i2c_client *client)
> +static int hmc5843_resume(struct device *dev)
>  {
> +	struct i2c_client *client = to_i2c_client(dev);
>  	struct hmc5843_data *data = i2c_get_clientdata(client);
>  	hmc5843_configure(client, data->operating_mode);
>  	return 0;
>  }
> -
> +static SIMPLE_DEV_PM_OPS(hmc5843_pm, hmc5843_suspend, hmc5843_resume);
> +#else
> +#define hmc5843_pm NULL
Is this needed given at a quick glance, it doesn't look like hmc5843_pm
is used anywhere if CONFIG_PM isn't defined?  (it's protected below as
well)
> +#endif
>  static const struct i2c_device_id hmc5843_id[] = {
>  	{ "hmc5843", 0 },
>  	{ }
> @@ -605,14 +610,15 @@ static const struct i2c_device_id hmc5843_id[] = {
>  static struct i2c_driver hmc5843_driver = {
>  	.driver = {
>  		.name	= "hmc5843",
> +#ifdef CONFIG_PM
> +		.pm	= &hmc5843_pm,
> +#endif
>  	},
>  	.id_table	= hmc5843_id,
>  	.probe		= hmc5843_probe,
>  	.remove		= hmc5843_remove,
>  	.detect		= hmc5843_detect,
>  	.address_list	= normal_i2c,
> -	.suspend	= hmc5843_suspend,
> -	.resume		= hmc5843_resume,
>  };
>  
>  static int __init hmc5843_init(void)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH ] hmc5843: Trivial optimisation
  2011-01-18  6:59 ` [PATCH ] hmc5843: Trivial optimisation shubhrajyoti
@ 2011-01-18 11:14   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2011-01-18 11:14 UTC (permalink / raw)
  To: shubhrajyoti; +Cc: linux-iio

On 01/18/11 06:59, shubhrajyoti@ti.com wrote:
> From: Shubhrajyoti Datta <shubhrajyoti@ti.com>
> 
> Free the memory that is used only at init

hmc5843_init_client is only called by probe.
Could also be marked as devinit for consistency
and possible tiny saving in memory...

Otherwise all fine with me, please forward to GregKH.
> 
> 
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
>  drivers/staging/iio/magnetometer/hmc5843.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
> index b1c26d8..9df66cd 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843.c
> @@ -529,7 +529,7 @@ static void hmc5843_init_client(struct i2c_client *client)
>  	pr_info("HMC5843 initialized\n");
>  }
>  
> -static int hmc5843_probe(struct i2c_client *client,
> +static int __devinit hmc5843_probe(struct i2c_client *client,
>  			 const struct i2c_device_id *id)
>  {
>  	struct hmc5843_data *data;
> @@ -574,7 +574,7 @@ exit:
>  	return err;
>  }
>  
> -static int hmc5843_remove(struct i2c_client *client)
> +static int __devexit hmc5843_remove(struct i2c_client *client)
>  {
>  	struct hmc5843_data *data = i2c_get_clientdata(client);
>  	 /*  sleep mode to save power */
> @@ -616,7 +616,7 @@ static struct i2c_driver hmc5843_driver = {
>  	},
>  	.id_table	= hmc5843_id,
>  	.probe		= hmc5843_probe,
> -	.remove		= hmc5843_remove,
> +	.remove		=  __devexit_p(hmc5843_remove),
>  	.detect		= hmc5843_detect,
>  	.address_list	= normal_i2c,
>  };


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hmc5843: Convert to dev pm ops
  2011-01-18 11:42 [PATCH] hmc5843: " shubhrajyoti
@ 2011-01-18 11:48 ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2011-01-18 11:48 UTC (permalink / raw)
  To: shubhrajyoti; +Cc: linux-iio, Shubhrajyoti D

On 01/18/11 11:42, shubhrajyoti@ti.com wrote:
> From: Shubhrajyoti D <a0393217@india.ti.com>
> 
I'm not that familiar with the power management stuff, but
looks fine to me...
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
>  drivers/staging/iio/magnetometer/hmc5843.c |   16 +++++++++++-----
>  1 files changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
> index 5168917..2650f21 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843.c
> @@ -583,20 +583,25 @@ static int hmc5843_remove(struct i2c_client *client)
>  	kfree(i2c_get_clientdata(client));
>  	return 0;
>  }
> -
> -static int hmc5843_suspend(struct i2c_client *client, pm_message_t mesg)
> +#ifdef CONFIG_PM
> +static int hmc5843_suspend(struct device *dev)
>  {
> +	struct i2c_client *client = to_i2c_client(dev);
>  	hmc5843_configure(client, MODE_SLEEP);
>  	return 0;
>  }
>  
> -static int hmc5843_resume(struct i2c_client *client)
> +static int hmc5843_resume(struct device *dev)
>  {
> +	struct i2c_client *client = to_i2c_client(dev);
>  	struct hmc5843_data *data = i2c_get_clientdata(client);
>  	hmc5843_configure(client, data->operating_mode);
>  	return 0;
>  }
>  
> +static SIMPLE_DEV_PM_OPS(hmc5843_pm, hmc5843_suspend, hmc5843_resume);
> +#endif
> +
>  static const struct i2c_device_id hmc5843_id[] = {
>  	{ "hmc5843", 0 },
>  	{ }
> @@ -605,14 +610,15 @@ static const struct i2c_device_id hmc5843_id[] = {
>  static struct i2c_driver hmc5843_driver = {
>  	.driver = {
>  		.name	= "hmc5843",
> +#ifdef CONFIG_PM
> +		.pm	= &hmc5843_pm,
> +#endif
>  	},
>  	.id_table	= hmc5843_id,
>  	.probe		= hmc5843_probe,
>  	.remove		= hmc5843_remove,
>  	.detect		= hmc5843_detect,
>  	.address_list	= normal_i2c,
> -	.suspend	= hmc5843_suspend,
> -	.resume		= hmc5843_resume,
>  };
>  
>  static int __init hmc5843_init(void)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] hmc5843: Convert to dev pm ops
@ 2011-01-18 11:42 shubhrajyoti
  2011-01-18 11:48 ` Jonathan Cameron
  0 siblings, 1 reply; 6+ messages in thread
From: shubhrajyoti @ 2011-01-18 11:42 UTC (permalink / raw)
  To: linux-iio; +Cc: Shubhrajyoti D, Shubhrajyoti Datta

From: Shubhrajyoti D <a0393217@india.ti.com>

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti@ti.com>
---
 drivers/staging/iio/magnetometer/hmc5843.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index 5168917..2650f21 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -583,20 +583,25 @@ static int hmc5843_remove(struct i2c_client *client)
 	kfree(i2c_get_clientdata(client));
 	return 0;
 }
-
-static int hmc5843_suspend(struct i2c_client *client, pm_message_t mesg)
+#ifdef CONFIG_PM
+static int hmc5843_suspend(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
 	hmc5843_configure(client, MODE_SLEEP);
 	return 0;
 }
 
-static int hmc5843_resume(struct i2c_client *client)
+static int hmc5843_resume(struct device *dev)
 {
+	struct i2c_client *client = to_i2c_client(dev);
 	struct hmc5843_data *data = i2c_get_clientdata(client);
 	hmc5843_configure(client, data->operating_mode);
 	return 0;
 }
 
+static SIMPLE_DEV_PM_OPS(hmc5843_pm, hmc5843_suspend, hmc5843_resume);
+#endif
+
 static const struct i2c_device_id hmc5843_id[] = {
 	{ "hmc5843", 0 },
 	{ }
@@ -605,14 +610,15 @@ static const struct i2c_device_id hmc5843_id[] = {
 static struct i2c_driver hmc5843_driver = {
 	.driver = {
 		.name	= "hmc5843",
+#ifdef CONFIG_PM
+		.pm	= &hmc5843_pm,
+#endif
 	},
 	.id_table	= hmc5843_id,
 	.probe		= hmc5843_probe,
 	.remove		= hmc5843_remove,
 	.detect		= hmc5843_detect,
 	.address_list	= normal_i2c,
-	.suspend	= hmc5843_suspend,
-	.resume		= hmc5843_resume,
 };
 
 static int __init hmc5843_init(void)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-18 11:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18  6:59 [PATCH ]hmc5843: Convert to dev pm ops shubhrajyoti
2011-01-18  6:59 ` [PATCH ] hmc5843: Trivial optimisation shubhrajyoti
2011-01-18 11:14   ` Jonathan Cameron
2011-01-18 11:09 ` [PATCH ]hmc5843: Convert to dev pm ops Jonathan Cameron
2011-01-18 11:42 [PATCH] hmc5843: " shubhrajyoti
2011-01-18 11:48 ` Jonathan Cameron

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.