Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1133037imm; Tue, 15 May 2018 14:23:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrS1re1yCew8VYsSavzXU3lkO59pidbSWBMf0ChaV8+qwFQNHLPo21TR+5GtD1HpcymuFGy X-Received: by 2002:a17:902:968d:: with SMTP id n13-v6mr15608404plp.168.1526419395786; Tue, 15 May 2018 14:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526419395; cv=none; d=google.com; s=arc-20160816; b=j8D3Ic2uc/1yaiwLVNhBWZsqt/JmSpml+ToGtIUEUCyYLgeSn8N3LwZT+fvEyZ8G7Z 8gQnTpgiOOVhiE7YcEPPH4mr5jvDcC8T/2qQ8uuoleGQFDTyzw5mh0A5gri/RuL55vw5 3whRC5lhBC0ZZiLsH8BPDUkmGmrP4GhgJeC0KOWn7RMTwMlFACd70Aqby5cAuJKtVVvU EEJN+84NY+oQkJWHPjEl+Gy/c9jPpcoKPunVGlCtWYJnOGBxDjTvvUiCCNlQjts4SbxJ BFbSRjM444slbTUlnUHlNB7d0ChruAB6WwLLFEWFlLdlzbswyuOyci663GBt0ZPxeqSF 8m3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Kv3Dsb136m6woDcLeq0RvetZlxd07JTKK/EPH5bVjKE=; b=OD9yTDr1+cyFn7oJ8XpZGO8FJIdFTM0OOkU6Mhv7UWRrzm4SSnIjCuvdNYY7zfo+tA zqc1VHYXv4HD54zop05U0sCji7vB8uA7gHdbGV1duW0qoFCuFd5feHKVABMVO2r8JTWF syoysL3JEIWUMj3WQC/Fh5A0qV3c4erqwpRitNqiRzTBteyy6F0DsjH8mui43spRhcRn 0JjVkbPwcKT5zlbIPeR9++wGBa14NJqbwquo+sdeY1Ss/dUS++TGweOnbFxFhDOoHuwh UnpOXz67SRJEn0oX+UiWY1+oP0aMl84EhO3I8qLcOb8HE1OwCUQJsqXlMxAoi55OCFA3 BvjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GjXYeyXg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u15-v6si757932pgv.355.2018.05.15.14.23.01; Tue, 15 May 2018 14:23:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GjXYeyXg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbeEOVVk (ORCPT + 99 others); Tue, 15 May 2018 17:21:40 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:36723 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752783AbeEOVVh (ORCPT ); Tue, 15 May 2018 17:21:37 -0400 Received: by mail-qt0-f194.google.com with SMTP id q6-v6so2334039qtn.3; Tue, 15 May 2018 14:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Kv3Dsb136m6woDcLeq0RvetZlxd07JTKK/EPH5bVjKE=; b=GjXYeyXghAo02f4jjkuKBv2M0xrQhcoR/2/nNezd+VFThSEWvzWGhAFhAH0tQxHBHm S6EUmYbm0FLRcAqF7nL47eurnLRItrjzq8LgeVHcmIyn6MmktTiHg7jvPXDI/ur1urYE Fp38TijBUwhe8evZ10Q0qzMBLItL47W2Ij9KbKZj+0oy3a7LNPIrPxN23jlB4X7mqdQa KlaZrSrUl5K4ZnhJ0l2/MVouOeVzex0PyAv1HCqR602IeGD8NqWMAUilmYYRgxrXPJX6 IJr7aXkLGIFXIK3efu8muFL17XXc8m2xk/V/SZOonuOhl+r56JU3q6/QNUt2k5lWPldZ FRgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Kv3Dsb136m6woDcLeq0RvetZlxd07JTKK/EPH5bVjKE=; b=JKm867NUCMzJHivEpbeG+JeAc/YCc+43QDNZf2m0PAFov/llsUIAY4AP+OlF5UHc/E WCwxxQNGxK0BkKiyJy5G0Y2tdh2mJUs3tbq1q0gADfpb0xh+/Ml9mPfHqt5kZvOpnBpk kFltqhyZagL17ZdUFz6mhzFDqmwy+9HZZHI+TKYs8HWLO1/MWMl7qtNR/oN8BxAIEAu9 QYl2Qkj8LKtxr1w1bgLW5eFDlObEFqMPoTapvNm/noXcMpHVvNit7z1XNaQiGdEh3zw4 hp0H3JrQlQdLoTP6acdtp6cesSsU/Wo9p76t/nXiBTdYChxTjKdWMvKfWh4Pd/l1+6PN JRHQ== X-Gm-Message-State: ALKqPwe3XCenvhA0hziMpJ2zUF3VpCffQQXhibD4Fggc5B6Jxda6O/g8 vPHrmxpPnjf+Zlq661QUKOY2pMNdTj0E07B/XhY= X-Received: by 2002:ac8:354f:: with SMTP id z15-v6mr15555316qtb.295.1526419296060; Tue, 15 May 2018 14:21:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.150 with HTTP; Tue, 15 May 2018 14:21:35 -0700 (PDT) In-Reply-To: <1526394095-5069-2-git-send-email-oleksandrs@mellanox.com> References: <1526394095-5069-1-git-send-email-oleksandrs@mellanox.com> <1526394095-5069-2-git-send-email-oleksandrs@mellanox.com> From: Andy Shevchenko Date: Wed, 16 May 2018 00:21:35 +0300 Message-ID: Subject: Re: [patch v21 1/4] drivers: jtag: Add JTAG core driver To: Oleksandr Shamray Cc: Greg Kroah-Hartman , Arnd Bergmann , Linux Kernel Mailing List , linux-arm Mailing List , devicetree , openbmc@lists.ozlabs.org, Joel Stanley , =?UTF-8?B?SmnFmcOtIFDDrXJrbw==?= , Tobias Klauser , "open list:SERIAL DRIVERS" , Vadim Pasternak , system-sw-low-level@mellanox.com, Rob Herring , openocd-devel-owner@lists.sourceforge.net, linux-api@vger.kernel.org, "David S. Miller" , Mauro Carvalho Chehab , Jiri Pirko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 5:21 PM, Oleksandr Shamray wrote: > Initial patch for JTAG driver > JTAG class driver provide infrastructure to support hardware/software > JTAG platform drivers. It provide user layer API interface for flashing > and debugging external devices which equipped with JTAG interface > using standard transactions. > > Driver exposes set of IOCTL to user space for: > - XFER: > - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan); > - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan); > - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified > number of clocks). > - SIOCFREQ/GIOCFREQ for setting and reading JTAG frequency. > > Driver core provides set of internal APIs for allocation and > registration: > - jtag_register; > - jtag_unregister; > - jtag_alloc; > - jtag_free; > > Platform driver on registration with jtag-core creates the next > entry in dev folder: > /dev/jtagX > 0xB0 all RATIO devices in development: > > 0xB1 00-1F PPPoX > +0xB2 00-0f linux/jtag.h JTAG driver > + Consider to preserve style (upper vs. lower). > + This provides basic core functionality support for JTAG class devices. > + Hardware that is equipped with a JTAG microcontroller can be > + supported by using this driver's interfaces. > + This driver exposes a set of IOCTLs to the user space for > + the following commands: > + SDR: (Scan Data Register) Performs an IEEE 1149.1 Data Register scan > + SIR: (Scan Instruction Register) Performs an IEEE 1149.1 Instruction > + Register scan. > + RUNTEST: Forces the IEEE 1149.1 bus to a run state for a specified > + number of clocks or a specified time period. Something feels wrong with formatting here. > +#define MAX_JTAG_NAME_LEN (sizeof("jtag") + 5) Interesting definition. Why not to set to 10 explicitly? And why 10? (16 sounds better) > +struct jtag { > + struct miscdevice miscdev; > + struct device *dev; Doesn't miscdev parent contain exactly this one? > + const struct jtag_ops *ops; > + int id; > + bool opened; > + struct mutex open_lock; > + unsigned long priv[0]; > +}; > + err = copy_to_user(u64_to_user_ptr(xfer.tdio), > + (void *)(xfer_data), data_size); Redundant parens in one case. Check the rest similar places. > +static int jtag_open(struct inode *inode, struct file *file) > +{ > + struct jtag *jtag = container_of(file->private_data, struct jtag, > + miscdev); I would don't care about length and put it on one line. > + if (jtag->opened) { > + jtag->opened = true; > + jtag->opened = false; Can it be opened non exclusively several times? If so, this needs to be a ref counter instead. > + if (!ops->idle || !ops->mode_set || !ops->status_get || !ops->xfer) > + return NULL; Are all of them mandatory? > +int jtag_register(struct jtag *jtag) Perhaps devm_ variant. > +#define jtag_u64_to_ptr(arg) ((void *)(uintptr_t)arg) Where is this used or supposed to be used? > +#define JTAG_MAX_XFER_DATA_LEN 65535 Is this limitation from some spec? Otherwise why not to allow 64K? > +/** > + * struct jtag_ops - callbacks for jtag control functions: > + * > + * @freq_get: get frequency function. Filled by device driver > + * @freq_set: set frequency function. Filled by device driver > + * @status_get: set status function. Filled by device driver > + * @idle: set JTAG to idle state function. Filled by device driver > + * @xfer: send JTAG xfer function. Filled by device driver > + */ Perhaps you need to describe which of them are _really_ mandatory and which are optional. -- With Best Regards, Andy Shevchenko