drivers: fsi: Fix incremeting dev nums
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
@@ -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
@@ -211,6 +211,8 @@ static int scom_remove(struct device *dev) } } +atomic_dec (&scom_idx); +return 0 ; }
Signature · 1 line
1.8.3.1
Joel Stanley
AppliedQuoted 5 lines · Eddie James
From: "Edward A. James" <[email protected]>
both for FSI master and scom client
Signed-off-by Edward A. James <[email protected]>
Applied to dev-4.7.
Cheers,
Joel
Quoted 4 lines
--- drivers/fsi/fsi-core.c | 4 +++- drivers/fsi/fsi-scom.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
Hi Eddie,
Quoted 15 lines
From: "Edward A. James" <[email protected]>
both for FSI master and scom client
Signed-off-by Edward A. James <[email protected]>--- 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
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
-0struct 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
Quoted 44 lines · Jeremy Kerr
Hi Eddie,
Quoted 15 lines
From: "Edward A. James" <[email protected]>
both for FSI master and scom client
Signed-off-by Edward A. James <[email protected]>--- 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
-0drivers/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
-0struct 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_idxat -1
- master added, assigned index 0,master_idxnow at 0
- master added, assigned index 1, master idx now at 1
- master 0 removed,master_idxnow 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