From 4fd72fd29d4a90d9117038f4e15e4073aeb3bf7f Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 1 Aug 2017 21:20:52 -0500 Subject: ARM: socfpga: explicitly request exclusive reset control Commit a53e35db70d1 ("reset: Ensure drivers are explicit when requesting reset lines") started to transition the reset control request API calls to explicitly state whether the driver needs exclusive or shared reset control behavior. Convert all drivers requesting exclusive resets to the explicit API call so the temporary transition helpers can be removed. No functional changes. Cc: Alan Tull Cc: Moritz Fischer Cc: linux-fpga@vger.kernel.org Signed-off-by: Philipp Zabel Acked-By: Moritz Fischer Signed-off-by: Alan Tull Signed-off-by: Greg Kroah-Hartman --- drivers/fpga/altera-hps2fpga.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/fpga/altera-hps2fpga.c') diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c index 3066b805f2d0..a18ff430c9af 100644 --- a/drivers/fpga/altera-hps2fpga.c +++ b/drivers/fpga/altera-hps2fpga.c @@ -145,7 +145,8 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev) of_id = of_match_device(altera_fpga_of_match, dev); priv = (struct altera_hps2fpga_data *)of_id->data; - priv->bridge_reset = of_reset_control_get_by_index(dev->of_node, 0); + priv->bridge_reset = of_reset_control_get_exclusive_by_index(dev->of_node, + 0); if (IS_ERR(priv->bridge_reset)) { dev_err(dev, "Could not get %s reset control\n", priv->name); return PTR_ERR(priv->bridge_reset); -- cgit v1.2.3-70-g09d2 From 26ffca5ec406213da347cd3c5858d1414943caea Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 1 Aug 2017 21:20:53 -0500 Subject: fpga: altera-hps2fpga: add NULL check on of_match_device() return value Check return value from call to of_match_device() in order to prevent a NULL pointer dereference. In case of NULL print error message and return -ENODEV Signed-off-by: Gustavo A. R. Silva Reviewed-by: Moritz Fischer Signed-off-by: Alan Tull Signed-off-by: Greg Kroah-Hartman --- drivers/fpga/altera-hps2fpga.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/fpga/altera-hps2fpga.c') diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c index a18ff430c9af..e6c948b31474 100644 --- a/drivers/fpga/altera-hps2fpga.c +++ b/drivers/fpga/altera-hps2fpga.c @@ -143,6 +143,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev) int ret; of_id = of_match_device(altera_fpga_of_match, dev); + if (!of_id) { + dev_err(dev, "failed to match device\n"); + return -ENODEV; + } + priv = (struct altera_hps2fpga_data *)of_id->data; priv->bridge_reset = of_reset_control_get_exclusive_by_index(dev->of_node, -- cgit v1.2.3-70-g09d2 From 4ae2bd4b3ada3dfd80ca8110b4f567752966ca1e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 1 Aug 2017 21:20:54 -0500 Subject: fpga: altera-hps2fpga: fix multiple init of l3_remap_lock The global spinlock `l3_remap_lock` is reinitialized every time the "probe" function `alt_fpga_bridge_probe()` is called. It should only be initialized once. Use `DEFINE_SPINLOCK()` to initialize it statically. Fixes: e5f8efa5c8bf ("ARM: socfpga: fpga bridge driver support") Cc: # 4.10+ Signed-off-by: Ian Abbott Reviewed-By: Moritz Fischer Signed-off-by: Alan Tull Signed-off-by: Greg Kroah-Hartman --- drivers/fpga/altera-hps2fpga.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/fpga/altera-hps2fpga.c') diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c index e6c948b31474..406d2f10741f 100644 --- a/drivers/fpga/altera-hps2fpga.c +++ b/drivers/fpga/altera-hps2fpga.c @@ -66,7 +66,7 @@ static int alt_hps2fpga_enable_show(struct fpga_bridge *bridge) /* The L3 REMAP register is write only, so keep a cached value. */ static unsigned int l3_remap_shadow; -static spinlock_t l3_remap_lock; +static DEFINE_SPINLOCK(l3_remap_lock); static int _alt_hps2fpga_enable_set(struct altera_hps2fpga_data *priv, bool enable) @@ -177,8 +177,6 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev) return -EBUSY; } - spin_lock_init(&l3_remap_lock); - if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) { if (enable > 1) { dev_warn(dev, "invalid bridge-enable %u > 1\n", enable); -- cgit v1.2.3-70-g09d2