Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2954356imm; Thu, 24 May 2018 19:49:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr1BxHD+Gy/gv1dMVT8VNWdtxfGnDkRuC4By4WkoEmVxhztelTlGRRzPDlJd4yLv18maM9f X-Received: by 2002:a17:902:1e3:: with SMTP id b90-v6mr594056plb.273.1527216561324; Thu, 24 May 2018 19:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216561; cv=none; d=google.com; s=arc-20160816; b=ZuxXtYSI/ZFWq8DnA+bWDJoYm9Z7sPPk+Z6IwgsSyaDdpues4+agIgsfC07OtaaneZ 4QepJYapnAOZ8zyMH5SnbC1c6JF7VC8UyWSNReMg74AuLm+QvdB7WFJrg/+5wrOEEsow 12ufX+OteCqWSk43yZID6sddmE3WkK4uH0XVsoimZfqbWQdkmUHyK12dY+e8iaCCOCG5 qIgr/jlodVDybN659VoEdQihgdIlyZKK7XwQ1C5+sysES0i9pwEB+WmbZs5HGJnBNv+r mnzTXUhHINX63rHF5Mrrps3RBb3Cz6gmLg5fNOH8B+KPyplRJ/8c5FplC4MqVcMx2+6X n/Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=6T0xcJMR9FVIVXn7IDMqRhJqTGtNiHin744IOmSDAxw=; b=qea+b6gMnWl1CrsXj5SHojclGW4PeKm3MAEPOl9uz2AHfMrrl7Dh8nAOdnHCDwgEJx Bz78dSSZ/5GFCq0eTyZbpm2WDMx3p7wgBxUMrjIDG9yFckWHLn6QF021uBcthmes8/PY AsLAcjNxdHIUMa//RHkBtPo1/lPkiVBFbMsMma64A7DRiJ/NI09Rfc3cXrjFtpsJkVmL oqTQ2buzsTl7dPEgC9A3GvMFGS5c6EUAFNxqfPZAackC880cIxnI/scxjzHFlW9XAStK mXMjVNOZLZy5N4AEF5Qa2uLLgvybhotEKo858uGDLv4mk/DfDSDm4k1++kgVfMV/Lv9z ExoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tVHyKjoR; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si22223598plc.452.2018.05.24.19.49.07; Thu, 24 May 2018 19:49:21 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tVHyKjoR; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970417AbeEYAb0 (ORCPT + 99 others); Thu, 24 May 2018 20:31:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:54268 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966894AbeEYAbX (ORCPT ); Thu, 24 May 2018 20:31:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6T0xcJMR9FVIVXn7IDMqRhJqTGtNiHin744IOmSDAxw=; b=tVHyKjoRhd3Gxl3CJC5k3Ys6N 8beMtycoKeSm3mCaU69t9EZn8/9UxAlDlDh3WgNAf6q5YmMb7Xa4CT9Q/nNk3PS0JpHBtIIOjc/Ev K4Y8S6b4wHSc+NyvJzPJHrU1jojAlaKyd3IxyffqO803pTVdBYFDjgo5yejeeiSIMS7xL/P9U3Q6u w/8e8y9MM6dK4mM5Qu5uLY94ZprUGlhIhZRgpFH6FsgpDHL88bK+G6ePJ/nAChk3VNOQxbDeytrhR rqPp30WEpH8k6Uvf9OwLUUIoXyrAvp2+jW/1rBj4/uVwVvcC+5MuCPbsHuXU/k+RoEq/NakhwuiQp 5IOrKivuw==; Received: from dvhart by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fM0dW-0006MU-Mo; Fri, 25 May 2018 00:31:14 +0000 Date: Thu, 24 May 2018 17:31:12 -0700 From: Darren Hart To: Vadim Pasternak Cc: andy.shevchenko@gmail.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, jiri@resnulli.us, michaelsh@mellanox.com, ivecera@redhat.com Subject: Re: [PATCH v2 6/7] platform/mellanox: Introduce support for Mellanox register access driver Message-ID: <20180525003112.GC10172@fury> References: <1525675735-125547-1-git-send-email-vadimp@mellanox.com> <1525675735-125547-4-git-send-email-vadimp@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525675735-125547-4-git-send-email-vadimp@mellanox.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 07, 2018 at 06:48:54AM +0000, Vadim Pasternak wrote: > Introduce new Mellanox platform driver to allow access to Mellanox > programmable device register space trough sysfs interface. > The driver purpose is to provide sysfs interface for user space for the > registers essential for system control and monitoring. > The sets of registers for sysfs access are supposed to be defined per > system type bases and include the registers related to system resets > operation, system reset causes monitoring and some kinds of mux selection. > > Signed-off-by: Vadim Pasternak > --- One question on the attr init which I'm not familiar with... Andy, Greg - can you offer your opinion below... > +static int mlxreg_io_attr_init(struct mlxreg_io_priv_data *priv) > +{ > + int i; > + > + priv->group.attrs = devm_kzalloc(&priv->pdev->dev, > + priv->pdata->counter * > + sizeof(struct attribute *), > + GFP_KERNEL); > + if (!priv->group.attrs) > + return -ENOMEM; > + > + for (i = 0; i < priv->pdata->counter; i++) { > + priv->mlxreg_io_attr[i] = > + &priv->mlxreg_io_dev_attr[i].dev_attr.attr; > + > + /* Set attribute name as a label. */ > + priv->mlxreg_io_attr[i]->name = > + devm_kasprintf(&priv->pdev->dev, GFP_KERNEL, > + priv->pdata->data[i].label); > + > + if (!priv->mlxreg_io_attr[i]->name) { > + dev_err(&priv->pdev->dev, "Memory allocation failed for sysfs attribute %d.\n", > + i + 1); > + return -ENOMEM; > + } > + > + priv->mlxreg_io_dev_attr[i].dev_attr.attr.mode = > + priv->pdata->data[i].mode; > + switch (priv->pdata->data[i].mode) { This seemed a bit odd to me. Do we need to do this conditional assignment within the kernel, or can these just be assigned, and the mode will guard against the user being able to call store on a read only attr? > + case 0200: > + priv->mlxreg_io_dev_attr[i].dev_attr.store = > + mlxreg_io_attr_store; > + break; > + > + case 0444: > + priv->mlxreg_io_dev_attr[i].dev_attr.show = > + mlxreg_io_attr_show; > + break; > + > + case 0644: > + priv->mlxreg_io_dev_attr[i].dev_attr.show = > + mlxreg_io_attr_show; > + priv->mlxreg_io_dev_attr[i].dev_attr.store = > + mlxreg_io_attr_store; > + break; If this is necessary, we can simplify this by checking for the read mask and the write mask and setting each once - rather than duplicating this for r, w, and rw. As it is a 0400 would not assign the show function, even though it is readable by somebody. -- Darren Hart VMware Open Source Technology Center