firewire: get_cycle_timer optimization and cleanup
ohci: Break out of the retry loop if too many attempts were necessary. This may theoretically happen if the chip is fatally defective or if the get_cycle_timer ioctl was performed after a CardBus controller was ejected. Also micro-optimize the loop by re-using the last two register reads in the next iteration, remove a questionable inline keyword, and shuffle a comment around. core: ioctl_get_cycle_timer() is always called with interrupts on, therefore local_irq_save() can be replaced by local_irq_disable(). Disabled local IRQs imply disabled preemption, hence preempt_disable() can be removed. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
This commit is contained in:
@ -25,6 +25,7 @@
|
||||
#include <linux/firewire.h>
|
||||
#include <linux/firewire-cdev.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/irqflags.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/kref.h>
|
||||
@ -32,7 +33,6 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/preempt.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/time.h>
|
||||
@ -1013,21 +1013,19 @@ static int ioctl_get_cycle_timer(struct client *client, void *buffer)
|
||||
{
|
||||
struct fw_cdev_get_cycle_timer *request = buffer;
|
||||
struct fw_card *card = client->device->card;
|
||||
unsigned long long bus_time;
|
||||
struct timeval tv;
|
||||
unsigned long flags;
|
||||
u32 cycle_time;
|
||||
|
||||
preempt_disable();
|
||||
local_irq_save(flags);
|
||||
local_irq_disable();
|
||||
|
||||
bus_time = card->driver->get_bus_time(card);
|
||||
cycle_time = card->driver->get_bus_time(card);
|
||||
do_gettimeofday(&tv);
|
||||
|
||||
local_irq_restore(flags);
|
||||
preempt_enable();
|
||||
local_irq_enable();
|
||||
|
||||
request->local_time = tv.tv_sec * 1000000ULL + tv.tv_usec;
|
||||
request->cycle_timer = bus_time & 0xffffffff;
|
||||
request->cycle_timer = cycle_time;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user