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>
This commit is contained in:
parent
be81c6ea23
commit
0bf841281e
1 changed files with 21 additions and 21 deletions
|
@ -147,6 +147,10 @@ static inline void dump_entry_trace(struct dma_debug_entry *entry)
|
||||||
|
|
||||||
static bool driver_filter(struct device *dev)
|
static bool driver_filter(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct device_driver *drv;
|
||||||
|
unsigned long flags;
|
||||||
|
bool ret;
|
||||||
|
|
||||||
/* driver filter off */
|
/* driver filter off */
|
||||||
if (likely(!current_driver_name[0]))
|
if (likely(!current_driver_name[0]))
|
||||||
return true;
|
return true;
|
||||||
|
@ -155,32 +159,28 @@ static bool driver_filter(struct device *dev)
|
||||||
if (current_driver && dev->driver == current_driver)
|
if (current_driver && dev->driver == current_driver)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (current_driver || !current_driver_name[0])
|
||||||
|
return false;
|
||||||
|
|
||||||
/* driver filter on but not yet initialized */
|
/* driver filter on but not yet initialized */
|
||||||
if (!current_driver && current_driver_name[0]) {
|
drv = get_driver(dev->driver);
|
||||||
struct device_driver *drv = get_driver(dev->driver);
|
if (!drv)
|
||||||
unsigned long flags;
|
return false;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
if (!drv)
|
/* lock to protect against change of current_driver_name */
|
||||||
return false;
|
read_lock_irqsave(&driver_name_lock, flags);
|
||||||
|
|
||||||
/* lock to protect against change of current_driver_name */
|
ret = false;
|
||||||
read_lock_irqsave(&driver_name_lock, flags);
|
if (drv->name &&
|
||||||
|
strncmp(current_driver_name, drv->name, NAME_MAX_LEN - 1) == 0) {
|
||||||
if (drv->name &&
|
current_driver = drv;
|
||||||
strncmp(current_driver_name, drv->name,
|
ret = true;
|
||||||
NAME_MAX_LEN-1) == 0) {
|
|
||||||
current_driver = drv;
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
read_unlock_irqrestore(&driver_name_lock, flags);
|
|
||||||
put_driver(drv);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
read_unlock_irqrestore(&driver_name_lock, flags);
|
||||||
|
put_driver(drv);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define err_printk(dev, entry, format, arg...) do { \
|
#define err_printk(dev, entry, format, arg...) do { \
|
||||||
|
|
Loading…
Reference in a new issue