diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-06-08 09:53:46 -0400 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-06-08 09:53:46 -0400 |
commit | 0bf841281e58d0b3cc9fe9dc4383df7694bde6bd (patch) | |
tree | b45e799974aa94c8d1e5c89bbd3dcd5c69d26991 /lib/dma-debug.c | |
parent | be81c6ea23b8b471141734ef4bc005f5127aaf43 (diff) |
dma-debug: simplify logic in driver_filter()
This patch makes the driver_filter function more readable by
reorganizing the code. The removal of a code code block to an upper
indentation level makes hard-to-read line-wraps unnecessary.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'lib/dma-debug.c')
-rw-r--r-- | lib/dma-debug.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 27b369da52c..ad65fc0317d 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
@@ -147,6 +147,10 @@ static inline void dump_entry_trace(struct dma_debug_entry *entry) | |||
147 | 147 | ||
148 | static bool driver_filter(struct device *dev) | 148 | static bool driver_filter(struct device *dev) |
149 | { | 149 | { |
150 | struct device_driver *drv; | ||
151 | unsigned long flags; | ||
152 | bool ret; | ||
153 | |||
150 | /* driver filter off */ | 154 | /* driver filter off */ |
151 | if (likely(!current_driver_name[0])) | 155 | if (likely(!current_driver_name[0])) |
152 | return true; | 156 | return true; |
@@ -155,32 +159,28 @@ static bool driver_filter(struct device *dev) | |||
155 | if (current_driver && dev->driver == current_driver) | 159 | if (current_driver && dev->driver == current_driver) |
156 | return true; | 160 | return true; |
157 | 161 | ||
158 | /* driver filter on but not yet initialized */ | 162 | if (current_driver || !current_driver_name[0]) |
159 | if (!current_driver && current_driver_name[0]) { | 163 | return false; |
160 | struct device_driver *drv = get_driver(dev->driver); | ||
161 | unsigned long flags; | ||
162 | bool ret = false; | ||
163 | |||
164 | if (!drv) | ||
165 | return false; | ||
166 | |||
167 | /* lock to protect against change of current_driver_name */ | ||
168 | read_lock_irqsave(&driver_name_lock, flags); | ||
169 | 164 | ||
170 | if (drv->name && | 165 | /* driver filter on but not yet initialized */ |
171 | strncmp(current_driver_name, drv->name, | 166 | drv = get_driver(dev->driver); |
172 | NAME_MAX_LEN-1) == 0) { | 167 | if (!drv) |
173 | current_driver = drv; | 168 | return false; |
174 | ret = true; | ||
175 | } | ||
176 | 169 | ||
177 | read_unlock_irqrestore(&driver_name_lock, flags); | 170 | /* lock to protect against change of current_driver_name */ |
178 | put_driver(drv); | 171 | read_lock_irqsave(&driver_name_lock, flags); |
179 | 172 | ||
180 | return ret; | 173 | ret = false; |
174 | if (drv->name && | ||
175 | strncmp(current_driver_name, drv->name, NAME_MAX_LEN - 1) == 0) { | ||
176 | current_driver = drv; | ||
177 | ret = true; | ||
181 | } | 178 | } |
182 | 179 | ||
183 | return false; | 180 | read_unlock_irqrestore(&driver_name_lock, flags); |
181 | put_driver(drv); | ||
182 | |||
183 | return ret; | ||
184 | } | 184 | } |
185 | 185 | ||
186 | #define err_printk(dev, entry, format, arg...) do { \ | 186 | #define err_printk(dev, entry, format, arg...) do { \ |