Skip to contentSkip to conversation

drivers: fsi: Fix incremeting dev nums

PATCH Applied Eddie James 3 participants 4 messages Feb 16, 2017 – Feb 17, 2017 FSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: fsi: Fix incremeting dev nums

From: "Edward A. James" <[email protected]>

both for FSI master and scom client

---
 drivers/fsi/fsi-core.c | 4 +++-
 drivers/fsi/fsi-scom.c | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +3 -1
index e8a3618..7816482 100644
@@ -46,7 +46,7 @@ static const int engine_page_size = 0x400;
 static struct task_struct *master_ipoll;
 static unsigned int fsi_ipoll_period_ms = 100;
 
-static atomic_t master_idx = ATOMIC_INIT(-1);
+static atomic_t master_idx = ATOMIC_INIT(0);
 
 struct fsi_slave {
 	struct list_head	list_link;	/* Master's list of slaves */
@@ -617,6 +617,8 @@ void fsi_master_unregister(struct fsi_master *master)
 		kthread_stop(master_ipoll);
 		master_ipoll = NULL;
 	}
+
+	atomic_dec(&master_idx);
 }
 EXPORT_SYMBOL_GPL(fsi_master_unregister);
 
drivers/fsi/fsi-scom.c +2 -0
index a439a5e..62d3482 100644
@@ -211,6 +211,8 @@ static int scom_remove(struct device *dev)
 		}
 	}
 
+	atomic_dec(&scom_idx);
+
 	return 0;
 }
 
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Eddie James

Hi Eddie,

Quoted 15 lines

From: "Edward A. James" <[email protected]>

both for FSI master and scom client

---
 drivers/fsi/fsi-core.c | 4 +++-
 drivers/fsi/fsi-scom.c | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +0 -0
index e8a3618..7816482 100644

drivers/fsi/fsi-core.c static const int engine_page_size = 0x400; · line 49

Quoted 5 lines
drivers/fsi/fsi-core.c +1 -1
@@ -46,7 +46,7 @@ static const int engine_page_size = 0x400;
 static struct task_struct *master_ipoll;
 static unsigned int fsi_ipoll_period_ms = 100;
 
-static atomic_t master_idx = ATOMIC_INIT(-1);
+static atomic_t master_idx = ATOMIC_INIT(0);

This will mean that our first master is numbered 1 instead of zero. Not a huge problem, but it doesn't sound like that's what you wanted to do here.

drivers/fsi/fsi-core.c void fsi_master_unregister(struct fsi_master *master) · line 621

Quoted 8 lines
drivers/fsi/fsi-core.c +2 -0
 struct fsi_slave {
 	struct list_head	list_link;	/* Master's list of slaves */
@@ -617,6 +617,8 @@ void fsi_master_unregister(struct fsi_master *master)
 		kthread_stop(master_ipoll);
 		master_ipoll = NULL;
 	}
+
+	atomic_dec(&master_idx);

This doesn't work. Consider (starting from -1):

- master_idx at -1
- master added, assigned index 0, master_idx now at 0
- master added, assigned index 1, master idx now at 1
- master 0 removed, master_idx now at 0
- master added, assigned index 1

now we have two masters with index 1.

Either we need to check for present masters, or use the ida functions (as greg kh has suggested).

So, nak from me on this.

Regards,

Jeremy

#3 lore raw
Quoted 44 lines · Jeremy Kerr

Hi Eddie,

Quoted 15 lines

From: "Edward A. James" <[email protected]>

both for FSI master and scom client

---
 drivers/fsi/fsi-core.c | 4 +++-
 drivers/fsi/fsi-scom.c | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/fsi/fsi-core.c +0 -0
index e8a3618..7816482 100644

drivers/fsi/fsi-core.c static const int engine_page_size = 0x400; · line 49

Quoted 5 lines
drivers/fsi/fsi-core.c +1 -1
@@ -46,7 +46,7 @@ static const int engine_page_size = 0x400;
 static struct task_struct *master_ipoll;
 static unsigned int fsi_ipoll_period_ms = 100;
 
-static atomic_t master_idx = ATOMIC_INIT(-1);
+static atomic_t master_idx = ATOMIC_INIT(0);

This will mean that our first master is numbered 1 instead of zero. Not a huge problem, but it doesn't sound like that's what you wanted to do here.

drivers/fsi/fsi-core.c void fsi_master_unregister(struct fsi_master *master) · line 621

Quoted 8 lines
drivers/fsi/fsi-core.c +2 -0
 struct fsi_slave {
      struct list_head        list_link;      /* Master's list of slaves */
@@ -617,6 +617,8 @@ void fsi_master_unregister(struct fsi_master *master)
              kthread_stop(master_ipoll);
              master_ipoll = NULL;
      }
+
+     atomic_dec(&master_idx);

This doesn't work. Consider (starting from -1):

- master_idx at -1
- master added, assigned index 0, master_idx now at 0
- master added, assigned index 1, master idx now at 1
- master 0 removed, master_idx now at 0
- master added, assigned index 1

Quoted 6 lines

now we have two masters with index 1.

Either we need to check for present masters, or use the ida functions (as greg kh has suggested).

So, nak from me on this.

Thanks Jeremy. I missed this case when reviewing.

I have committed a revert of this patch.

Cheers,

Joel