From patchwork Fri Feb 26 17:59:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jouni Malinen X-Patchwork-Id: 8440531 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@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 6F187C0553 for ; Fri, 26 Feb 2016 17:59:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95E3D203B6 for ; Fri, 26 Feb 2016 17:59:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EA6C202E6 for ; Fri, 26 Feb 2016 17:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754823AbcBZR7b (ORCPT ); Fri, 26 Feb 2016 12:59:31 -0500 Received: from mail.w1.fi ([212.71.239.96]:32842 "EHLO li674-96.members.linode.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139AbcBZR7b (ORCPT ); Fri, 26 Feb 2016 12:59:31 -0500 Received: from jm (87-93-72-73.bb.dnainternet.fi [87.93.72.73]) by li674-96.members.linode.com (Postfix) with ESMTPSA id 61BBE11972; Fri, 26 Feb 2016 17:59:26 +0000 (UTC) Received: by jm (sSMTP sendmail emulation); Fri, 26 Feb 2016 19:59:25 +0200 Date: Fri, 26 Feb 2016 19:59:25 +0200 From: Jouni Malinen To: =?utf-8?B?Sm/Do28=?= Paulo Rechi Vita Cc: Johannes Berg , "David S. Miller" , Darren Hart , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessm.com, =?utf-8?B?Sm/Do28=?= Paulo Rechi Vita Subject: Re: [PATCHv2 08/10] rfkill: Use switch to demux userspace operations Message-ID: <20160226175925.GA9331@w1.fi> References: <1456159001-20307-1-git-send-email-jprvita@endlessm.com> <1456159001-20307-9-git-send-email-jprvita@endlessm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1456159001-20307-9-git-send-email-jprvita@endlessm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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=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 On Mon, Feb 22, 2016 at 11:36:39AM -0500, João Paulo Rechi Vita wrote: > Using a switch to handle different ev.op values in rfkill_fop_write() > makes the code easier to extend, as out-of-range values can always be > handled by the default case. This breaks rfkill.. There are automated test scripts for testing this area (and most of Wi-Fi for that matter. It would be nice if these were used for changes before they get contributed upstream.. http://buildbot.w1.fi/hwsim/ This specific commit broke all the rfkill_* test cases because of following: > diff --git a/net/rfkill/core.c b/net/rfkill/core.c > @@ -1199,29 +1200,32 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf, > - list_for_each_entry(rfkill, &rfkill_list, node) { > - if (rfkill->idx != ev.idx && ev.op != RFKILL_OP_CHANGE_ALL) > - continue; > - > - if (rfkill->type != ev.type && ev.type != RFKILL_TYPE_ALL) > - continue; Note that RFKILL_TYPE_ALL here.. > + list_for_each_entry(rfkill, &rfkill_list, node) > + if (rfkill->type == ev.type || > + ev.type == RFKILL_TYPE_ALL) > + rfkill_set_block(rfkill, ev.soft); It was included for RFKILL_OP_CHANGE_ALL. > + case RFKILL_OP_CHANGE: > + list_for_each_entry(rfkill, &rfkill_list, node) > + if (rfkill->idx == ev.idx && rfkill->type == ev.type) > + rfkill_set_block(rfkill, ev.soft); but not for RFKILL_OP_CHANGE.. This needs following to work: diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 59ff92d..c4bbd19 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -1239,7 +1239,9 @@ static ssize_t rfkill_fop_write(struct file *file, const char __user *buf, break; case RFKILL_OP_CHANGE: list_for_each_entry(rfkill, &rfkill_list, node) - if (rfkill->idx == ev.idx && rfkill->type == ev.type) + if (rfkill->idx == ev.idx && + (rfkill->type == ev.type || + ev.type == RFKILL_TYPE_ALL)) rfkill_set_block(rfkill, ev.soft); ret = 0; break;