From patchwork Thu Mar 26 21:46:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 46393 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B79FB21584 for ; Thu, 26 Mar 2015 21:46:51 +0000 (UTC) Received: by labcd2 with SMTP id cd2sf8582695lab.3 for ; Thu, 26 Mar 2015 14:46:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=1urjHSwirIDWyXGj2A5C8GIXreeCBaf5esAS5vsmczI=; b=GsPNR28L7WDNcQsmjuOc1tvLR6Ryv0JqNaic+ISmgLODZni5WLs/xlXbIOXp+vMKo9 ucq5e56Wvi1G7IDXR2JkuYu+bwfSeH/DeW6974gAVXrJnIDPLRNUO98SEDVyjzCIj+0L RoNLzCf2wvFhqN8wTlz0lN5vfDFhNlXtHPbUC95F7tppE9nBblSv0wBx1elWM/Jmxc9P t93Lquby48BLIFZrLp75WWCMZhcf31BxY4g8VlWwY/J0RHIt66er/yTiKYNH5R/v1G9e QuPVqAL9hngC4xIUgUcjjYzJ6fDvjcAnUbI8APCefSUpl2+a3rkiRa+Hy+d7NUDD1C5b rL4g== X-Gm-Message-State: ALoCoQmNBV0Nw61rSjvwhzFJtORiS8wADH5qf7bl1wbUnAVEIKRdsgv7kWoR4tZrnLHkpqYe7KKt X-Received: by 10.112.180.74 with SMTP id dm10mr3909618lbc.11.1427406410693; Thu, 26 Mar 2015 14:46:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.97 with SMTP id it1ls313260lac.1.gmail; Thu, 26 Mar 2015 14:46:50 -0700 (PDT) X-Received: by 10.112.46.74 with SMTP id t10mr14940898lbm.73.1427406410370; Thu, 26 Mar 2015 14:46:50 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id db5si39819lad.22.2015.03.26.14.46.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Mar 2015 14:46:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbcgn8 with SMTP id gn8so50879403lbc.2 for ; Thu, 26 Mar 2015 14:46:49 -0700 (PDT) X-Received: by 10.112.212.106 with SMTP id nj10mr15197937lbc.36.1427406409761; Thu, 26 Mar 2015 14:46:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp877312lbq; Thu, 26 Mar 2015 14:46:48 -0700 (PDT) X-Received: by 10.70.94.169 with SMTP id dd9mr30201891pdb.34.1427406408029; Thu, 26 Mar 2015 14:46:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn8si46088pbc.124.2015.03.26.14.46.46; Thu, 26 Mar 2015 14:46:48 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753316AbbCZVql (ORCPT + 27 others); Thu, 26 Mar 2015 17:46:41 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:35291 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753111AbbCZVqj (ORCPT ); Thu, 26 Mar 2015 17:46:39 -0400 Received: by pdbop1 with SMTP id op1so75147280pdb.2 for ; Thu, 26 Mar 2015 14:46:37 -0700 (PDT) X-Received: by 10.70.48.97 with SMTP id k1mr29954574pdn.159.1427406397580; Thu, 26 Mar 2015 14:46:37 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPSA id n10sm29587pdp.18.2015.03.26.14.46.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2015 14:46:36 -0700 (PDT) From: Mathieu Poirier To: alexander.shishkin@linux.intel.com Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, peter.lachner@intel.com, norbert.schulz@intel.com, keven.boell@intel.com, yann.fouassier@intel.com, laurent.fert@intel.com, linux-api@vger.kernel.org, kaixu.xia@linaro.org, zhang.chunyan@linaro.org, mathieu.poirier@linaro.org Subject: [PATCH] stm class: Adding master and channel parameter to ioctl function Date: Thu, 26 Mar 2015 15:46:11 -0600 Message-Id: <1427406371-6699-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mathieu.poirier@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hey Alex, Have a look at the following patch and see if you agree with my approach. If so simply add the code to a third version. Thanks, Mathieu >From 70b4709b668ef59b303dabeff73ed850a4980cfc Mon Sep 17 00:00:00 2001 From: Mathieu Poirier Date: Thu, 26 Mar 2015 15:33:03 -0600 Subject: [PATCH] stm class: Adding master and channel parameter to ioctl function Just like the "write" function, architecture specific device need to know about master and channels to do the correct operations on a ioctl call. Since this information is embedded in the stm_file structure that is private to the stm class core, adding extra parameters to convey the values is simple and clean. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/stm/core.c | 12 ++++++++++-- include/linux/stm.h | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/stm/core.c b/drivers/hwtracing/stm/core.c index 9e82634590dc..ca71b06bbfea 100644 --- a/drivers/hwtracing/stm/core.c +++ b/drivers/hwtracing/stm/core.c @@ -511,9 +511,17 @@ stm_char_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return stm_char_policy_get_ioctl(stmf, (void __user *)arg); default: - if (stm_data->ioctl) - err = stm_data->ioctl(stm_data, cmd, arg); + if (stm_data->ioctl) { + /* users shouldn't call device specific ioctl before + * getting a channel using the proper potocol + */ + if (!stmf->output.nr_chans) + return -EINVAL; + err = stm_data->ioctl(stm_data, stmf->output.master, + stmf->output.channel, cmd, arg); + + } break; } diff --git a/include/linux/stm.h b/include/linux/stm.h index 976c94d8f17f..84dd83c47fe7 100644 --- a/include/linux/stm.h +++ b/include/linux/stm.h @@ -62,8 +62,9 @@ struct stm_data { unsigned int); void (*unlink)(struct stm_data *, unsigned int, unsigned int); - long (*ioctl)(struct stm_data *, unsigned int, - unsigned long); + long (*ioctl)(struct stm_data *, + unsigned int, unsigned int, + unsigned int, unsigned long); }; int stm_register_device(struct device *parent, struct stm_data *stm_data,