From patchwork Thu Sep 24 14:00:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7256931 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BDA419F32B for ; Thu, 24 Sep 2015 14:07:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4D11207C6 for ; Thu, 24 Sep 2015 14:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D35E1207A4 for ; Thu, 24 Sep 2015 14:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756530AbbIXOBm (ORCPT ); Thu, 24 Sep 2015 10:01:42 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:8846 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756189AbbIXOBX (ORCPT ); Thu, 24 Sep 2015 10:01:23 -0400 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NV6008MDPMAG170@mailout3.w1.samsung.com>; Thu, 24 Sep 2015 15:01:22 +0100 (BST) X-AuditID: cbfec7f5-f794b6d000001495-ed-560402317e31 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 21.E8.05269.13204065; Thu, 24 Sep 2015 15:01:21 +0100 (BST) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NV600IK6PLM8670@eusync4.samsung.com>; Thu, 24 Sep 2015 15:01:21 +0100 (BST) From: Andrzej Hajda To: linux-kernel@vger.kernel.org Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Mattia Dongili , Darren Hart , platform-driver-x86@vger.kernel.org Subject: [PATCH 14/19] sony-laptop: fix handling sony_nc_hotkeys_decode result Date: Thu, 24 Sep 2015 16:00:22 +0200 Message-id: <1443103227-25612-15-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1443103227-25612-1-git-send-email-a.hajda@samsung.com> References: <1443103227-25612-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4NV1DJpYwg1nnrCxurTvHarFxxnpW i66FBhaXd81hs1h75C67xaurq9ksVu95wezA7rF5hZZH2/J9LB59W1YxenzeJBfAEsVlk5Ka k1mWWqRvl8CVcXjqJZaC/9wVtw+tZWxgvMDZxcjJISFgIvH8zSI2CFtM4sK99WC2kMBSRomH q4W6GLmA7CYmibM3n7KCJNgENCX+br4JViQioCCxufcZK0gRs8B/Ronfi14ydzFycAgL+Elc eikPUsMioCqx9MgUdhCbV8BF4uLhh8wQy+QkTh6bDDaTEyj+duomJojFzhInjsxim8DIu4CR YRWjaGppckFxUnqukV5xYm5xaV66XnJ+7iZGSBh93cG49JjVIUYBDkYlHt6ZOsxhQqyJZcWV uYcYJTiYlUR4Od4DhXhTEiurUovy44tKc1KLDzFKc7AoifPO3PU+REggPbEkNTs1tSC1CCbL xMEp1cC40+mzikLV3z5BLtO3berXp1fpzF32/PmGCYZd03Z6K1z9dFvV5m3bNsbG8IT5e8vY DqdOWRz8VvqgtJ3BU5vJnws7+x3XXFS/ZvohNjjc25kr8NXMl84zczLjynTUn+41XMx4zGGL 0Fsl+8p5ly+590+co3VoR+tnZ6eAWQ8rRf6ntrudE/ZRYinOSDTUYi4qTgQAST2bZR8CAAA= Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function can return negative value. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 Signed-off-by: Andrzej Hajda --- Hi, To avoid problems with too many mail recipients I have sent whole patchset only to LKML. Anyway patches have no dependencies. Regards Andrzej --- drivers/platform/x86/sony-laptop.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c index aeb80d1..d8a2115 100644 --- a/drivers/platform/x86/sony-laptop.c +++ b/drivers/platform/x86/sony-laptop.c @@ -1204,6 +1204,8 @@ static void sony_nc_notify(struct acpi_device *device, u32 event) { u32 real_ev = event; u8 ev_type = 0; + int ret; + dprintk("sony_nc_notify, event: 0x%.2x\n", event); if (event >= 0x90) { @@ -1225,13 +1227,15 @@ static void sony_nc_notify(struct acpi_device *device, u32 event) case 0x0100: case 0x0127: ev_type = HOTKEY; - real_ev = sony_nc_hotkeys_decode(event, handle); + ret = sony_nc_hotkeys_decode(event, handle); - if (real_ev > 0) - sony_laptop_report_input_event(real_ev); - else + if (ret > 0) { + sony_laptop_report_input_event(ret); + real_ev = ret; + } else { /* restore the original event for reporting */ real_ev = event; + } break;