From patchwork Thu Jul 28 01:23:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9250521 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 87550607D8 for ; Thu, 28 Jul 2016 01:23:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 774D01FFBD for ; Thu, 28 Jul 2016 01:23:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B9CE254F7; Thu, 28 Jul 2016 01:23:25 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 B808A1FFBD for ; Thu, 28 Jul 2016 01:23:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758906AbcG1BXW (ORCPT ); Wed, 27 Jul 2016 21:23:22 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35427 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751229AbcG1BXV (ORCPT ); Wed, 27 Jul 2016 21:23:21 -0400 Received: by mail-pf0-f194.google.com with SMTP id h186so2700791pfg.2 for ; Wed, 27 Jul 2016 18:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=UZZXNVGFtjzoGfvVtqoDddsY7fd+b+UmfjHtKOMHKKQ=; b=nyr9ClKsTMaT+M96LtTUxiusqgYKXnZuHWCUGbWhndlDlsZkQOyBrJi5jlGO38faJX cAwhL1gCrfUPuQL7n8SlDEOUPjlnK3TUz/HDFp9e/qYkNOPFoxJrbZHLWL2gxHXJD/jf DvAoPjzv/Qscm3qMU/6hhcfqmdO07NsJMktjKW+hALD3KBc1EKhXc1u2YN98W4mYbX9e jyMCEPAGxA1QibKrQxz6HW8QcTDRfXTtekIhf0r1s/AMCYtM3mn7tBT8sbpBkGP3rN2x GN2Lc8PCldpbeNQYBj6ayzZ/PP4jbvPJnsYYViE50AC91l6+H5o8X7jJtAEx/ccE7rBt NyOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=UZZXNVGFtjzoGfvVtqoDddsY7fd+b+UmfjHtKOMHKKQ=; b=h3WZnWUEDF97lJ2kwQOxFBu0rLNJVGPIrXye2SD2jyXMF0sJDN91I4VvdAKcfqGGaV 1u9nsUuMTXHseYJk6t98MVkVqqdikvYBaPxf6HVKjd36vWVUE90OA+lpilNSs9bhn5oE fQKcaUlUhqzp/vG5uZOvF/V9lvwKKMnO6hvkpRF+E/raagB2LoDHUJVLlBalBOTWywgc EKblfmKsDQu7aCe2BuTpYCVp8igBdtmdmldWtzeGyZKPTSIa3ZbggL6tyXjBiYX1xe1P Ah3SyAM4ch0YWQyNLg2M7XWY6x35uvnroPHS6Y7ZlC+qcGJqIYdSBotXB8ROifFlq2dc D8Hg== X-Gm-Message-State: AEkooutB3sOARanxu/xse3g2dk2G3d0ec1Innd/ge7U4jFrxv4zBTvV1zPUslCu/2oGrWA== X-Received: by 10.98.80.29 with SMTP id e29mr54709834pfb.76.1469669000411; Wed, 27 Jul 2016 18:23:20 -0700 (PDT) Received: from [192.168.1.139] (c-24-16-1-64.hsd1.wa.comcast.net. [24.16.1.64]) by smtp.gmail.com with ESMTPSA id q14sm11951419pfi.76.2016.07.27.18.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jul 2016 18:23:19 -0700 (PDT) Subject: Re: [PATCH] Input: xpad - power off wireless 360 controllers on suspend To: Dmitry Torokhov References: <6203d65c-4e15-c44c-edc9-d47cc78f1c28@gmail.com> <20160727213222.GB24351@dtor-ws> <20160727213912.GD24351@dtor-ws> <8a8bea8a-69c4-3f2f-c32c-151b3076e7cb@gmail.com> <20160728000416.GE24351@dtor-ws> <4fdf587c-0d51-68ca-edc6-5978d9bfa0ca@gmail.com> <20160728002944.GF24351@dtor-ws> Cc: rojtberg@gmail.com, linux-input@vger.kernel.org From: Cameron Gutman Message-ID: Date: Wed, 27 Jul 2016 18:23:19 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160728002944.GF24351@dtor-ws> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 07/27/2016 05:29 PM, Dmitry Torokhov wrote: > On Wed, Jul 27, 2016 at 05:10:41PM -0700, Cameron Gutman wrote: >> On 07/27/2016 05:04 PM, Dmitry Torokhov wrote: >>> On Wed, Jul 27, 2016 at 04:24:06PM -0700, Cameron Gutman wrote: >>>> On 07/27/2016 02:39 PM, Dmitry Torokhov wrote: >>>>> On Wed, Jul 27, 2016 at 02:32:22PM -0700, Dmitry Torokhov wrote: >>>>>> On Mon, Jul 25, 2016 at 10:35:08PM -0700, Cameron Gutman wrote: >>>>>>> When the USB wireless adapter is suspended, the controllers >>>>>>> lose their connection. This causes them to start flashing >>>>>>> their LED rings and searching for the wireless adapter >>>>>>> again, wasting the controller's battery power. >>>>>>> >>>>>>> Instead, we will tell the controllers to power down when >>>>>>> we suspend. This mirrors the behavior of the controllers >>>>>>> when connected to the console itself and how the official >>>>>>> Xbox One wireless adapter behaves on Windows. >>>>>>> >>>>>>> Signed-off-by: Cameron Gutman >>>>>>> --- >>>>>>> This patch is independent of the other xpad patch [0] that I >>>>>>> submitted (and decided to wait on). It applies against >>>>>>> unmodified xpad.c in master. >>>>>>> >>>>>>> [0] http://www.spinics.net/lists/linux-input/msg46062.html >>>>>>> --- >>>>>>> drivers/input/joystick/xpad.c | 43 +++++++++++++++++++++++++++++++++++++++++++ >>>>>>> 1 file changed, 43 insertions(+) >>>>>>> >>>>>>> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c >>>>>>> index a529a45..3408019 100644 >>>>>>> --- a/drivers/input/joystick/xpad.c >>>>>>> +++ b/drivers/input/joystick/xpad.c >>>>>>> @@ -115,6 +115,10 @@ static bool sticks_to_null; >>>>>>> module_param(sticks_to_null, bool, S_IRUGO); >>>>>>> MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads"); >>>>>>> >>>>>>> +static bool disable_auto_poweroff; >>>>>>> +module_param(disable_auto_poweroff, bool, S_IRUGO); >>>>>>> +MODULE_PARM_DESC(disable_auto_poweroff, "Do not power off wireless controllers on suspend"); >>>>>> >>>>>> Why negating? Why not do >>>>>> >>>>>> static bool xpad_auto_poweroff = true; >>>>>> >>>>>> ? >>>>>> >>>>>> (No need to resubmit if agree/disagree, I can fix up on my side). >>>> >>>> Yeah, sounds fine to make it default Y and get rid of the negation. >>>> >>>> I'm fine with it if you want to make that change and apply it. See my >>>> comments below about the other issues. >>>> >>>>> >>>>> By the way, I think we can allow root writing to it, there is nothing >>>>> that stops us from changing behavior at runtime. >>>> >>>> Yep, I was following the convention of the existing module params. They >>>> can probably all be changed to allow root writing. >>> >>> My rule of thumb is we allow writing if behavior changes immediately. >>> The other parameters only affect devices that will be bound after the >>> parameter has been changed, which woudl be confusing. So they are RO and >>> you have to specify them at module load time. >>> >>> Thanks. >>> >> >> Sounds reasonable. Would you like to make the permission change also or >> do you prefer I resubmit the patch with those 2 modifications? > > No, I made them. If you have a moment please take a look at my "next" > branch on kernel.org. > I reviewed and tested your changes. I think you forgot to undo one of the negations. With the patch below applied on the commit in next, it works correctly. --- drivers/input/joystick/xpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 0c8d5c3..83af17a 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1631,7 +1631,7 @@ static int xpad_suspend(struct usb_interface *intf, pm_message_t message) * Unless explicitly disabled, power them down * so they don't just sit there flashing. */ - if (!auto_poweroff && xpad->pad_present) + if (auto_poweroff && xpad->pad_present) xpad360w_poweroff_controller(xpad); } else { mutex_lock(&input->mutex);