From patchwork Mon Jun 26 17:26:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AbdAllah-MEZITI X-Patchwork-Id: 9810137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2EFD60209 for ; Mon, 26 Jun 2017 17:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF25226E55 for ; Mon, 26 Jun 2017 17:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD91D27D4A; Mon, 26 Jun 2017 17:26:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48FF726E55 for ; Mon, 26 Jun 2017 17:26:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751403AbdFZR0e (ORCPT ); Mon, 26 Jun 2017 13:26:34 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35775 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751101AbdFZR0d (ORCPT ); Mon, 26 Jun 2017 13:26:33 -0400 Received: by mail-wm0-f66.google.com with SMTP id 131so1448407wmq.2; Mon, 26 Jun 2017 10:26:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=z9haiYcnYa2qZO/vNoAPuDpKnvn1lOg1KFQ1nw+srjE=; b=NkhUa+LEM1UIBBi2tgKv6yioObL+bEv4y0f+McslG6+DxuwgsWyy2/aP4odtcFCK/q 0Ma+5MxyEkkRoDjYuAKl8bfSV7oQjn4goFTg/1d4nj8gh3F0f8EtTIANglsQaflW1IwK mkzcYbft7OdWT0lGPkWJM1GpmYdouPupAQyRze27cMxI2aUBFZCSGHH/wIe0fOEhgvBB rW1o0EV9yZ1Rd4EtO+TuuKD8X0R5gqVBIJfUi67N5BtQU7cxvQt03Ot/ehQq5qHqyRT5 zV+wBsEciqdhMqugF/7jq/DaROTKbdD0aEtEN117YJZLtkAZTR8zPeFs7XpzBSuQ+5K2 I8tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=z9haiYcnYa2qZO/vNoAPuDpKnvn1lOg1KFQ1nw+srjE=; b=HJfHb+fLsyRXNr6bVVA5j2uNChAyCjVKfXxAEo0Qr/XwOi670jYM0g8Q/k7Hym9emf y1a9OAm/I9enBUhGqf+KsHYjPCSnkQHSJVdFiyasjPALICMNQvdc0u1mi0vg1hA2l2La kWlWgfVNQDYovhnlg6kQM+WmsRTbQB2df01bhqmFveG7qlWeuQbzt3zRF4cMRmZLjdEl vvSSq5mTOQoiuf5pbTaLY8L9oLrT/ztDPDjgQioUzp2Hr943Jy32Hmo61b6fkPlYrqiI dl52pY5pqTcbIn2tZv6supqxOUJpVQMZsvq2tloUh4kQ5VAAD0cWJNOdMy5TSpILLOFD MzaQ== X-Gm-Message-State: AKS2vOyLuv0rfpfjx+6wZnDzZsodwDXvRvusZpyDP7gqMCGt438HPasZ 7i0BTqh5VHhNDw== X-Received: by 10.28.206.202 with SMTP id e193mr505981wmg.0.1498497992197; Mon, 26 Jun 2017 10:26:32 -0700 (PDT) Received: from localhost.localdomain (bty91-h01-176-179-209-84.dsl.sta.abo.bbox.fr. [176.179.209.84]) by smtp.gmail.com with ESMTPSA id y2sm91668wmy.29.2017.06.26.10.26.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Jun 2017 10:26:31 -0700 (PDT) From: AbdAllah-MEZITI To: sudipm.mukherjee@gmail.com Cc: AbdAllah MEZITI , Teddy Wang , Greg Kroah-Hartman , linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: sm750fb: always take the lock Date: Mon, 26 Jun 2017 19:26:19 +0200 Message-Id: <1498497981-3240-1-git-send-email-abdallah.meziti.pro@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch - Always take the lock: The current code only takes the lock if multiple instances are in use. This is error-prone, and confuses static analyzers. As taking the lock in case of a single instance is harmless and cheap, change the code to always take the lock. - That also fix the sparse warning: drivers/staging/sm750fb/sm750.c:159:13: warning: context imbalance in 'lynxfb_ops_fillrect' - different lock contexts for basic block drivers/staging/sm750fb/sm750.c:231:9: warning: context imbalance in 'lynxfb_ops_copyarea' - different lock contexts for basic block drivers/staging/sm750fb/sm750.c:235:13: warning: context imbalance in 'lynxfb_ops_imageblit' - different lock contexts for basic block Signed-off-by: AbdAllah MEZITI v2: - add and fix the changelog text. --- drivers/staging/sm750fb/sm750.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 386d4ad..4a22190 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -186,16 +186,14 @@ static void lynxfb_ops_fillrect(struct fb_info *info, * If not use spin_lock,system will die if user load driver * and immediately unload driver frequently (dual) */ - if (sm750_dev->fb_count > 1) - spin_lock(&sm750_dev->slock); + spin_lock(&sm750_dev->slock); sm750_dev->accel.de_fillrect(&sm750_dev->accel, base, pitch, Bpp, region->dx, region->dy, region->width, region->height, color, rop); - if (sm750_dev->fb_count > 1) - spin_unlock(&sm750_dev->slock); + spin_unlock(&sm750_dev->slock); } static void lynxfb_ops_copyarea(struct fb_info *info, @@ -220,16 +218,14 @@ static void lynxfb_ops_copyarea(struct fb_info *info, * If not use spin_lock, system will die if user load driver * and immediately unload driver frequently (dual) */ - if (sm750_dev->fb_count > 1) - spin_lock(&sm750_dev->slock); + spin_lock(&sm750_dev->slock); sm750_dev->accel.de_copyarea(&sm750_dev->accel, base, pitch, region->sx, region->sy, base, pitch, Bpp, region->dx, region->dy, region->width, region->height, HW_ROP2_COPY); - if (sm750_dev->fb_count > 1) - spin_unlock(&sm750_dev->slock); + spin_unlock(&sm750_dev->slock); } static void lynxfb_ops_imageblit(struct fb_info *info, @@ -269,8 +265,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info, * If not use spin_lock, system will die if user load driver * and immediately unload driver frequently (dual) */ - if (sm750_dev->fb_count > 1) - spin_lock(&sm750_dev->slock); + spin_lock(&sm750_dev->slock); sm750_dev->accel.de_imageblit(&sm750_dev->accel, image->data, image->width >> 3, 0, @@ -278,8 +273,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info, image->dx, image->dy, image->width, image->height, fgcol, bgcol, HW_ROP2_COPY); - if (sm750_dev->fb_count > 1) - spin_unlock(&sm750_dev->slock); + spin_unlock(&sm750_dev->slock); } static int lynxfb_ops_pan_display(struct fb_var_screeninfo *var,