From: Eddie James <eajames@linux.vnet.ibm.com>
To: openbmc@lists.ozlabs.org
Cc: joel@jms.id.au, "Edward A. James" <eajames@us.ibm.com>
Subject: [PATCH linux dev-4.10 v2 4/5] drivers: occ: hwmon and fsi probing fix
Date: Fri, 9 Jun 2017 13:01:04 -0500 [thread overview]
Message-ID: <1497031265-29545-5-git-send-email-eajames@linux.vnet.ibm.com> (raw)
In-Reply-To: <1497031265-29545-1-git-send-email-eajames@linux.vnet.ibm.com>
From: "Edward A. James" <eajames@us.ibm.com>
Probe the FSI-based OCC hwmon driver immediately instead of delaying.
The probe will fail during FSI scan intentionally, since the OCC is not
active when the system is first powering on. The driver can then be
manually bound when the OCC becomes active.
Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
drivers/fsi/fsi-sbefifo.c | 4 ++--
drivers/fsi/occ.c | 8 +++++++-
drivers/hwmon/occ/p9_sbe.c | 38 ++++++++++----------------------------
3 files changed, 19 insertions(+), 31 deletions(-)
diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
index fbc8dc5..bcf284c 100644
--- a/drivers/fsi/fsi-sbefifo.c
+++ b/drivers/fsi/fsi-sbefifo.c
@@ -839,8 +839,6 @@ static int sbefifo_probe(struct device *dev)
setup_timer(&sbefifo->poll_timer, sbefifo_poll_timer,
(unsigned long)sbefifo);
- list_add(&sbefifo->link, &sbefifo_fifos);
-
if (dev->of_node) {
/* create platform devs for dts child nodes (occ, etc) */
for_each_child_of_node(dev->of_node, np) {
@@ -852,6 +850,8 @@ static int sbefifo_probe(struct device *dev)
"failed to create child node dev\n");
}
}
+
+ list_add(&sbefifo->link, &sbefifo_fifos);
return misc_register(&sbefifo->mdev);
}
diff --git a/drivers/fsi/occ.c b/drivers/fsi/occ.c
index a1508f2..f43ae51 100644
--- a/drivers/fsi/occ.c
+++ b/drivers/fsi/occ.c
@@ -635,6 +635,9 @@ struct occ_client *occ_drv_open(struct device *dev, unsigned long flags)
{
struct occ *occ = dev_get_drvdata(dev);
+ if (!occ)
+ return NULL;
+
return occ_open_common(occ, flags);
}
EXPORT_SYMBOL_GPL(occ_drv_open);
@@ -688,7 +691,8 @@ static int occ_probe(struct platform_device *pdev)
mutex_init(&occ->occ_lock);
INIT_WORK(&occ->work, occ_worker);
- platform_set_drvdata(pdev, occ);
+ /* ensure NULL before we probe children, so they don't hang FSI */
+ platform_set_drvdata(pdev, NULL);
if (dev->of_node) {
rc = of_property_read_u32(dev->of_node, "reg", ®);
@@ -715,6 +719,8 @@ static int occ_probe(struct platform_device *pdev)
} else
occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL);
+ platform_set_drvdata(pdev, occ);
+
snprintf(occ->name, sizeof(occ->name), "occ%d", occ->idx);
occ->mdev.fops = &occ_fops;
occ->mdev.minor = MISC_DYNAMIC_MINOR;
diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c
index fe435ef..c70858d 100644
--- a/drivers/hwmon/occ/p9_sbe.c
+++ b/drivers/hwmon/occ/p9_sbe.c
@@ -16,11 +16,8 @@
#include <linux/sched.h>
#include <linux/workqueue.h>
-#define P9_SBE_OCC_SETUP_DELAY 5000
-
struct p9_sbe_occ {
struct occ occ;
- struct delayed_work setup;
struct device *sbe;
};
@@ -93,12 +90,9 @@ static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd)
return rc;
}
-static void p9_sbe_occ_setup(struct work_struct *work)
+static int p9_sbe_occ_setup(struct p9_sbe_occ *p9_sbe_occ)
{
int rc;
- struct delayed_work *dwork = to_delayed_work(work);
- struct p9_sbe_occ *p9_sbe_occ = container_of(dwork, struct p9_sbe_occ,
- setup);
struct occ *occ = &p9_sbe_occ->occ;
/* no need to lock */
@@ -106,7 +100,7 @@ static void p9_sbe_occ_setup(struct work_struct *work)
if (rc < 0) {
dev_err(occ->bus_dev, "failed to get OCC poll response: %d\n",
rc);
- return;
+ return rc;
}
occ_parse_poll_response(occ);
@@ -114,21 +108,24 @@ static void p9_sbe_occ_setup(struct work_struct *work)
rc = occ_setup_sensor_attrs(occ);
if (rc) {
dev_err(occ->bus_dev, "failed to setup p9 attrs: %d\n", rc);
- return;
+ return rc;
}
occ->hwmon = devm_hwmon_device_register_with_groups(occ->bus_dev,
"p9_occ", occ,
occ->groups);
if (IS_ERR(occ->hwmon)) {
- dev_err(occ->bus_dev, "failed to register hwmon device: %ld\n",
- PTR_ERR(occ->hwmon));
- return;
+ rc = PTR_ERR(occ->hwmon);
+ dev_err(occ->bus_dev, "failed to register hwmon device: %d\n",
+ rc);
+ return rc;
}
rc = occ_create_status_attrs(occ);
if (rc)
dev_err(occ->bus_dev, "failed to setup p9 status attrs: %d\n", rc);
+
+ return rc;
}
static int p9_sbe_occ_probe(struct platform_device *pdev)
@@ -148,24 +145,10 @@ static int p9_sbe_occ_probe(struct platform_device *pdev)
occ->poll_cmd_data = 0x20;
occ->send_cmd = p9_sbe_occ_send_cmd;
mutex_init(&occ->lock);
- INIT_DELAYED_WORK(&p9_sbe_occ->setup, p9_sbe_occ_setup);
platform_set_drvdata(pdev, occ);
- schedule_delayed_work(&p9_sbe_occ->setup,
- msecs_to_jiffies(P9_SBE_OCC_SETUP_DELAY));
-
- return 0;
-}
-
-static int p9_sbe_occ_remove(struct platform_device *pdev)
-{
- struct occ *occ = platform_get_drvdata(pdev);
- struct p9_sbe_occ *p9_sbe_occ = to_p9_sbe_occ(occ);
-
- cancel_delayed_work_sync(&p9_sbe_occ->setup);
-
- return 0;
+ return p9_sbe_occ_setup(p9_sbe_occ);
}
static const struct of_device_id p9_sbe_occ_of_match[] = {
@@ -179,7 +162,6 @@ static int p9_sbe_occ_remove(struct platform_device *pdev)
.of_match_table = p9_sbe_occ_of_match,
},
.probe = p9_sbe_occ_probe,
- .remove = p9_sbe_occ_remove,
};
module_platform_driver(p9_sbe_occ_driver);
--
1.8.3.1
next prev parent reply other threads:[~2017-06-09 18:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-09 18:01 [PATCH linux dev-4.10 v2 0/5] drivers: OCC: Update sensors, fix probing, add P8 Eddie James
2017-06-09 18:01 ` [PATCH linux dev-4.10 v2 1/5] drivers: fsi: occ: Fix 1 byte response and rc for O_NONBLOCK Eddie James
2017-06-16 5:11 ` Joel Stanley
2017-06-09 18:01 ` [PATCH linux dev-4.10 v2 2/5] drivers: hwmon: occ: Add new sensor versions and non-hwmon attributes Eddie James
2017-06-16 5:36 ` Joel Stanley
2017-06-09 18:01 ` [PATCH linux dev-4.10 v2 3/5] drivers: hwmon: occ: Add P8 OCC access Eddie James
2017-06-09 18:01 ` Eddie James [this message]
2017-06-09 18:01 ` [PATCH linux dev-4.10 v2 5/5] aspeed: update power9 dts and defconfigs for OCC Eddie James
2017-06-16 5:40 ` [PATCH linux dev-4.10 v2 0/5] drivers: OCC: Update sensors, fix probing, add P8 Joel Stanley
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=1497031265-29545-5-git-send-email-eajames@linux.vnet.ibm.com \
--to=eajames@linux.vnet.ibm.com \
--cc=eajames@us.ibm.com \
--cc=joel@jms.id.au \
--cc=openbmc@lists.ozlabs.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.