Skip to content

Commit 176538d

Browse files
committed
Merge tag 'cfi/for-5.7' into mtd/next
HyperBus changes * Print err msg when compatible is wrong or missing * Move mapping of direct access window from core to individual drivers
2 parents 17872f5 + b6fe8bc commit 176538d

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

drivers/mtd/hyperbus/hbmc-am654.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/mtd/mtd.h>
1212
#include <linux/mux/consumer.h>
1313
#include <linux/of.h>
14+
#include <linux/of_address.h>
1415
#include <linux/platform_device.h>
1516
#include <linux/pm_runtime.h>
1617
#include <linux/types.h>
@@ -57,8 +58,10 @@ static const struct hyperbus_ops am654_hbmc_ops = {
5758

5859
static int am654_hbmc_probe(struct platform_device *pdev)
5960
{
61+
struct device_node *np = pdev->dev.of_node;
6062
struct device *dev = &pdev->dev;
6163
struct am654_hbmc_priv *priv;
64+
struct resource res;
6265
int ret;
6366

6467
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -67,6 +70,10 @@ static int am654_hbmc_probe(struct platform_device *pdev)
6770

6871
platform_set_drvdata(pdev, priv);
6972

73+
ret = of_address_to_resource(np, 0, &res);
74+
if (ret)
75+
return ret;
76+
7077
if (of_property_read_bool(dev->of_node, "mux-controls")) {
7178
struct mux_control *control = devm_mux_control_get(dev, NULL);
7279

@@ -88,6 +95,11 @@ static int am654_hbmc_probe(struct platform_device *pdev)
8895
goto disable_pm;
8996
}
9097

98+
priv->hbdev.map.size = resource_size(&res);
99+
priv->hbdev.map.virt = devm_ioremap_resource(dev, &res);
100+
if (IS_ERR(priv->hbdev.map.virt))
101+
return PTR_ERR(priv->hbdev.map.virt);
102+
91103
priv->ctlr.dev = dev;
92104
priv->ctlr.ops = &am654_hbmc_ops;
93105
priv->hbdev.ctlr = &priv->ctlr;

drivers/mtd/hyperbus/hyperbus-core.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/mtd/map.h>
1111
#include <linux/mtd/mtd.h>
1212
#include <linux/of.h>
13-
#include <linux/of_address.h>
1413
#include <linux/types.h>
1514

1615
static struct hyperbus_device *map_to_hbdev(struct map_info *map)
@@ -62,7 +61,6 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
6261
struct hyperbus_ctlr *ctlr;
6362
struct device_node *np;
6463
struct map_info *map;
65-
struct resource res;
6664
struct device *dev;
6765
int ret;
6866

@@ -73,22 +71,15 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
7371

7472
np = hbdev->np;
7573
ctlr = hbdev->ctlr;
76-
if (!of_device_is_compatible(np, "cypress,hyperflash"))
74+
if (!of_device_is_compatible(np, "cypress,hyperflash")) {
75+
dev_err(ctlr->dev, "\"cypress,hyperflash\" compatible missing\n");
7776
return -ENODEV;
77+
}
7878

7979
hbdev->memtype = HYPERFLASH;
8080

81-
ret = of_address_to_resource(np, 0, &res);
82-
if (ret)
83-
return ret;
84-
8581
dev = ctlr->dev;
8682
map = &hbdev->map;
87-
map->size = resource_size(&res);
88-
map->virt = devm_ioremap_resource(dev, &res);
89-
if (IS_ERR(map->virt))
90-
return PTR_ERR(map->virt);
91-
9283
map->name = dev_name(dev);
9384
map->bankwidth = 2;
9485
map->device_node = np;

0 commit comments

Comments
 (0)