Re: [PATCH 6/6] staging: sm750fb: Spinlock and unlock in the same block

From
Dan Carpenter <hidden>
Date
2015-03-11 09:09:36
Also in
lkml
Reply to
Lorenzo Stoakes, 2015-03-11
On Wed, Mar 11, 2015 at 01:28:45AM +0000, Lorenzo Stoakes wrote:
-static inline void myspin_lock(spinlock_t * sl){
-	struct lynx_share * share;
-	share = container_of(sl,struct lynx_share,slock);
-	if(share->dual){
-		spin_lock(sl);
-	}
-}
Yes, good.  We all hate locking wrappers but these are worse than
normal.
quoted hunk ↗ jump to hunk
+	/* if not use spin_lock,system will die if user load driver
+	 * and immediatly unload driver frequently (dual)*/
+	if (share->dual) {
+		spin_lock(&share->slock);
+		share->accel.de_fillrect(&share->accel,
+					base,pitch,Bpp,
+					region->dx,region->dy,
+					region->width,region->height,
+					color,rop);
+		spin_unlock(&share->slock);
+	} else
+		share->accel.de_fillrect(&share->accel,
+					base,pitch,Bpp,
+					region->dx,region->dy,
+					region->width,region->height,
+					color,rop);
 }
No.  You've made the code uglier to work around Sparse stupidness.  Also
the braces are not according to kernel style.

	if (share->dual)
		spin_lock(&share->slock);

	share->accel.de_fillrect(&share->accel,
				 base,pitch,Bpp,
				 region->dx,region->dy,
				 region->width,region->height,
				 color,rop);

	if (share->dual)
		spin_unlock(&share->slock);

Sparse will still complain but no one cares.

regards,
Thread (18 messages) 18 messages, 3 authors, last reply 2015-03-11
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help