Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp259093pxa; Tue, 4 Aug 2020 23:48:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg2pEe2FpMmjyIylaQ2s+mA5tQD5dcgrPECVwaeLzJbb+RbQASqiyihuF4oFq0MfIPlKgB X-Received: by 2002:a17:906:ca8c:: with SMTP id js12mr1839220ejb.195.1596610117173; Tue, 04 Aug 2020 23:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596610117; cv=none; d=google.com; s=arc-20160816; b=rNdGZD87Ef+aSDHxKLxOn6R7L/WnaeTRe4Lgsaz+vNIHNxzTsgpI3D0WN8xSIh+XKX I8A0K3dLfBAxy5cHiCJp96/AmNsnlQdINyIRh3reXpwd66IqE+YI+2jFxaM78xWYceD7 J7C3cxq4YgCRW7sx+6cWr3kihqBFoXVmR2C/BP49eV3A51aVkhF5uJEdIp7MZBaHIOej oRSHkrb9geEWRfQYLSiXZNjvBW22B4aux7ApmewsTBBtdxDtWEJ5HCsFpmHkrcy/i6Bx r3ANpAwZyW53v8kftd9o5yMP7Tcu7KVGranLgsSgFv5riivmvFeZTRofeD43StNPHSm6 2Zeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=85nlV2e7JP99BfqbhsA+WDHBOWJz3l3JyYFvvTJcmxs=; b=XipBDWPHa32v42tiaGLkvd84AqId96o6Ofv8NxIkzaBW2fHe0WzU6aOt+/+H4XIVxl 6K+MfZR7e4xAFe0rg145JE5jZYREcmfqSuUIijWDw1t8gxQwJeEZIp4llb4KVNVIw7OK fVCvNie/WQvCfn7GxzgTDTZ0AWRuvT0lkuDGnjHxCSZ0aRSUxZ23929adF2RLHJNF0xg pcue+CloBDnAkbUwX1QM42/RIuYr9hsEpW3eY9SZfEruT+Yp4ty3clBm1VV4Ol78IWY3 jAHiSYGkPofxJIhUWFkFnFCBYQ9/NxbfePf8ktD0wTNdXB1i45aBP1HOhKkncaCS0IeL 0rTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I4QzF2WN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c18si692799edr.134.2020.08.04.23.48.14; Tue, 04 Aug 2020 23:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I4QzF2WN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726459AbgHEGqG (ORCPT + 99 others); Wed, 5 Aug 2020 02:46:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:38588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgHEGqG (ORCPT ); Wed, 5 Aug 2020 02:46:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DCFD52076E; Wed, 5 Aug 2020 06:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596609965; bh=b/ISxBJkxTj71SxW9Fvr39ExmksIlTwwn0gnSM6clBk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I4QzF2WN1uR4Z537dtQAMIrYpcpzFg0eobJFDRxiG8CMXTUzn6O2xUrDeRIpkwYGE J1OZMNIVH4lX5U5RxyUXDJqYRQlslQwwvb6WPmhr+pIPJ3UxRe2gSoRi2P/Ja/zkwS nBFUh5NAzgcfQU0SCyVDB+kYTD5d9Ca1CezbuyvI= Date: Wed, 5 Aug 2020 08:46:22 +0200 From: gregkh To: "Eads, Gage" Cc: Arnd Bergmann , "linux-kernel@vger.kernel.org" , "Karlsson, Magnus" , "Topel, Bjorn" Subject: Re: [PATCH 04/20] dlb2: add device ioctl layer and first 4 ioctls Message-ID: <20200805064622.GA608152@kroah.com> References: <20200712134331.8169-1-gage.eads@intel.com> <20200712134331.8169-5-gage.eads@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 04, 2020 at 10:20:47PM +0000, Eads, Gage wrote: > > > +/* [7:0]: device revision, [15:8]: device version */ > > > +#define DLB2_SET_DEVICE_VERSION(ver, rev) (((ver) << 8) | (rev)) > > > + > > > +static int dlb2_ioctl_get_device_version(struct dlb2_dev *dev, > > > + unsigned long user_arg, > > > + u16 size) > > > +{ > > > + struct dlb2_get_device_version_args arg; > > > + struct dlb2_cmd_response response; > > > + int ret; > > > + > > > + dev_dbg(dev->dlb2_device, "Entering %s()\n", __func__); > > > + > > > + response.status = 0; > > > + response.id = DLB2_SET_DEVICE_VERSION(2, DLB2_REV_A0); > > > + > > > + ret = dlb2_copy_from_user(dev, user_arg, size, &arg, sizeof(arg)); > > > + if (ret) > > > + return ret; > > > + > > > + ret = dlb2_copy_resp_to_user(dev, arg.response, &response); > > > > Better avoid any indirect pointers. As you always return a constant > > here, I think the entire ioctl command can be removed until you > > actually need it. If you have an ioctl command that needs both > > input and output, use _IOWR() to define it and put all arguments > > into the same structure. > > I should've caught this in my earlier response, sorry. The device version > command is intentionally the first in the user interface enum. My > goal is for all device versions (e.g. DLB 1.0 in the future) to be accessible > through a /dev/dlb%d node. To allow this, all drivers would support the same > device-version command as command 0, then the subsequent commands can be > tailored to that particular device. User-space would query the version first > to determine which set of ioctl commands it needs to use. > > So even though the response is constant (for now), it must occupy command 0 for > this design to work. "versions" for ioctls just do not work, please don't go down that path, they should not be needed. See the many different discussions about this topic on lkml for other subsystem submissions if you are curious. thanks, greg k-h