laforge submitted this change.

View Change


Approvals: laforge: Looks good to me, approved; Verified
Support kernel >= 6.3.0 (bus_type.uevent() const struct device)

linux kernel commit 2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6 modifies
the struct bus_type.uevent() argument from 'struct device *' to
'const struct device *'. Let's adjust our code to support that.

Change-Id: I0c416d8fa8d7d0081fdfec6325971d6de9f8d239
---
M drivers/dahdi/dahdi-sysfs.c
M drivers/dahdi/xpp/xbus-sysfs.c
M include/dahdi/kernel.h
3 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c
index ca29ddb..14a6d74 100644
--- a/drivers/dahdi/dahdi-sysfs.c
+++ b/drivers/dahdi/dahdi-sysfs.c
@@ -47,7 +47,7 @@
return 1;
}

-static inline struct dahdi_span *dev_to_span(struct device *dev)
+static inline struct dahdi_span *dev_to_span(const struct device *dev)
{
return dev_get_drvdata(dev);
}
@@ -68,7 +68,7 @@
return err; \
} while (0)

-static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv)
+static int span_uevent(UEVENT_CONST struct device *dev, struct kobj_uevent_env *kenv)
{
struct dahdi_span *span;

@@ -415,7 +415,7 @@
unsigned int clean_chardev:1;
} should_cleanup;

-static inline struct dahdi_device *to_ddev(struct device *dev)
+static inline const struct dahdi_device *to_ddev(const struct device *dev)
{
return container_of(dev, struct dahdi_device, dev);
}
@@ -438,9 +438,9 @@
return err; \
} while (0)

-static int device_uevent(struct device *dev, struct kobj_uevent_env *kenv)
+static int device_uevent(UEVENT_CONST struct device *dev, struct kobj_uevent_env *kenv)
{
- struct dahdi_device *ddev;
+ const struct dahdi_device *ddev;

if (!dev)
return -ENODEV;
@@ -456,7 +456,7 @@
manufacturer_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);
return sprintf(buf, "%s\n", ddev->manufacturer);
}

@@ -464,7 +464,7 @@
type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);
return sprintf(buf, "%s\n", ddev->devicetype);
}

@@ -472,7 +472,7 @@
span_count_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);
unsigned int count = 0;
struct list_head *pos;

@@ -486,7 +486,7 @@
hardware_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);

return sprintf(buf, "%s\n",
(ddev->hardware_id) ? ddev->hardware_id : "");
@@ -496,7 +496,7 @@
location_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);

return sprintf(buf, "%s\n",
(ddev->location) ? ddev->location : "");
@@ -506,7 +506,7 @@
auto_assign_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ struct dahdi_device *ddev = (struct dahdi_device *) to_ddev(dev);
dahdi_assign_device_spans(ddev);
return count;
}
@@ -520,7 +520,7 @@
unsigned int local_span_number;
unsigned int desired_spanno;
unsigned int desired_basechanno;
- struct dahdi_device *const ddev = to_ddev(dev);
+ struct dahdi_device *const ddev = (struct dahdi_device *const) to_ddev(dev);

ret = sscanf(buf, "%u:%u:%u", &local_span_number, &desired_spanno,
&desired_basechanno);
@@ -553,7 +553,7 @@
int ret;
unsigned int local_span_number;
struct dahdi_span *span;
- struct dahdi_device *const ddev = to_ddev(dev);
+ struct dahdi_device *const ddev = (struct dahdi_device *const) to_ddev(dev);

ret = sscanf(buf, "%u", &local_span_number);
if (ret != 1)
@@ -578,7 +578,7 @@
dahdi_spantype_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);
int count = 0;
ssize_t total = 0;
struct dahdi_span *span;
@@ -598,7 +598,7 @@
dahdi_spantype_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
- struct dahdi_device *const ddev = to_ddev(dev);
+ struct dahdi_device *const ddev = (struct dahdi_device *const) to_ddev(dev);
int ret;
struct dahdi_span *span = NULL;
struct dahdi_span *cur;
@@ -652,7 +652,7 @@
dahdi_registration_time_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dahdi_device *ddev = to_ddev(dev);
+ const struct dahdi_device *ddev = to_ddev(dev);
int count = 0;
struct timespec64 ts = ktime_to_timespec64(ddev->registration_time);

diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index d8c11dc..34cab65 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -418,7 +418,7 @@
return err; \
} while (0)

-static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
+static int astribank_uevent(UEVENT_CONST struct device *dev, struct kobj_uevent_env *kenv)
{
xbus_t *xbus;
extern char *initdir;
diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h
index 778c2b2..f04f324 100644
--- a/include/dahdi/kernel.h
+++ b/include/dahdi/kernel.h
@@ -1683,4 +1683,13 @@

#endif /* DAHDI_PRINK_MACROS_USE_debug */

+
+/* work-around kernel API change from "struct device *dev" to "const struct device *dev"
+ * as implemented in 2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6 */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+#define UEVENT_CONST const
+#else
+#define UEVENT_CONST
+#endif
+
#endif /* _DAHDI_KERNEL_H */

To view, visit change 33184. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: dahdi-linux
Gerrit-Branch: master
Gerrit-Change-Id: I0c416d8fa8d7d0081fdfec6325971d6de9f8d239
Gerrit-Change-Number: 33184
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-MessageType: merged