* [PATCH] i2o: fix notifiers when max_drivers is configured
@ 2007-05-20 14:27 Akinobu Mita
2007-05-21 4:16 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Akinobu Mita @ 2007-05-20 14:27 UTC (permalink / raw)
To: Markus Lidel; +Cc: linux-kernel
Maxinum number of I2O drivers which could be registered is
configurable by max_drivers module parameter.
But the module parameter is ignored and default value (I2O_MAX_DRIVERS = 8)
is used in the loops to notify all registered drivers.
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
drivers/message/i2o/driver.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: 2.6-mm/drivers/message/i2o/driver.c
===================================================================
--- 2.6-mm.orig/drivers/message/i2o/driver.c
+++ 2.6-mm/drivers/message/i2o/driver.c
@@ -20,6 +20,7 @@
#include <linux/workqueue.h>
#include <linux/string.h>
#include <linux/slab.h>
+#include <linux/log2.h>
#include "core.h"
#define OSM_NAME "i2o"
@@ -260,7 +261,7 @@ void i2o_driver_notify_controller_add_al
int i;
struct i2o_driver *drv;
- for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+ for (i = 0; i < i2o_max_drivers; i++) {
drv = i2o_drivers[i];
if (drv)
@@ -280,7 +281,7 @@ void i2o_driver_notify_controller_remove
int i;
struct i2o_driver *drv;
- for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+ for (i = 0; i < i2o_max_drivers; i++) {
drv = i2o_drivers[i];
if (drv)
@@ -299,7 +300,7 @@ void i2o_driver_notify_device_add_all(st
int i;
struct i2o_driver *drv;
- for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+ for (i = 0; i < i2o_max_drivers; i++) {
drv = i2o_drivers[i];
if (drv)
@@ -318,7 +319,7 @@ void i2o_driver_notify_device_remove_all
int i;
struct i2o_driver *drv;
- for (i = 0; i < I2O_MAX_DRIVERS; i++) {
+ for (i = 0; i < i2o_max_drivers; i++) {
drv = i2o_drivers[i];
if (drv)
@@ -340,8 +341,7 @@ int __init i2o_driver_init(void)
spin_lock_init(&i2o_drivers_lock);
if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
- ((i2o_max_drivers ^ (i2o_max_drivers - 1)) !=
- (2 * i2o_max_drivers - 1))) {
+ !is_power_of_2(i2o_max_drivers)) {
osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
"a power of 2\n", i2o_max_drivers);
i2o_max_drivers = I2O_MAX_DRIVERS;
@@ -349,7 +349,7 @@ int __init i2o_driver_init(void)
osm_info("max drivers = %d\n", i2o_max_drivers);
i2o_drivers =
- kzalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL);
+ kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL);
if (!i2o_drivers)
return -ENOMEM;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2o: fix notifiers when max_drivers is configured
2007-05-20 14:27 [PATCH] i2o: fix notifiers when max_drivers is configured Akinobu Mita
@ 2007-05-21 4:16 ` Andrew Morton
2007-05-21 16:58 ` Akinobu Mita
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2007-05-21 4:16 UTC (permalink / raw)
To: Akinobu Mita; +Cc: Markus Lidel, linux-kernel
On Sun, 20 May 2007 23:27:28 +0900 Akinobu Mita <akinobu.mita@gmail.com> wrote:
> Maxinum number of I2O drivers which could be registered is
> configurable by max_drivers module parameter.
>
> But the module parameter is ignored and default value (I2O_MAX_DRIVERS = 8)
> is used in the loops to notify all registered drivers.
>
> Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>
> ---
> drivers/message/i2o/driver.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> Index: 2.6-mm/drivers/message/i2o/driver.c
> ===================================================================
> --- 2.6-mm.orig/drivers/message/i2o/driver.c
> +++ 2.6-mm/drivers/message/i2o/driver.c
> @@ -20,6 +20,7 @@
> #include <linux/workqueue.h>
> #include <linux/string.h>
> #include <linux/slab.h>
> +#include <linux/log2.h>
> #include "core.h"
>
> #define OSM_NAME "i2o"
> @@ -260,7 +261,7 @@ void i2o_driver_notify_controller_add_al
> int i;
> struct i2o_driver *drv;
>
> - for (i = 0; i < I2O_MAX_DRIVERS; i++) {
> + for (i = 0; i < i2o_max_drivers; i++) {
> drv = i2o_drivers[i];
>
> if (drv)
> @@ -280,7 +281,7 @@ void i2o_driver_notify_controller_remove
> int i;
> struct i2o_driver *drv;
>
> - for (i = 0; i < I2O_MAX_DRIVERS; i++) {
> + for (i = 0; i < i2o_max_drivers; i++) {
> drv = i2o_drivers[i];
>
> if (drv)
> @@ -299,7 +300,7 @@ void i2o_driver_notify_device_add_all(st
> int i;
> struct i2o_driver *drv;
>
> - for (i = 0; i < I2O_MAX_DRIVERS; i++) {
> + for (i = 0; i < i2o_max_drivers; i++) {
> drv = i2o_drivers[i];
>
> if (drv)
> @@ -318,7 +319,7 @@ void i2o_driver_notify_device_remove_all
> int i;
> struct i2o_driver *drv;
>
> - for (i = 0; i < I2O_MAX_DRIVERS; i++) {
> + for (i = 0; i < i2o_max_drivers; i++) {
> drv = i2o_drivers[i];
>
> if (drv)
> @@ -340,8 +341,7 @@ int __init i2o_driver_init(void)
> spin_lock_init(&i2o_drivers_lock);
>
> if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
> - ((i2o_max_drivers ^ (i2o_max_drivers - 1)) !=
> - (2 * i2o_max_drivers - 1))) {
> + !is_power_of_2(i2o_max_drivers)) {
> osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
> "a power of 2\n", i2o_max_drivers);
> i2o_max_drivers = I2O_MAX_DRIVERS;
> @@ -349,7 +349,7 @@ int __init i2o_driver_init(void)
> osm_info("max drivers = %d\n", i2o_max_drivers);
>
> i2o_drivers =
> - kzalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL);
> + kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL);
> if (!i2o_drivers)
> return -ENOMEM;
>
Is there any particular reason why i2o_max_drivers must be a power of two?
It seems a peculiar constraint.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i2o: fix notifiers when max_drivers is configured
2007-05-21 4:16 ` Andrew Morton
@ 2007-05-21 16:58 ` Akinobu Mita
0 siblings, 0 replies; 3+ messages in thread
From: Akinobu Mita @ 2007-05-21 16:58 UTC (permalink / raw)
To: Andrew Morton; +Cc: Markus Lidel, linux-kernel
On Sun, May 20, 2007 at 09:16:59PM -0700, Andrew Morton wrote:
> > @@ -340,8 +341,7 @@ int __init i2o_driver_init(void)
> > spin_lock_init(&i2o_drivers_lock);
> >
> > if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
> > - ((i2o_max_drivers ^ (i2o_max_drivers - 1)) !=
> > - (2 * i2o_max_drivers - 1))) {
> > + !is_power_of_2(i2o_max_drivers)) {
> > osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
> > "a power of 2\n", i2o_max_drivers);
> > i2o_max_drivers = I2O_MAX_DRIVERS;
>
> Is there any particular reason why i2o_max_drivers must be a power of two?
> It seems a peculiar constraint.
I can't find the reason.
Subject: [patch -mm] i2o: eliminate a peculiar constraint on i2o_max_drivers
There is no reason i2o_max_drivers must be a power of two.
This patch eliminates such a constraint.
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
drivers/message/i2o/driver.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
Index: 2.6-mm/drivers/message/i2o/driver.c
===================================================================
--- 2.6-mm.orig/drivers/message/i2o/driver.c
+++ 2.6-mm/drivers/message/i2o/driver.c
@@ -20,7 +20,6 @@
#include <linux/workqueue.h>
#include <linux/string.h>
#include <linux/slab.h>
-#include <linux/log2.h>
#include "core.h"
#define OSM_NAME "i2o"
@@ -340,10 +339,9 @@ int __init i2o_driver_init(void)
spin_lock_init(&i2o_drivers_lock);
- if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64) ||
- !is_power_of_2(i2o_max_drivers)) {
- osm_warn("max_drivers set to %d, but must be >=2 and <= 64 and "
- "a power of 2\n", i2o_max_drivers);
+ if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64)) {
+ osm_warn("max_drivers set to %d, but must be >=2 and <= 64\n",
+ i2o_max_drivers);
i2o_max_drivers = I2O_MAX_DRIVERS;
}
osm_info("max drivers = %d\n", i2o_max_drivers);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-21 17:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-20 14:27 [PATCH] i2o: fix notifiers when max_drivers is configured Akinobu Mita
2007-05-21 4:16 ` Andrew Morton
2007-05-21 16:58 ` Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).