LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: richard.gong@linux.intel.com
Cc: robh+dt@kernel.org, mark.rutland@arm.com, dinguyen@kernel.org,
atull@kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, sen.li@intel.com,
Richard Gong <richard.gong@intel.com>
Subject: Re: [PATCHv3 2/4] firmware: add Intel Stratix10 remote system update driver
Date: Fri, 24 May 2019 20:58:58 +0200 [thread overview]
Message-ID: <20190524185858.GB13200@kroah.com> (raw)
In-Reply-To: <1558616610-499-3-git-send-email-richard.gong@linux.intel.com>
On Thu, May 23, 2019 at 08:03:28AM -0500, richard.gong@linux.intel.com wrote:
> +static int stratix10_rsu_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct stratix10_rsu_priv *priv;
> + int ret;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->client.dev = dev;
> + priv->client.receive_cb = NULL;
> + priv->client.priv = priv;
> + priv->status.current_image = 0;
> + priv->status.fail_image = 0;
> + priv->status.error_location = 0;
> + priv->status.error_details = 0;
> + priv->status.version = 0;
> + priv->status.state = 0;
> +
> + mutex_init(&priv->lock);
> + priv->chan = stratix10_svc_request_channel_byname(&priv->client,
> + SVC_CLIENT_RSU);
> + if (IS_ERR(priv->chan)) {
> + dev_err(dev, "couldn't get service channel %s\n",
> + SVC_CLIENT_RSU);
> + return PTR_ERR(priv->chan);
> + }
> +
> + init_completion(&priv->completion);
> + platform_set_drvdata(pdev, priv);
> +
> + /* status is only updated after reboot */
> + ret = rsu_send_msg(priv, COMMAND_RSU_STATUS,
> + 0, rsu_status_callback);
> + if (ret) {
> + dev_err(dev, "Error, getting RSU status %i\n", ret);
> + stratix10_svc_free_channel(priv->chan);
> + }
> +
> + ret = devm_device_add_groups(dev, rsu_groups);
> + if (ret) {
> + dev_err(dev, "unable to create sysfs group");
> + stratix10_svc_free_channel(priv->chan);
> + }
> +
> + return ret;
> +}
> +
> +static int stratix10_rsu_remove(struct platform_device *pdev)
> +{
> + struct stratix10_rsu_priv *priv = platform_get_drvdata(pdev);
> +
> + stratix10_svc_free_channel(priv->chan);
> + devm_device_remove_groups(&pdev->dev, rsu_groups);
When you are the only caller of a function in the kernel, that's a HUGE
flag that maybe you should not be calling it...
Which reminds me, I need to go remove this...
Anyway, no, don't do this, you are racing userspace with your sysfs
files. Reference the groups in the platform_driver structure and the
driver core will properly create, and remove, them for you, and
userspace will be happy they show up at the correct time.
This also makes your probe/remove function smaller.
thanks,
greg k-h
next prev parent reply other threads:[~2019-05-24 18:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 13:03 [PATCHv3 0/4] " richard.gong
2019-05-23 13:03 ` [PATCHv3 1/4] firmware: stratix10-svc: extend svc to support RSU notify and WD features richard.gong
2019-05-23 13:03 ` [PATCHv3 2/4] firmware: add Intel Stratix10 remote system update driver richard.gong
2019-05-24 18:58 ` Greg KH [this message]
2019-05-23 13:03 ` [PATCHv3 3/4] firmware: rsu: document sysfs interface richard.gong
2019-05-24 18:56 ` Greg KH
2019-05-23 13:03 ` [PATCHv3 4/4] MAINTAINERS: add maintainer for Intel Stratix10 FW drivers richard.gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190524185858.GB13200@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=atull@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dinguyen@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=richard.gong@intel.com \
--cc=richard.gong@linux.intel.com \
--cc=robh+dt@kernel.org \
--cc=sen.li@intel.com \
--subject='Re: [PATCHv3 2/4] firmware: add Intel Stratix10 remote system update driver' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).