Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1183486 > unrolled thread

[PATCH] power: Destroy IDRs on module exit

Started byJohannes Thumshirn <jthumshirn@suse.de>
First post2015-07-14 11:20 +0200
Last post2015-07-14 11:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] power: Destroy IDRs on module exit Johannes Thumshirn <jthumshirn@suse.de> - 2015-07-14 11:20 +0200
    Re: [PATCH] power: Destroy IDRs on module exit Pali Rohár <pali.rohar@gmail.com> - 2015-07-14 11:30 +0200

#1183486 — [PATCH] power: Destroy IDRs on module exit

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2015-07-14 11:20 +0200
Subject[PATCH] power: Destroy IDRs on module exit
Message-ID<pM4xA-lo-11@gated-at.bofh.it>
Destroy IDRs on module exit, freeing the resources for
* bq2415x_charger.c
* ds2782_battery.c
* ltc2941-battery-gauge.c

The drivers had to be converted to "ordinary" module_init()/module_exit()
style drivers instead of using module_i2c_driver.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/power/bq2415x_charger.c       | 20 +++++++++++++++++++-
 drivers/power/ds2782_battery.c        | 20 +++++++++++++++++++-
 drivers/power/ltc2941-battery-gauge.c | 20 +++++++++++++++++++-
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
index e98dcb6..38f4208 100644
--- a/drivers/power/bq2415x_charger.c
+++ b/drivers/power/bq2415x_charger.c
@@ -1773,7 +1773,25 @@ static struct i2c_driver bq2415x_driver = {
 	.remove = bq2415x_remove,
 	.id_table = bq2415x_i2c_id_table,
 };
-module_i2c_driver(bq2415x_driver);
+
+static int __init bq2415x_init(void)
+{
+	int ret;
+
+	ret = i2c_add_driver(&bq2415x_driver);
+	if (ret)
+		printk(KERN_ERR "Unable to register bq2415x-battery driver\n");
+
+	return ret;
+}
+module_init(bq2415x_init);
+
+static void __exit bq2415x_exit(void)
+{
+	i2c_del_driver(&bq2415x_driver);
+	idr_destroy(&bq2415x_id);
+}
+module_exit(bq2415x_exit);
 
 MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
 MODULE_DESCRIPTION("bq2415x charger driver");
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
index ed4d756..410bc9d 100644
--- a/drivers/power/ds2782_battery.c
+++ b/drivers/power/ds2782_battery.c
@@ -468,7 +468,25 @@ static struct i2c_driver ds278x_battery_driver = {
 	.remove		= ds278x_battery_remove,
 	.id_table	= ds278x_id,
 };
-module_i2c_driver(ds278x_battery_driver);
+
+static int __init ds2782_init(void)
+{
+	int ret;
+
+	ret = i2c_add_driver(&ds278x_battery_driver);
+	if (ret)
+		printk(KERN_ERR "Unable to register ds2782-battery driver\n");
+
+	return ret;
+}
+module_init(ds2782_init);
+
+static void __exit ds2782_exit(void)
+{
+	i2c_del_driver(&ds278x_battery_driver);
+	idr_destroy(&battery_id);
+}
+module_exit(ds2782_exit);
 
 MODULE_AUTHOR("Ryan Mallon");
 MODULE_DESCRIPTION("Maxim/Dallas DS2782 Stand-Alone Fuel Gauage IC driver");
diff --git a/drivers/power/ltc2941-battery-gauge.c b/drivers/power/ltc2941-battery-gauge.c
index daeb086..6fbbcd2 100644
--- a/drivers/power/ltc2941-battery-gauge.c
+++ b/drivers/power/ltc2941-battery-gauge.c
@@ -544,7 +544,25 @@ static struct i2c_driver ltc294x_driver = {
 	.remove		= ltc294x_i2c_remove,
 	.id_table	= ltc294x_i2c_id,
 };
-module_i2c_driver(ltc294x_driver);
+
+static int __init ltc294x_init(void)
+{
+	int ret;
+
+	ret = i2c_add_driver(&ltc294x_driver);
+	if (ret)
+		printk(KERN_ERR "Unable to register bq2415x-battery driver\n");
+
+	return ret;
+}
+module_init(ltc294x_init);
+
+static void __exit ltc294x_exit(void)
+{
+	i2c_del_driver(&ltc294x_driver);
+	idr_destroy(&ltc294x_id);
+}
+module_exit(ltc294x_exit);
 
 MODULE_AUTHOR("Auryn Verwegen, Topic Embedded Systems");
 MODULE_AUTHOR("Mike Looijmans, Topic Embedded Products");
-- 
2.4.5

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

