Skip to contentSkip to conversation

cdc-acm: Convert acm_minors to XArray

PATCH New Oliver Neukum 1 participant 1 message Mar 19, 2019 USB

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 cdc-acm: Convert acm_minors to XArray

Quoted 2 lines · Greg KH
Quoted 1 line · Matthew Wilcox

[..]

Quoted 5 lines
Quoted 5 lines

static int acm_alloc_minor(struct acm *acm)
{

(quoted diff) +0 -3
-	int minor;
-
-	mutex_lock(&acm_minors_lock);
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +2 -4
-	minor = idr_alloc(&acm_minors, acm, 0, ACM_TTY_MINORS, GFP_KERNEL);
-	mutex_unlock(&acm_minors_lock);
-
-	return minor;
+	return xa_alloc(&acm_minors, &acm->minor, acm,
+			XA_LIMIT(0, ACM_TTY_MINORS - 1), GFP_KERNEL);

So, the only thing "better" here is that you don't need a lock anymore?

Once this is accepted I can reduce the locking to a per instance spinlock. But to start with a straight conversion is best.

Regards
Oliver