Skip to contentSkip to conversation

+ input-new-force-feedback-interface.patch added to -mm tree

DISCUSSION Arjan van de Ven 2 participants 3 messages May 19, 2006 – May 23, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Review

Quoted 6 lines · On Wed, 2006-05-17 at 21:46 -0700, [email protected] wrote:
(quoted diff) +6 -0
+
+#ifdef DEBUG
+#define debug(format, arg...) printk(KERN_DEBUG "ff-effects: " format "\n" , ## arg)
+#else
+#define debug(format, arg...) do {} while (0)
+#endif

please just use the existing prdebug() thing for this, no need to invent your own ;)

Review

Quoted 5 lines
(quoted diff) +5 -0
+
+EXPORT_SYMBOL(input_ff_allocate);
+EXPORT_SYMBOL(input_ff_register);
+EXPORT_SYMBOL(input_ff_upload);
+EXPORT_SYMBOL(input_ff_erase);

should these be _GPL exports?

Review

Quoted 12 lines
(quoted diff) +12 -0
+
+#define spin_ff_cond_lock(_ff, _flags)					  \
+	do {								  \
+		if (!_ff->driver->playback)				  \
+			spin_lock_irqsave(&_ff->atomiclock, _flags);	  \
+	} while (0);
+
+#define spin_ff_cond_unlock(_ff, _flags)					  \
+	do {								  \
+		if (!_ff->driver->playback)				  \
+			spin_unlock_irqrestore(&_ff->atomiclock, _flags); \
+	} while (0);

hmmm conditional locking like this always makes me very nervous... what is preventing ->playback from changing halfway a locked sequence?

Review