[toc] | [next] | [standalone]


#1183495

FromPali Rohár <pali.rohar@gmail.com>
Date2015-07-14 11:30 +0200
Message-ID<pM4Hh-oF-47@gated-at.bofh.it>
In reply to#1183486
On Tuesday 14 July 2015 11:16:14 Johannes Thumshirn wrote:
> Destroy IDRs on module exit, freeing the resources for
> * bq2415x_charger.c
> * ds2782_battery.c
> * ltc2941-battery-gauge.c
> 
> The drivers had to be converted to "ordinary" module_init()/module_exit()
> style drivers instead of using module_i2c_driver.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/power/bq2415x_charger.c       | 20 +++++++++++++++++++-
>  drivers/power/ds2782_battery.c        | 20 +++++++++++++++++++-
>  drivers/power/ltc2941-battery-gauge.c | 20 +++++++++++++++++++-
>  3 files changed, 57 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c
> index e98dcb6..38f4208 100644
> --- a/drivers/power/bq2415x_charger.c
> +++ b/drivers/power/bq2415x_charger.c
> @@ -1773,7 +1773,25 @@ static struct i2c_driver bq2415x_driver = {
>  	.remove = bq2415x_remove,
>  	.id_table = bq2415x_i2c_id_table,
>  };
> -module_i2c_driver(bq2415x_driver);
> +
> +static int __init bq2415x_init(void)
> +{
> +	int ret;
> +
> +	ret = i2c_add_driver(&bq2415x_driver);
> +	if (ret)
> +		printk(KERN_ERR "Unable to register bq2415x-battery driver\n");
> +
> +	return ret;
> +}
> +module_init(bq2415x_init);
> +
> +static void __exit bq2415x_exit(void)
> +{
> +	i2c_del_driver(&bq2415x_driver);
> +	idr_destroy(&bq2415x_id);
> +}
> +module_exit(bq2415x_exit);
>  
>  MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>");
>  MODULE_DESCRIPTION("bq2415x charger driver");
> diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
> index ed4d756..410bc9d 100644
> --- a/drivers/power/ds2782_battery.c
> +++ b/drivers/power/ds2782_battery.c
> @@ -468,7 +468,25 @@ static struct i2c_driver ds278x_battery_driver = {
>  	.remove		= ds278x_battery_remove,
>  	.id_table	= ds278x_id,
>  };
> -module_i2c_driver(ds278x_battery_driver);
> +
> +static int __init ds2782_init(void)
> +{
> +	int ret;
> +
> +	ret = i2c_add_driver(&ds278x_battery_driver);
> +	if (ret)
> +		printk(KERN_ERR "Unable to register ds2782-battery driver\n");
> +
> +	return ret;
> +}
> +module_init(ds2782_init);
> +
> +static void __exit ds2782_exit(void)
> +{
> +	i2c_del_driver(&ds278x_battery_driver);
> +	idr_destroy(&battery_id);
> +}
> +module_exit(ds2782_exit);
>  
>  MODULE_AUTHOR("Ryan Mallon");
>  MODULE_DESCRIPTION("Maxim/Dallas DS2782 Stand-Alone Fuel Gauage IC driver");
> diff --git a/drivers/power/ltc2941-battery-gauge.c b/drivers/power/ltc2941-battery-gauge.c
> index daeb086..6fbbcd2 100644
> --- a/drivers/power/ltc2941-battery-gauge.c
> +++ b/drivers/power/ltc2941-battery-gauge.c
> @@ -544,7 +544,25 @@ static struct i2c_driver ltc294x_driver = {
>  	.remove		= ltc294x_i2c_remove,
>  	.id_table	= ltc294x_i2c_id,
>  };
> -module_i2c_driver(ltc294x_driver);
> +
> +static int __init ltc294x_init(void)
> +{
> +	int ret;
> +
> +	ret = i2c_add_driver(&ltc294x_driver);
> +	if (ret)
> +		printk(KERN_ERR "Unable to register bq2415x-battery driver\n");
> +
> +	return ret;
> +}
> +module_init(ltc294x_init);
> +
> +static void __exit ltc294x_exit(void)
> +{
> +	i2c_del_driver(&ltc294x_driver);
> +	idr_destroy(&ltc294x_id);
> +}
> +module_exit(ltc294x_exit);
>  
>  MODULE_AUTHOR("Auryn Verwegen, Topic Embedded Systems");
>  MODULE_AUTHOR("Mike Looijmans, Topic Embedded Products");

I'm feeling that there is something wrong with idr API. There is no idr
code in __init functions, so why it is needed for __exit? idr functions
are used in devices, not in global module.

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web