Skip to content

Commit

Permalink
Fix build with recent kernels. (#142)
Browse files Browse the repository at this point in the history
* Fix the layout changes after linux 6

* Fixup for commit 1aaba11da9aa ("driver core: class: remove module * from class_create()")

Since Linux 6.4-rc1 the first argument to class_create is removed.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>

---------

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Co-authored-by: Jeffrey Cheung <jcheung@suse.com>
  • Loading branch information
hramrach and JeffreyCheung authored Sep 20, 2023
1 parent 69ad02f commit 9901354
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
10 changes: 9 additions & 1 deletion msr_allowlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,11 @@ static int parse_next_allowlist_entry(char *inbuf, char **nextinbuf, struct allo
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)
static char *msr_allowlist_nodename(struct device *dev, mode_t *mode)
#else
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,2,0)
static char *msr_allowlist_nodename(struct device *dev, umode_t *mode)
#else
static char *msr_allowlist_nodename(const struct device *dev, umode_t *mode)
#endif
#endif
{
return kasprintf(GFP_KERNEL, "cpu/msr_allowlist");
Expand Down Expand Up @@ -410,7 +414,11 @@ int msr_allowlist_init(int *majordev)
}
cdev_registered = 1;

cdev_class = class_create(THIS_MODULE, "msr_allowlist");
cdev_class = class_create(
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
THIS_MODULE,
#endif
"msr_allowlist");
if (IS_ERR(cdev_class))
{
err = PTR_ERR(cdev_class);
Expand Down
10 changes: 9 additions & 1 deletion msr_batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ void msrbatch_cleanup(int majordev)
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)
static char *msrbatch_nodename(struct device *dev, mode_t *mode)
#else
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,2,0)
static char *msrbatch_nodename(struct device *dev, umode_t *mode)
#else
static char *msrbatch_nodename(const struct device *dev, umode_t *mode)
#endif
#endif
{
return kasprintf(GFP_KERNEL, "cpu/msr_batch");
Expand All @@ -207,7 +211,11 @@ int msrbatch_init(int *majordev)
}
cdev_registered = 1;

cdev_class = class_create(THIS_MODULE, "msr_batch");
cdev_class = class_create(
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
THIS_MODULE,
#endif
"msr_batch");
if (IS_ERR(cdev_class))
{
err = PTR_ERR(cdev_class);
Expand Down
10 changes: 9 additions & 1 deletion msr_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ static struct notifier_block __refdata msr_class_cpu_notifier =
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)
static char *msr_devnode(struct device *dev, mode_t *mode)
#else
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,2,0)
static char *msr_devnode(struct device *dev, umode_t *mode)
#else
static char *msr_devnode(const struct device *dev, umode_t *mode)
#endif
#endif
{
return kasprintf(GFP_KERNEL, "cpu/%u/msr_safe", MINOR(dev->devt));
Expand Down Expand Up @@ -315,7 +319,11 @@ static int __init msr_init(void)
pr_debug("msr_allowlist major dev: %i\n", mdev_msr_allowlist);
pr_debug("msr_version major dev: %i\n", mdev_msr_version);

msr_class = class_create(THIS_MODULE, "msr_safe");
msr_class = class_create(
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
THIS_MODULE,
#endif
"msr_safe");
if (IS_ERR(msr_class))
{
err = PTR_ERR(msr_class);
Expand Down
10 changes: 9 additions & 1 deletion msr_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ static const struct file_operations fops =
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)
static char *msr_version_nodename(struct device *dev, mode_t *mode)
#else
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,2,0)
static char *msr_version_nodename(struct device *dev, umode_t *mode)
#else
static char *msr_version_nodename(const struct device *dev, umode_t *mode)
#endif
#endif
{
if (mode)
Expand Down Expand Up @@ -103,7 +107,11 @@ int msr_version_init(int *majordev)
}
cdev_registered = 1;

cdev_class = class_create(THIS_MODULE, "msr_safe_version");
cdev_class = class_create(
#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
THIS_MODULE,
#endif
"msr_safe_version");
if (IS_ERR(cdev_class))
{
err = PTR_ERR(cdev_class);
Expand Down

0 comments on commit 9901354

Please sign in to comment.