Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1330213ybl; Thu, 22 Aug 2019 12:46:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzLwOtn/mKsq+9iQAeItT+qyOk4iEe2Tnmz003w6ehhtYZjWbSH2wv+6v8D3fJlnVqp94ZT X-Received: by 2002:aa7:9e0a:: with SMTP id y10mr922277pfq.93.1566503214916; Thu, 22 Aug 2019 12:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566503214; cv=none; d=google.com; s=arc-20160816; b=bH35WunPQJG18pi+9+of0YZY1+DguBtype5Y+EVaI6pSo5weZBxNO27Cq/O753bU/B vEi5OiPD+zNDWd8fMPxKr51fcQnRuG+gCAnOfqS42r3rcg2/8iywhB7x2c5FVXkZKL7p 5G4ZAzPsO/R04RxQUaymi98ufGRYIDQwLnMNhThJBaShA16iSX/JE2tocsQZoFEea973 1j8hKLS2wp2z06APCW3xjIKzQyi5VHq69Mw3/yAp0jzL2tOtrMnfxeKMa/gAIE998nBz 761RfsA7uMAfRbBmsKWmFdFKaZ5x69wqmLMi8hkW31HKfe7+YZYZOp9aCvGuwjUvERK7 u05A== 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; bh=DwlPQdW0JeEtIGvgq8R1ceN0wd/Kz610hNpWCu5gwlA=; b=Lv5PLUFI8e8eb89peVhAGqyywkr5OGC6kqp82kSYU0qAqnTKzQPzrJmc/3p9Vy9FAo /xLN4zN2hnm6YT5eGmgTcwIRD2ASu/6E5D2UgboYKao5cdaZwqfPptRz2zsGkhrybfBd C9j4Ii/yBJjudlXSmBR18zwtSOOyhPLUmsDywjN4L2ibX1oMTDW3PRMyZlvP2gGLXMgD 8Hi4gvBhIdeeOMfhKTeQ5LnQPLIZYfPFdvjVdOOcZWSQLp8nR01BoWEZoELh9UUDqusF HDw/uY+R4N+d2wTh70T1KkHhCE5P99u7FBHDAO39y8TmwjhkFwX1dt3OBXNKA40wP6hO jPeA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c189si484314pfa.110.2019.08.22.12.46.31; Thu, 22 Aug 2019 12:46:54 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389384AbfHVPHE (ORCPT + 99 others); Thu, 22 Aug 2019 11:07:04 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:39284 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387481AbfHVPHE (ORCPT ); Thu, 22 Aug 2019 11:07:04 -0400 Received: by mail-pg1-f196.google.com with SMTP id u17so3834820pgi.6 for ; Thu, 22 Aug 2019 08:07:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DwlPQdW0JeEtIGvgq8R1ceN0wd/Kz610hNpWCu5gwlA=; b=n5npKcw1CAfs4aZP6U3NE9l44x+40qfx6dkAC6yrp74rM/NuvYK0m6OfEfiDV8ViGv MRYGnpEFomYkUIBrOrVIGoIR9w7VBKiE9N618vd/LAiyHCI9s68ruMZOYXkoJMvmiMUp FNrOkSTRvDM2s7KmhGyjAvPGBjpz1fkA77oRZscbQrXeolIAoYYWoHFnrtFFRan8NES/ lmOBJzFpbN89wiCH+Tvd4YrfUuy+xoBgL4rE25OOSHZH3tRkrlJdhfgtO7nKh4V4I1Kj xLaYy1A5fPeeC7G3/7eeUamGdfQm6X74e3Z5Qh+fvChWmZNfXwZbuuEJusrLz9VGa+Rx Q8cA== X-Gm-Message-State: APjAAAX4jOlv3kxIg68omYer5AWzy0lsDVDMYkxsWtx78bwPqQna49X6 rvVbDpMg5WqYZhixOr1KHxmnm0PHlmU= X-Received: by 2002:aa7:95b8:: with SMTP id a24mr41746708pfk.103.1566486423362; Thu, 22 Aug 2019 08:07:03 -0700 (PDT) Received: from localhost ([2601:647:5b80:29f7:1bdd:d748:9a4e:8083]) by smtp.gmail.com with ESMTPSA id 71sm3357841pfw.157.2019.08.22.08.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2019 08:07:02 -0700 (PDT) Date: Thu, 22 Aug 2019 08:07:01 -0700 From: Moritz Fischer To: Wu Hao Cc: gregkh@linuxfoundation.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, atull@kernel.org Subject: Re: [PATCH v5 3/9] fpga: dfl: afu: convert platform_driver to use dev_groups Message-ID: <20190822150701.GB22556@archbox> References: <1565578204-13969-1-git-send-email-hao.wu@intel.com> <1565578204-13969-4-git-send-email-hao.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1565578204-13969-4-git-send-email-hao.wu@intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hao, On Mon, Aug 12, 2019 at 10:49:58AM +0800, Wu Hao wrote: > This patch takes advantage of driver core which helps to create > and remove sysfs attribute files, so there is no need to register > sysfs entries manually in dfl-afu platform river code. Same nit: s/river/driver > > Signed-off-by: Wu Hao Acked-by: Moritz Fischer > --- > drivers/fpga/dfl-afu-main.c | 69 +++++++++++++++++++++++---------------------- > 1 file changed, 36 insertions(+), 33 deletions(-) > > diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c > index e50c45e..e955149 100644 > --- a/drivers/fpga/dfl-afu-main.c > +++ b/drivers/fpga/dfl-afu-main.c > @@ -282,24 +282,17 @@ static int port_get_id(struct platform_device *pdev) > &dev_attr_power_state.attr, > NULL, > }; > -ATTRIBUTE_GROUPS(port_hdr); > + > +static const struct attribute_group port_hdr_group = { > + .attrs = port_hdr_attrs, > +}; > > static int port_hdr_init(struct platform_device *pdev, > struct dfl_feature *feature) > { > - dev_dbg(&pdev->dev, "PORT HDR Init.\n"); > - > port_reset(pdev); > > - return device_add_groups(&pdev->dev, port_hdr_groups); > -} > - > -static void port_hdr_uinit(struct platform_device *pdev, > - struct dfl_feature *feature) > -{ > - dev_dbg(&pdev->dev, "PORT HDR UInit.\n"); > - > - device_remove_groups(&pdev->dev, port_hdr_groups); > + return 0; > } > > static long > @@ -330,7 +323,6 @@ static void port_hdr_uinit(struct platform_device *pdev, > > static const struct dfl_feature_ops port_hdr_ops = { > .init = port_hdr_init, > - .uinit = port_hdr_uinit, > .ioctl = port_hdr_ioctl, > }; > > @@ -361,32 +353,37 @@ static void port_hdr_uinit(struct platform_device *pdev, > &dev_attr_afu_id.attr, > NULL > }; > -ATTRIBUTE_GROUPS(port_afu); > > -static int port_afu_init(struct platform_device *pdev, > - struct dfl_feature *feature) > +static umode_t port_afu_attrs_visible(struct kobject *kobj, > + struct attribute *attr, int n) > { > - struct resource *res = &pdev->resource[feature->resource_index]; > - int ret; > - > - dev_dbg(&pdev->dev, "PORT AFU Init.\n"); > + struct device *dev = kobj_to_dev(kobj); > > - ret = afu_mmio_region_add(dev_get_platdata(&pdev->dev), > - DFL_PORT_REGION_INDEX_AFU, resource_size(res), > - res->start, DFL_PORT_REGION_READ | > - DFL_PORT_REGION_WRITE | DFL_PORT_REGION_MMAP); > - if (ret) > - return ret; > + /* > + * sysfs entries are visible only if related private feature is > + * enumerated. > + */ > + if (!dfl_get_feature_by_id(dev, PORT_FEATURE_ID_AFU)) > + return 0; > > - return device_add_groups(&pdev->dev, port_afu_groups); > + return attr->mode; > } > > -static void port_afu_uinit(struct platform_device *pdev, > - struct dfl_feature *feature) > +static const struct attribute_group port_afu_group = { > + .attrs = port_afu_attrs, > + .is_visible = port_afu_attrs_visible, > +}; > + > +static int port_afu_init(struct platform_device *pdev, > + struct dfl_feature *feature) > { > - dev_dbg(&pdev->dev, "PORT AFU UInit.\n"); Thanks. > + struct resource *res = &pdev->resource[feature->resource_index]; > > - device_remove_groups(&pdev->dev, port_afu_groups); > + return afu_mmio_region_add(dev_get_platdata(&pdev->dev), > + DFL_PORT_REGION_INDEX_AFU, > + resource_size(res), res->start, > + DFL_PORT_REGION_MMAP | DFL_PORT_REGION_READ | > + DFL_PORT_REGION_WRITE); > } > > static const struct dfl_feature_id port_afu_id_table[] = { > @@ -396,7 +393,6 @@ static void port_afu_uinit(struct platform_device *pdev, > > static const struct dfl_feature_ops port_afu_ops = { > .init = port_afu_init, > - .uinit = port_afu_uinit, > }; > > static struct dfl_feature_driver port_feature_drvs[] = { > @@ -748,9 +744,16 @@ static int afu_remove(struct platform_device *pdev) > return 0; > } > > +static const struct attribute_group *afu_dev_groups[] = { > + &port_hdr_group, > + &port_afu_group, > + NULL > +}; > + > static struct platform_driver afu_driver = { > .driver = { > - .name = DFL_FPGA_FEATURE_DEV_PORT, > + .name = DFL_FPGA_FEATURE_DEV_PORT, > + .dev_groups = afu_dev_groups, > }, > .probe = afu_probe, > .remove = afu_remove, > -- > 1.8.3.1 > Thanks, Moritz