[PATCH] [RFC] firewire: nosy: simplify grabbing context pointer in open()

2015-03-13 Thread Martin Kepplinger
Signed-off-by: Martin Kepplinger 
---

This is a question: What's the real difference between the two solutions?
I'm not sure if they are equivalent :(


 drivers/firewire/nosy.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 76b2d39..f43619e 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -275,16 +275,12 @@ set_phy_reg(struct pcilynx *lynx, int addr, int val)
 static int
 nosy_open(struct inode *inode, struct file *file)
 {
-   int minor = iminor(inode);
struct client *client;
-   struct pcilynx *tmp, *lynx = NULL;
+   struct pcilynx *lynx = NULL;
 
mutex_lock(_mutex);
-   list_for_each_entry(tmp, _list, link)
-   if (tmp->misc.minor == minor) {
-   lynx = lynx_get(tmp);
-   break;
-   }
+   lynx = container_of(file->private_data, struct pcilynx, misc);
+   lynx = lynx_get(lynx);
mutex_unlock(_mutex);
if (lynx == NULL)
return -ENODEV;
-- 
2.1.4

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


[PATCH] [RFC] firewire: nosy: simplify grabbing context pointer in open()

2015-03-13 Thread Martin Kepplinger
Signed-off-by: Martin Kepplinger mart...@posteo.de
---

This is a question: What's the real difference between the two solutions?
I'm not sure if they are equivalent :(


 drivers/firewire/nosy.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 76b2d39..f43619e 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -275,16 +275,12 @@ set_phy_reg(struct pcilynx *lynx, int addr, int val)
 static int
 nosy_open(struct inode *inode, struct file *file)
 {
-   int minor = iminor(inode);
struct client *client;
-   struct pcilynx *tmp, *lynx = NULL;
+   struct pcilynx *lynx = NULL;
 
mutex_lock(card_mutex);
-   list_for_each_entry(tmp, card_list, link)
-   if (tmp-misc.minor == minor) {
-   lynx = lynx_get(tmp);
-   break;
-   }
+   lynx = container_of(file-private_data, struct pcilynx, misc);
+   lynx = lynx_get(lynx);
mutex_unlock(card_mutex);
if (lynx == NULL)
return -ENODEV;
-- 
2.1.4

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