From patchwork Sun Dec 28 16:07:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aniroop Mathur X-Patchwork-Id: 5545641 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AC540BF6C3 for ; Sun, 28 Dec 2014 16:07:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E8A520149 for ; Sun, 28 Dec 2014 16:07:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 485FF2011B for ; Sun, 28 Dec 2014 16:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751844AbaL1QHs (ORCPT ); Sun, 28 Dec 2014 11:07:48 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:59794 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751809AbaL1QHr (ORCPT ); Sun, 28 Dec 2014 11:07:47 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so15939284pad.37; Sun, 28 Dec 2014 08:07:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=yOpABb+uFsVudMH2nYW1lpsqFm610W8fA3VCrMFIFX8=; b=RZcs8YQ4qYhjPmlqmMR6FXFaikzGdPTuRenYSdY1HfDrQmEwnOOcGlVBxtrO1XxrJs swjEBeYfAo0re4V0OA9i1zKesLDzs1mhJk2Oi8TIXXihcnyFJ7d9ljZP21p6NM0q6Qc2 mA8EBVxnbFpQaBHu/Qc8VInMtKQK+g1Ry3evVfFkLIuaQtdx/Rq/L67NVfLDK1WOUyEx BJQMvMG+NdSFGblKzA52VtCsD0lA53Pr6l/WHw0va/xMQRuOdqhTP9DCet0D5GZdGEQ/ HgLjHaPyEhPUD8VvxJ+s937grNyPUr9b5bxZdQMrYLxUhVUot0OUuRpAZF0JQe8Mhvqa Xwrg== X-Received: by 10.66.184.175 with SMTP id ev15mr50444475pac.78.1419782866694; Sun, 28 Dec 2014 08:07:46 -0800 (PST) Received: from localhost.localdomain ([115.118.72.223]) by mx.google.com with ESMTPSA id w8sm33257928pbt.71.2014.12.28.08.07.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Dec 2014 08:07:45 -0800 (PST) From: Aniroop Mathur To: , , Cc: , Subject: [PATCH] hid: Initialize battery_no to -1 & correct its format string Date: Sun, 28 Dec 2014 21:37:52 +0530 Message-Id: <1419782872-2991-1-git-send-email-aniroop.mathur@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Aniroop Mathur This patch initializes battery_no to -1 to avoid extra subtraction operation performed everytime wacom battery is initialized and correct format string of unsigned long from %ld to %lu. Signed-off-by: Aniroop Mathur --- drivers/hid/wacom_sys.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index 129fd33..4b5ff84 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -919,17 +919,17 @@ static int wacom_ac_get_property(struct power_supply *psy, static int wacom_initialize_battery(struct wacom *wacom) { - static atomic_t battery_no = ATOMIC_INIT(0); + static atomic_t battery_no = ATOMIC_INIT(-1); int error; unsigned long n; if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) { - n = atomic_inc_return(&battery_no) - 1; + n = atomic_inc_return(&battery_no); wacom->battery.properties = wacom_battery_props; wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props); wacom->battery.get_property = wacom_battery_get_property; - sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n); + sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%lu", n); wacom->battery.name = wacom->wacom_wac.bat_name; wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY; wacom->battery.use_for_apm = 0; @@ -937,7 +937,7 @@ static int wacom_initialize_battery(struct wacom *wacom) wacom->ac.properties = wacom_ac_props; wacom->ac.num_properties = ARRAY_SIZE(wacom_ac_props); wacom->ac.get_property = wacom_ac_get_property; - sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n); + sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%lu", n); wacom->ac.name = wacom->wacom_wac.ac_name; wacom->ac.type = POWER_SUPPLY_TYPE_MAINS; wacom->ac.use_for_apm = 0;