From patchwork Sat Dec 21 23:05:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 3394001 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 52F61C0D4A for ; Sat, 21 Dec 2013 23:05:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47C412066F for ; Sat, 21 Dec 2013 23:05:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C48C2066D for ; Sat, 21 Dec 2013 23:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755331Ab3LUXFI (ORCPT ); Sat, 21 Dec 2013 18:05:08 -0500 Received: from smtprelay0239.hostedemail.com ([216.40.44.239]:42833 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754054Ab3LUXFG (ORCPT ); Sat, 21 Dec 2013 18:05:06 -0500 Received: from filter.hostedemail.com (ff-bigip1 [10.5.19.254]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id E90966B762; Sat, 21 Dec 2013 23:05:04 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::::, RULES_HIT:41:69:355:379:541:599:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3354:3865:3870:4321:4605:5007:6120:7652:7875:9592:10004:10400:10848:11026:11658:11914:12043:12294:12296:12438:12517:12519:12555:12679:12683, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0 X-HE-Tag: glove73_f0822ae5344f X-Filterd-Recvd-Size: 4240 Received: from [192.168.1.157] (pool-96-251-49-11.lsanca.fios.verizon.net [96.251.49.11]) (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA; Sat, 21 Dec 2013 23:05:03 +0000 (UTC) Message-ID: <1387667101.22671.6.camel@joe-AO722> Subject: Re: [RFC v2] ff-memless-next driver From: Joe Perches To: Michal =?ISO-8859-1?Q?Mal=FD?= Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, anssi.hannula@iki.fi, elias.vds@gmail.com Date: Sat, 21 Dec 2013 15:05:01 -0800 In-Reply-To: <2287724.uNI0tVeDgp@geidi-prime> References: <2287724.uNI0tVeDgp@geidi-prime> X-Mailer: Evolution 3.8.4-0ubuntu1 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=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Refactoring can help reduce the line lengths. For example: Move the get_envelope function. Use get_envelope in set_envelope_times. --- drivers/input/ff-memless-next.c | 58 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 31 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/ff-memless-next.c b/drivers/input/ff-memless-next.c index 722601a..73e1127 100644 --- a/drivers/input/ff-memless-next.c +++ b/drivers/input/ff-memless-next.c @@ -104,34 +104,46 @@ static int mlnx_upload_conditional(struct mlnx_device *mlnxdev, return mlnxdev->control_effect(mlnxdev->dev, mlnxdev->private, &ecmd); } +static const struct ff_envelope *mlnx_get_envelope(const struct ff_effect *effect) +{ + static const struct ff_envelope empty; + + switch (effect->type) { + case FF_CONSTANT: + return &effect->u.constant.envelope; + case FF_PERIODIC: + return &effect->u.periodic.envelope; + case FF_RAMP: + return &effect->u.ramp.envelope; + default: + return ∅ + } +} + static void mlnx_set_envelope_times(struct mlnx_effect *mlnxeff) { const struct ff_effect *effect = &mlnxeff->effect; + const struct ff_envelope *env; switch (effect->type) { - case FF_CONSTANT: - if (effect->u.constant.envelope.attack_length) - mlnxeff->attack_stop = mlnxeff->begin_at + msecs_to_jiffies(effect->u.constant.envelope.attack_length); - if (effect->replay.length && effect->u.constant.envelope.fade_length) - mlnxeff->fade_begin = mlnxeff->stop_at - msecs_to_jiffies(effect->u.constant.envelope.fade_length); - break; case FF_PERIODIC: pr_debug("Phase: %u, Offset: %d\n", effect->u.periodic.phase, effect->u.periodic.offset); - if (effect->u.periodic.envelope.attack_length) - mlnxeff->attack_stop = mlnxeff->begin_at + msecs_to_jiffies(effect->u.periodic.envelope.attack_length); - if (effect->replay.length && effect->u.periodic.envelope.fade_length) - mlnxeff->fade_begin = mlnxeff->stop_at - msecs_to_jiffies(effect->u.periodic.envelope.fade_length); break; + case FF_CONSTANT: case FF_RAMP: - if (effect->u.ramp.envelope.attack_length) - mlnxeff->attack_stop = mlnxeff->begin_at + msecs_to_jiffies(effect->u.ramp.envelope.attack_length); - if (effect->replay.length && effect->u.ramp.envelope.fade_length) - mlnxeff->fade_begin = mlnxeff->stop_at - msecs_to_jiffies(effect->u.ramp.envelope.fade_length); break; default: - break; + return; } + + env = mlnx_get_envelope(effect); + if (env->attack_length) + mlnxeff->attack_stop = mlnxeff->begin_at + + msecs_to_jiffies(env->attack_length); + if (effect->replay.length && env->fade_length) + mlnxeff->fade_begin = mlnxeff->stop_at - + msecs_to_jiffies(env->fade_length); } static void mlnx_set_trip_times(struct mlnx_effect *mlnxeff, @@ -185,22 +197,6 @@ static void mlnx_stop_effect(struct mlnx_device *mlnxdev, } } -static const struct ff_envelope *mlnx_get_envelope(const struct ff_effect *effect) -{ - static const struct ff_envelope empty; - - switch (effect->type) { - case FF_CONSTANT: - return &effect->u.constant.envelope; - case FF_PERIODIC: - return &effect->u.periodic.envelope; - case FF_RAMP: - return &effect->u.ramp.envelope; - default: - return ∅ - } -} - static s32 mlnx_apply_envelope(const struct mlnx_effect *mlnxeff, const s32 level) {