Quoted 3 lines
(quoted diff) +3 -0
+	if (!events) {
+		debug("no actions");
+		del_timer(&ff->timer);

are you really sure you don't need del_timer_sync() here?

Review

Quoted 9 lines
(quoted diff) +9 -0
+static void input_ff_timer(unsigned long timer_data)
+{
+	struct input_dev *dev = (struct input_dev *) timer_data;
+	struct ff_device *ff = dev->ff;
+	struct ff_effect effect;
+	int i;
+	unsigned long flags;
+	int effects_pending;
+	unsigned long effect_handled[NBITS(FF_EFFECTS_MAX)];

hmmm stack space?

Review

Quoted 2 lines
(quoted diff) +2 -0
+		} else {
+			ret = -ENOSYS;

that is almost always a wrong return value

Review

Quoted 9 lines
(quoted diff) +9 -0
+	if (test_bit(FF_CONSTANT, dev->ff->flags))
+		set_bit(FF_CONSTANT, dev->ffbit);
+	if (test_bit(FF_SPRING, dev->ff->flags))
+		set_bit(FF_SPRING, dev->ffbit);
+	if (test_bit(FF_FRICTION, dev->ff->flags))
+		set_bit(FF_FRICTION, dev->ffbit);
+	if (test_bit(FF_DAMPER, dev->ff->flags))
+		set_bit(FF_DAMPER, dev->ffbit);
+	if (test_bit(FF_INERTIA, dev->ff->flags))

are you really sure you need atomic set_bit()'s here?? if so.. I think you have a race ;)

#2 lore raw
Quoted 12 lines · Arjan van de Ven

Review

Quoted 6 lines · On Wed, 2006-05-17 at 21:46 -0700, [email protected] wrote:
(quoted diff) +6 -0
+
+#ifdef DEBUG
+#define debug(format, arg...) printk(KERN_DEBUG "ff-effects: " format "\n" , ## arg)
+#else
+#define debug(format, arg...) do {} while (0)
+#endif

please just use the existing prdebug() thing for this, no need to invent your own ;)

Couldn't find any info on that one, are you sure you spelled it correctly?

Quoted 10 lines

Review

Quoted 6 lines
(quoted diff) +5 -0
+
+EXPORT_SYMBOL(input_ff_allocate);
+EXPORT_SYMBOL(input_ff_register);
+EXPORT_SYMBOL(input_ff_upload);
+EXPORT_SYMBOL(input_ff_erase);

should these be _GPL exports?

Well, I don't know. When should EXPORT_SYMBOLs be EXPORT_SYMBOL_GPLs?

Quoted 10 lines
Quoted 10 lines
(quoted diff) +9 -0
+
+#define spin_ff_cond_lock(_ff, _flags)					  \
+	do {								  \
+		if (!_ff->driver->playback)				  \
+			spin_lock_irqsave(&_ff->atomiclock, _flags);	  \
+	} while (0);
+
+#define spin_ff_cond_unlock(_ff, _flags)					  \
+	do {								  \
Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+		if (!_ff->driver->playback)				  \
+			spin_unlock_irqrestore(&_ff->atomiclock, _flags); \
+	} while (0);

hmmm conditional locking like this always makes me very nervous... what is preventing ->playback from changing halfway a locked sequence?

Well, it's never changed, locked or not. But maybe we can get rid of this condlocking alltogether, see my reply for Andrew Morton.

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +3 -0
+	if (!events) {
+		debug("no actions");
+		del_timer(&ff->timer);

are you really sure you don't need del_timer_sync() here?

Yes, this function is also called from inside the timer in question and del_timer_sync() would block.

Quoted 16 lines

Review

Quoted 11 lines
(quoted diff) +9 -0
+static void input_ff_timer(unsigned long timer_data)
+{
+	struct input_dev *dev = (struct input_dev *) timer_data;
+	struct ff_device *ff = dev->ff;
+	struct ff_effect effect;
+	int i;
+	unsigned long flags;
+	int effects_pending;
+	unsigned long effect_handled[NBITS(FF_EFFECTS_MAX)];

hmmm stack space?

I count 76 bytes (x86), is that too much?

Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+		} else {
+			ret = -ENOSYS;

that is almost always a wrong return value

It's returned when the device is mem-capable but driver doesn't implement set_gain() but sets FF_GAIN or when driver doesn't implement set_autocenter() but sets FF_AUTOCENTER. But yes, if that happens, it's a driver bug, so maybe this is not correct use for -ENOSYS. Probably there should be BUG() too here.

Quoted 5 lines
Quoted 5 lines
(quoted diff) +5 -0
+	if (test_bit(FF_CONSTANT, dev->ff->flags))
+		set_bit(FF_CONSTANT, dev->ffbit);
+	if (test_bit(FF_SPRING, dev->ff->flags))
+		set_bit(FF_SPRING, dev->ffbit);
+	if (test_bit(FF_FRICTION, dev->ff->flags))
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+		set_bit(FF_FRICTION, dev->ffbit);
+	if (test_bit(FF_DAMPER, dev->ff->flags))
+		set_bit(FF_DAMPER, dev->ffbit);
+	if (test_bit(FF_INERTIA, dev->ff->flags))

are you really sure you need atomic set_bit()'s here?? if so.. I think you have a race ;)

Well, I'm not. Is there an alternative?

Signature · 1 line
Anssi Hannula
#3 lore raw
Quoted 14 lines · Anssi Hannula
Quoted 12 lines · Arjan van de Ven

Review

Quoted 6 lines · On Wed, 2006-05-17 at 21:46 -0700, [email protected] wrote:
(quoted diff) +6 -0
+
+#ifdef DEBUG
+#define debug(format, arg...) printk(KERN_DEBUG "ff-effects: " format "\n" , ## arg)
+#else
+#define debug(format, arg...) do {} while (0)
+#endif

please just use the existing prdebug() thing for this, no need to invent your own ;)

Quoted 5 lines

Couldn't find any info on that one, are you sure you spelled it correctly?

Quoted 1 line

#ifdef DEBUG
#define pr_debug(fmt,arg...) \
printk(KERN_DEBUG fmt,##arg)
#else

#define pr_debug(fmt,arg...) \
        do { } while (0)

#endif

in linux/kernel.h

Quoted 2 lines

Well, I don't know. When should EXPORT_SYMBOLs be EXPORT_SYMBOL_GPLs?

if it's linux-only code or otherwise very internal, _GPL is usually the right thing

Quoted 4 lines
Quoted 2 lines

hmmm stack space?

I count 76 bytes (x86), is that too much?

it's sort of ok, just make sure it doesn't grow more

Quoted 9 lines
Quoted 3 lines

that is almost always a wrong return value

It's returned when the device is mem-capable but driver doesn't implement set_gain() but sets FF_GAIN or when driver doesn't implement set_autocenter() but sets FF_AUTOCENTER. But yes, if that happens, it's a driver bug, so maybe this is not correct use for -ENOSYS. Probably there should be BUG() too here.

-EINVAL or so would be better; -ENOSYS basically is "not implemented system call", which is totally off topic in this context

Quoted 15 lines
Quoted 14 lines

Review

Quoted 10 lines
(quoted diff) +9 -0
+	if (test_bit(FF_CONSTANT, dev->ff->flags))
+		set_bit(FF_CONSTANT, dev->ffbit);
+	if (test_bit(FF_SPRING, dev->ff->flags))
+		set_bit(FF_SPRING, dev->ffbit);
+	if (test_bit(FF_FRICTION, dev->ff->flags))
+		set_bit(FF_FRICTION, dev->ffbit);
+	if (test_bit(FF_DAMPER, dev->ff->flags))
+		set_bit(FF_DAMPER, dev->ffbit);
+	if (test_bit(FF_INERTIA, dev->ff->flags))

are you really sure you need atomic set_bit()'s here?? if so.. I think you have a race ;)

Quoted 1 line

Well, I'm not. Is there an alternative?

__set_bit() is not atomic, and thus a lot faster if you don't need atomic behavior..