@@ -58,6 +58,7 @@ struct sx130x_priv {
struct regmap *regmap;
struct regmap_field *regmap_fields[ARRAY_SIZE(sx130x_regmap_fields)];
struct mutex io_lock;
+ void *drvdata;
};
struct regmap *sx130x_get_regmap(struct device *dev)
@@ -68,6 +69,24 @@ struct regmap *sx130x_get_regmap(struct device *dev)
return priv->regmap;
}
+void sx130x_set_drvdata(struct device *dev, void *drvdata)
+{
+ struct net_device *netdev = dev_get_drvdata(dev);
+ struct sx130x_priv *priv = netdev_priv(netdev);
+
+ priv->drvdata = drvdata;
+}
+EXPORT_SYMBOL_GPL(sx130x_set_drvdata);
+
+void *sx130x_get_drvdata(struct device *dev)
+{
+ struct net_device *netdev = dev_get_drvdata(dev);
+ struct sx130x_priv *priv = netdev_priv(netdev);
+
+ return priv->drvdata;
+}
+EXPORT_SYMBOL_GPL(sx130x_get_drvdata);
+
void sx130x_io_lock(struct device *dev)
{
struct net_device *netdev = dev_get_drvdata(dev);
@@ -14,6 +14,8 @@
#include <linux/regmap.h>
extern const struct regmap_config sx130x_regmap_config;
+void sx130x_set_drvdata(struct device *dev, void *drvdata);
+void *sx130x_get_drvdata(struct device *dev);
int sx130x_early_probe(struct regmap *regmap, struct gpio_desc *rst);
int sx130x_probe(struct device *dev);
int sx130x_remove(struct device *dev);
Some drivers (e.g., serdev) may need to access private data not part of the core sx130x_priv, which is inaccessible to other source files. As the sx130x core expects to obtain the net_device from the dev's drvdata, we can't reuse that in derived drivers and need a new field plus helpers. Signed-off-by: Andreas Färber <afaerber@suse.de> --- drivers/net/lora/sx130x.c | 19 +++++++++++++++++++ include/linux/lora/sx130x.h | 2 ++ 2 files changed, 21 insertions(+) -- 2.16.4