Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3073814pxv; Sun, 27 Jun 2021 18:08:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymXyZS+T2rSFsazCjVFyVITjLgjh/34yDMq6sknpBlPPGgu590tD12Fa+9dVllKtn3uWFm X-Received: by 2002:a05:6e02:c7:: with SMTP id r7mr16460601ilq.76.1624842538707; Sun, 27 Jun 2021 18:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624842538; cv=none; d=google.com; s=arc-20160816; b=y+VtJ5wTqCKz2kvFChVwKvUt+StfsKxDSgo+1yiGr/j4C6JEYjdJNHJa25nlDnKvpB UVZoq4rPcOIVoR3jPIrtdrwE9w+3pGEiFf3Lk8lPw/GjNo/UTyhYB0Pi74fGgVQoY6sJ O7dhs9dM7GjoMYRtmGK2qmHwX/eVjlZQFpcEKHqhcaTdYJDLkg5k4u48pZX2Nq80HUMG TGpJlek6oOfgGqiVcakeSDQaj/O5U6zfkaAHOg/iwou1WdHFrmiYflliWT4wUVpKHXwv vHDJavkEFLMzLnefwV1kmZ2Ow3NgisjKhA7Nh70zxacbm7EqDqJHomJGQ5Wi3MxPTJvY 2Dtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=sCXL5tQ4Estgqc64nzp7PF6WaekyAZR8K9OQWtsu6TI=; b=XEUA0XZWUMIhd2DJmpGd+24FsB/rTgFabyTL4FLidC0KTM+HSg4YmCdvZD5dHBl64R L0wfwf58mloy+Va2Eox3J1r1DAqgzXxBZtSBUnSkRN7+bgTxSX0cuo85Gm9APLEhvblk a/xP8N4brJeV3EqKbwFudxWBI3IjUFz26A/CoGVx8AsBqZo22SW24kcUP+nl77Z+ORXP Nxfqu7FbdhWsq9NNRr34apDDPpmNxoU7N2708EBDI2Ryq0rXVGe96l3Bi7CtDNZUDpkt CivrQQmDHVSV1hg5ZVgiTBO+fHMEtVJRKljdGeVKXCAuNtpRvITV8r1EP5a18yQmOTA8 xOlQ== ARC-Authentication-Results: i=1; mx.google.com; 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 s1si2736444iom.36.2021.06.27.18.08.46; Sun, 27 Jun 2021 18:08:58 -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; 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 S231918AbhF1BJH (ORCPT + 99 others); Sun, 27 Jun 2021 21:09:07 -0400 Received: from netrider.rowland.org ([192.131.102.5]:41061 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S231892AbhF1BJH (ORCPT ); Sun, 27 Jun 2021 21:09:07 -0400 Received: (qmail 639287 invoked by uid 1000); 27 Jun 2021 21:06:41 -0400 Date: Sun, 27 Jun 2021 21:06:41 -0400 From: Alan Stern To: "i.kononenko" Cc: Felipe Balbi , Greg Kroah-Hartman , openbmc@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/6] usb:gadget:mass-storage: refactoring the SCSI command handling Message-ID: <20210628010641.GB638648@rowland.harvard.edu> References: <20210626211820.107310-1-i.kononenko@yadro.com> <20210626211820.107310-3-i.kononenko@yadro.com> <20210627142355.GD624763@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jun 27, 2021 at 08:14:48PM +0300, i.kononenko wrote: > > > On 27.06.2021 17:23, Alan Stern wrote: > > On Sun, Jun 27, 2021 at 12:18:15AM +0300, Igor Kononenko wrote: > >> Implements a universal way to define SCSI commands and configure > >> precheck handlers. > > > > What is the reason for doing this? > > I have started implementing a way to specify a backend-file of > mass-storage images greater than 2.1Gb for cdrom-like mediums. > I notice the implementation of each scsi-command handler uses too > many magic-constant, hardcoded indexes and shifts. I decided to > define structures that contained appropriate SCSI-defined fields > and constant-values to clarify the code. > > Additionally, I noticed, many kernel subsystems use the 'separate > data and logic' approach, making a code more explicit and readable. > This looks reasonable to me, and a code looks more clearly, at > least - we don't need to examine each magic constant and its purpose. > > > > > At first glance, it appears you have added a great deal of complexity > > to the driver. The patch replaces a large amount of easily understood > > (albeit rather repetitious) code with an approximately equal amount > > of rather complicated code. This does not seem like an improvement. > > The SCSI-commands table is defined as unifying a way to specify the > SCSI-command handler, with corresponding required data instead pass > it to each repeatedly switch-case block, which makes code more readable > to me. If there isn't, I can keep the definition of SCSI-handlers as is, > but the SCSI-data structures with their constant-values are still > required, in my opinion. > > > > > Furthermore, the code you removed is flexible; it easily allows for > > small variations as neede by some command handlers. But the code you > > added is all table-driven, which does not easily permit arbitrary > > variations. > > > > I don't think that the SCSI-command handlers table is an obstacle to > define variation into a specific handler because the current patch has > helper macros, which can specify a behavior for each requirement of > handler. > > Anyway, the definition of the scsi-command handlers table may be discarded, > because this work done to helping developers who will work the > 'usb:gadget:mass-storage' subsystem in the future. Can you submit a patch that adds only the data structures without the commands table? Alan Stern