Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp874918imm; Sat, 26 May 2018 13:47:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoNGC8ZjSDn9P56G/i7uATe6LLXyMzvs8t00g4I9D51hzAoJNDLoRhG2uo7r6Klx99Ts7HK X-Received: by 2002:a17:902:5ac1:: with SMTP id g1-v6mr7678093plm.43.1527367668665; Sat, 26 May 2018 13:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527367668; cv=none; d=google.com; s=arc-20160816; b=fFIahBuOkxBc0oI6y2Ftwf1zaFHwLS6ArUqSAS6wIBFRjXx+1INJ3/juR1CjM88kQ1 xpzb2/m4iCgEZwd6yw4schulxeIW0xzL92n9UCJRekDVSeWKOsRdzHXD5r8thM4PJI7u y5xaRD+Adu1feC1S/o6hetSI25Gw1SXSHwlYcCGy7E7z1YtMYNiXEdjpCcsXpvqwzzc8 fEvzgGjpNWsxJ/lAZ2zyjxnw0MI68z6z1csfJfvqh04BiR6rDF2D5//84MFPLBvCla9G zE6OT49UQFcTysb2Bd6zXJHE2T/q7+xotGKry6lH+Mp5in/fSx/tPHVw1JGeiPSapWFR VP+w== 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=uneDQlGUA+9glPFoNTFljdhpzlLSVPuvCi1fyS8141c=; b=fA9HOhjGUOKWrKV4lu0SEuqz8fq6jDZbDGwmTqxk3uuPCMVPJ14gEkqS8N6+tSvm6W OmtsUKaqEx7ZrsR0hCMFHShHARSJztt1mXNH/XHJrEMORXX2LMglyF3ssefAy2wtASAI LSvWtSA3hbHvNpzUM2oynUVw0hBjY08Iw/yf2rxX+hljNHfua5sw+d7886dYj+MGOKfG u0cfBDk5wkwqlF8WucdKr5u5B2dedwN+G2R/mmWYe4t8BNwee8n98Rl3WkyQQaeZNqGp XtWcCGL+7z8jGXKx6+U5DD/hwE/ICmRn32+k9FivJChDcCv6mayy5jjsc1AwBHD1xusP 9OfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=qBnM4kOq; 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 u7-v6si27087623plq.160.2018.05.26.13.47.20; Sat, 26 May 2018 13:47:48 -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=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=qBnM4kOq; 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 S1032409AbeEZUrJ (ORCPT + 99 others); Sat, 26 May 2018 16:47:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40914 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032376AbeEZUrH (ORCPT ); Sat, 26 May 2018 16:47:07 -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=QHmOWl4Kx5z9+4HVCr1iackCGXu5+lwnPMsUx/wOC8c=; b=qBnM4kOqCxx9uhi86u+kCnf+P Kqa0nIxHfDjPzR076OvAvafTG1xcaAZuDAXx70tOH436dZjXJ1gx4Bt2gUwFa44siY7dqEHoKSgqn 1Tbtf6preVrce4xr/YmrMGvz7SK953dztaRi0qoBO+hqxXKW4jfyKYV6qm1Z/18pdNsynFJYbDubB ljjMuC0gNi/SyF4OnF7O0XjLICYItr16hLCO2dSIAty4JSBScllzG6iWJOUvQQUNJY1+NrHPwAkkS Z/9j2r/+AvwHxA6kluf+PeBIXAK66BZzf/s+jFihAEOg6rOQ8osWWxQ0FN9dqdesFFF/8Jk4tF7oJ t0UDnegNQ==; Received: from dvhart by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMg5h-0004v7-C4; Sat, 26 May 2018 20:47:05 +0000 Date: Sat, 26 May 2018 13:47:01 -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" , Michael Shych , "ivecera@redhat.com" Subject: Re: [PATCH v2 6/7] platform/mellanox: Introduce support for Mellanox register access driver Message-ID: <20180526204701.GF10172@fury> References: <1525675735-125547-1-git-send-email-vadimp@mellanox.com> <1525675735-125547-4-git-send-email-vadimp@mellanox.com> <20180525003112.GC10172@fury> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Sat, May 26, 2018 at 11:15:35AM +0000, Vadim Pasternak wrote: > > > > -----Original Message----- > > From: Darren Hart [mailto:dvhart@infradead.org] > > Sent: Friday, May 25, 2018 3:31 AM > > 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; > > Michael Shych ; ivecera@redhat.com > > Subject: Re: [PATCH v2 6/7] platform/mellanox: Introduce support for Mellanox > > register access driver > > > > 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... > > ... > > > + 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. > > Maybe I really can add something like > static struct device_attribute mlxreg_io_devattr_rw = { > .show = mlxreg_io_attr_show, > .store = mlxreg_io_attr_store, > }; > > And replace this whole switch statement just with: > memcpy(&priv->mlxreg_io_dev_attr[i].dev_attr, > &mlxreg_io_devattr_rw, sizeof(struct device_attribute)); This is certainly preferable if it doesn't present any functional problems. Seems to me it must be doable because the OS has to deny write for Group and Other and allow for User with 644, similarly for read is other perm conditions. -- Darren Hart VMware Open Source Technology Center