From patchwork Mon Dec 22 04:47:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 5525811 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9BD75BEEA8 for ; Mon, 22 Dec 2014 04:47:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3E4920165 for ; Mon, 22 Dec 2014 04:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6ACC200FF for ; Mon, 22 Dec 2014 04:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754131AbaLVErq (ORCPT ); Sun, 21 Dec 2014 23:47:46 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:50712 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753813AbaLVErp (ORCPT ); Sun, 21 Dec 2014 23:47:45 -0500 Received: by mail-pa0-f45.google.com with SMTP id lf10so5148518pab.18 for ; Sun, 21 Dec 2014 20:47:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=0u3TuuA1w5Bm3HXjSxIGfq5TNQDOfnc3um56h0dUh8o=; b=PL/VQCs5SxgNZWIdbC+g3jhaTJPJamIu7GxZ0tQOhaV+XwuomD0RctZISGcMx0IV6J MAhPESBzgmbX1U/FizkxuhR8axOE0on434AXY2H/WX9rl+hJD8KG5vDpqnH3N7ibP9tO LXgLhiXcBkWzaHe8MS445mpZXYMZBQQVfpqVjTEjh/hxg9r/+qoitKMi8zuvEsvjCQo6 G32apcMnj+7BfULzy0JCiZH07eNqHHoL/CB2CDvQuBQmY0sAmHYRTQOvgIp44D7iDrj0 KkX7tTgHTXCo/hi951o53ArT16N4oydpq+B68uvyfDp/9c6a9Pq4QLzBhhEyA7c7rDWi jFeA== X-Gm-Message-State: ALoCoQmhsrA2L5Adpxa5QXTpCiJ1KZGzRFPyICRFWxUbr2rLOggKdqXwKU5d5n2CjK+rZqls+tQd X-Received: by 10.66.224.201 with SMTP id re9mr32672160pac.138.1419223664755; Sun, 21 Dec 2014 20:47:44 -0800 (PST) Received: from [192.168.0.104] (218-164-101-144.dynamic.hinet.net. [218.164.101.144]) by mx.google.com with ESMTPSA id cf4sm15938732pbb.3.2014.12.21.20.47.42 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Sun, 21 Dec 2014 20:47:44 -0800 (PST) Message-ID: <1419223660.22487.1.camel@phoenix> Subject: [PATCH] Input: regulator-haptic: Make regulator_haptic_set_voltage call regulator_haptic_toggle From: Axel Lin To: Dmitry Torokhov Cc: Pankaj Dubey , Chanwoo Choi , Hyunhee Kim , Kyungmin Park , Jaewon Kim , linux-input@vger.kernel.org Date: Mon, 22 Dec 2014 12:47:40 +0800 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 All the use cases in this driver has a regulator_haptic_toggle() call after regulator_haptic_set_voltage(). So make regulator_haptic_set_voltage() call regulator_haptic_toggle() to simplify the code. Signed-off-by: Axel Lin --- drivers/input/misc/regulator-haptic.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/input/misc/regulator-haptic.c b/drivers/input/misc/regulator-haptic.c index 9426221..5b18de3 100644 --- a/drivers/input/misc/regulator-haptic.c +++ b/drivers/input/misc/regulator-haptic.c @@ -76,6 +76,8 @@ static int regulator_haptic_set_voltage(struct regulator_haptic *haptic, return error; } + regulator_haptic_toggle(haptic, !!magnitude); + return 0; } @@ -84,7 +86,6 @@ static void regulator_haptic_work(struct work_struct *work) struct regulator_haptic *haptic = container_of(work, struct regulator_haptic, work); unsigned int magnitude; - int error; mutex_lock(&haptic->mutex); @@ -93,12 +94,7 @@ static void regulator_haptic_work(struct work_struct *work) magnitude = ACCESS_ONCE(haptic->magnitude); - error = regulator_haptic_set_voltage(haptic, magnitude); - if (error) - goto out; - - regulator_haptic_toggle(haptic, magnitude != 0); - + regulator_haptic_set_voltage(haptic, magnitude); out: mutex_unlock(&haptic->mutex); } @@ -123,7 +119,6 @@ static void regulator_haptic_close(struct input_dev *input) cancel_work_sync(&haptic->work); regulator_haptic_set_voltage(haptic, 0); - regulator_haptic_toggle(haptic, false); } static int __maybe_unused @@ -225,7 +220,6 @@ static int __maybe_unused regulator_haptic_suspend(struct device *dev) return error; regulator_haptic_set_voltage(haptic, 0); - regulator_haptic_toggle(haptic, false); haptic->suspended = true; @@ -245,10 +239,8 @@ static int __maybe_unused regulator_haptic_resume(struct device *dev) haptic->suspended = false; magnitude = ACCESS_ONCE(haptic->magnitude); - if (magnitude) { + if (magnitude) regulator_haptic_set_voltage(haptic, magnitude); - regulator_haptic_toggle(haptic, true); - } mutex_unlock(&haptic->mutex);