diff --git a/module/include/linux/surface_aggregator/serial_hub.h b/module/include/linux/surface_aggregator/serial_hub.h index 8f9ba14b..0867e797 100644 --- a/module/include/linux/surface_aggregator/serial_hub.h +++ b/module/include/linux/surface_aggregator/serial_hub.h @@ -12,7 +12,7 @@ #ifndef _LINUX_SURFACE_AGGREGATOR_SERIAL_HUB_H #define _LINUX_SURFACE_AGGREGATOR_SERIAL_HUB_H -#include +#include #include #include #include @@ -188,7 +188,7 @@ static_assert(sizeof(struct ssh_command) == 8); */ static inline u16 ssh_crc(const u8 *buf, size_t len) { - return crc_ccitt_false(0xffff, buf, len); + return crc_itu_t(0xffff, buf, len); } /* diff --git a/module/src/bus.c b/module/src/bus.c index b87cc1f3..82e7e2c4 100644 --- a/module/src/bus.c +++ b/module/src/bus.c @@ -304,9 +304,9 @@ const void *ssam_device_get_match_data(const struct ssam_device *dev) } EXPORT_SYMBOL_GPL(ssam_device_get_match_data); -static int ssam_bus_match(struct device *dev, struct device_driver *drv) +static int ssam_bus_match(struct device *dev, const struct device_driver *drv) { - struct ssam_device_driver *sdrv = to_ssam_device_driver(drv); + const struct ssam_device_driver *sdrv = to_ssam_device_driver(drv); struct ssam_device *sdev = to_ssam_device(dev); if (!is_ssam_device(dev)) diff --git a/module/src/clients/surface_acpi_notify.c b/module/src/clients/surface_acpi_notify.c index f1d99878..9cac6d34 100644 --- a/module/src/clients/surface_acpi_notify.c +++ b/module/src/clients/surface_acpi_notify.c @@ -11,7 +11,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include @@ -850,7 +850,7 @@ static int san_probe(struct platform_device *pdev) return status; } -static int san_remove(struct platform_device *pdev) +static void san_remove(struct platform_device *pdev) { acpi_handle san = ACPI_HANDLE(&pdev->dev); @@ -864,8 +864,6 @@ static int san_remove(struct platform_device *pdev) * all delayed works they may have spawned are run to completion. */ flush_workqueue(san_wq); - - return 0; } static const struct acpi_device_id san_match[] = { diff --git a/module/src/clients/surface_aggregator_cdev.c b/module/src/clients/surface_aggregator_cdev.c index 1508a4fc..738829a6 100644 --- a/module/src/clients/surface_aggregator_cdev.c +++ b/module/src/clients/surface_aggregator_cdev.c @@ -670,7 +670,6 @@ static const struct file_operations ssam_controller_fops = { .fasync = ssam_cdev_fasync, .unlocked_ioctl = ssam_cdev_device_ioctl, .compat_ioctl = ssam_cdev_device_ioctl, - .llseek = no_llseek, }; @@ -714,7 +713,7 @@ static int ssam_dbg_device_probe(struct platform_device *pdev) return 0; } -static int ssam_dbg_device_remove(struct platform_device *pdev) +static void ssam_dbg_device_remove(struct platform_device *pdev) { struct ssam_cdev *cdev = platform_get_drvdata(pdev); struct ssam_cdev_client *client; @@ -757,7 +756,6 @@ static int ssam_dbg_device_remove(struct platform_device *pdev) misc_deregister(&cdev->mdev); ssam_cdev_put(cdev); - return 0; } static struct platform_device *ssam_cdev_device; diff --git a/module/src/clients/surface_aggregator_registry.c b/module/src/clients/surface_aggregator_registry.c index 743e6a37..ced04aba 100644 --- a/module/src/clients/surface_aggregator_registry.c +++ b/module/src/clients/surface_aggregator_registry.c @@ -438,14 +438,13 @@ static int ssam_platform_hub_probe(struct platform_device *pdev) return status; } -static int ssam_platform_hub_remove(struct platform_device *pdev) +static void ssam_platform_hub_remove(struct platform_device *pdev) { const struct software_node **nodes = platform_get_drvdata(pdev); ssam_remove_clients(&pdev->dev); set_secondary_fwnode(&pdev->dev, NULL); software_node_unregister_node_group(nodes); - return 0; } static struct platform_driver ssam_platform_hub_driver = { diff --git a/module/src/clients/surface_aggregator_tabletsw.c b/module/src/clients/surface_aggregator_tabletsw.c index 2cef890e..279ebcc2 100644 --- a/module/src/clients/surface_aggregator_tabletsw.c +++ b/module/src/clients/surface_aggregator_tabletsw.c @@ -5,7 +5,7 @@ * Copyright (C) 2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/clients/surface_battery.c b/module/src/clients/surface_battery.c index b663d163..a932b3c9 100644 --- a/module/src/clients/surface_battery.c +++ b/module/src/clients/surface_battery.c @@ -6,7 +6,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/clients/surface_charger.c b/module/src/clients/surface_charger.c index ff4d048a..2fb530b6 100644 --- a/module/src/clients/surface_charger.c +++ b/module/src/clients/surface_charger.c @@ -6,7 +6,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/clients/surface_dtx.c b/module/src/clients/surface_dtx.c index 6cae73a9..8deca1b9 100644 --- a/module/src/clients/surface_dtx.c +++ b/module/src/clients/surface_dtx.c @@ -555,7 +555,6 @@ static const struct file_operations surface_dtx_fops = { .fasync = surface_dtx_fasync, .unlocked_ioctl = surface_dtx_ioctl, .compat_ioctl = surface_dtx_ioctl, - .llseek = no_llseek, }; @@ -1168,10 +1167,9 @@ static int surface_dtx_platform_probe(struct platform_device *pdev) return 0; } -static int surface_dtx_platform_remove(struct platform_device *pdev) +static void surface_dtx_platform_remove(struct platform_device *pdev) { sdtx_device_destroy(platform_get_drvdata(pdev)); - return 0; } static const struct acpi_device_id surface_dtx_acpi_match[] = { diff --git a/module/src/clients/surface_hid.c b/module/src/clients/surface_hid.c index e8f74a0a..c3509ed7 100644 --- a/module/src/clients/surface_hid.c +++ b/module/src/clients/surface_hid.c @@ -8,7 +8,7 @@ * Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/clients/surface_hid_core.c b/module/src/clients/surface_hid_core.c index 8c225e1c..de21ffc8 100644 --- a/module/src/clients/surface_hid_core.c +++ b/module/src/clients/surface_hid_core.c @@ -7,7 +7,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/clients/surface_kbd.c b/module/src/clients/surface_kbd.c index bd4316e9..d7d4189e 100644 --- a/module/src/clients/surface_kbd.c +++ b/module/src/clients/surface_kbd.c @@ -7,7 +7,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include @@ -271,10 +271,9 @@ static int surface_kbd_probe(struct platform_device *pdev) return surface_hid_device_add(shid); } -static int surface_kbd_remove(struct platform_device *pdev) +static void surface_kbd_remove(struct platform_device *pdev) { surface_hid_device_destroy(platform_get_drvdata(pdev)); - return 0; } static const struct acpi_device_id surface_kbd_match[] = { diff --git a/module/src/clients/surface_platform_profile.c b/module/src/clients/surface_platform_profile.c index 3b35e8ff..38053ad7 100644 --- a/module/src/clients/surface_platform_profile.c +++ b/module/src/clients/surface_platform_profile.c @@ -6,7 +6,7 @@ * Copyright (C) 2021-2022 Maximilian Luz */ -#include +#include #include #include #include @@ -29,7 +29,7 @@ struct ssam_tmp_profile_info { struct ssam_tmp_profile_device { struct ssam_device *sdev; - struct platform_profile_handler handler; + struct device *ppdev; }; SSAM_DEFINE_SYNC_REQUEST_CL_R(__ssam_tmp_profile_get, struct ssam_tmp_profile_info, { @@ -105,15 +105,13 @@ static int convert_profile_to_ssam(struct ssam_device *sdev, enum platform_profi } } -static int ssam_platform_profile_get(struct platform_profile_handler *pprof, +static int ssam_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { - struct ssam_tmp_profile_device *tpd; + struct ssam_tmp_profile_device *tpd = dev_get_drvdata(dev); enum ssam_tmp_profile tp; int status; - tpd = container_of(pprof, struct ssam_tmp_profile_device, handler); - status = ssam_tmp_profile_get(tpd->sdev, &tp); if (status) return status; @@ -126,14 +124,12 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof, return 0; } -static int ssam_platform_profile_set(struct platform_profile_handler *pprof, +static int ssam_platform_profile_set(struct device *dev, enum platform_profile_option profile) { - struct ssam_tmp_profile_device *tpd; + struct ssam_tmp_profile_device *tpd = dev_get_drvdata(dev); int tp; - tpd = container_of(pprof, struct ssam_tmp_profile_device, handler); - tp = convert_profile_to_ssam(tpd->sdev, profile); if (tp < 0) return tp; @@ -141,6 +137,22 @@ static int ssam_platform_profile_set(struct platform_profile_handler *pprof, return ssam_tmp_profile_set(tpd->sdev, tp); } +static int ssam_platform_profile_probe(void *drvdata, unsigned long *choices) +{ + set_bit(PLATFORM_PROFILE_LOW_POWER, choices); + set_bit(PLATFORM_PROFILE_BALANCED, choices); + set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); + + return 0; +} + +static const struct platform_profile_ops ssam_platform_profile_ops = { + .probe = ssam_platform_profile_probe, + .profile_get = ssam_platform_profile_get, + .profile_set = ssam_platform_profile_set, +}; + static int surface_platform_profile_probe(struct ssam_device *sdev) { struct ssam_tmp_profile_device *tpd; @@ -150,22 +162,18 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) return -ENOMEM; tpd->sdev = sdev; + ssam_device_set_drvdata(sdev, tpd); - tpd->handler.profile_get = ssam_platform_profile_get; - tpd->handler.profile_set = ssam_platform_profile_set; - - set_bit(PLATFORM_PROFILE_LOW_POWER, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices); - set_bit(PLATFORM_PROFILE_PERFORMANCE, tpd->handler.choices); - - platform_profile_register(&tpd->handler); - return 0; + tpd->ppdev = platform_profile_register(&sdev->dev, "surface_platform_profile", + tpd, &ssam_platform_profile_ops); + return PTR_ERR_OR_ZERO(tpd->ppdev); } static void surface_platform_profile_remove(struct ssam_device *sdev) { - platform_profile_remove(); + struct ssam_tmp_profile_device *tpd = ssam_device_get_drvdata(sdev); + + platform_profile_remove(tpd->ppdev); } static const struct ssam_device_id ssam_platform_profile_match[] = { diff --git a/module/src/core.c b/module/src/core.c index ec9705a2..97ae9150 100644 --- a/module/src/core.c +++ b/module/src/core.c @@ -227,8 +227,8 @@ EXPORT_SYMBOL_GPL(ssam_client_bind); /* -- Glue layer (serdev_device -> ssam_controller). ------------------------ */ -static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf, - size_t n) +static size_t ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf, + size_t n) { struct ssam_controller *ctrl; diff --git a/module/src/ssh_msgb.h b/module/src/ssh_msgb.h index 113a8763..9486d716 100644 --- a/module/src/ssh_msgb.h +++ b/module/src/ssh_msgb.h @@ -8,7 +8,7 @@ #ifndef _SURFACE_AGGREGATOR_SSH_MSGB_H #define _SURFACE_AGGREGATOR_SSH_MSGB_H -#include +#include #include #include "../include/linux/surface_aggregator/controller.h" diff --git a/module/src/ssh_packet_layer.c b/module/src/ssh_packet_layer.c index fdb80a60..94282226 100644 --- a/module/src/ssh_packet_layer.c +++ b/module/src/ssh_packet_layer.c @@ -5,7 +5,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/ssh_parser.c b/module/src/ssh_parser.c index 22c3c690..229bd57c 100644 --- a/module/src/ssh_parser.c +++ b/module/src/ssh_parser.c @@ -5,7 +5,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/ssh_request_layer.c b/module/src/ssh_request_layer.c index 215514e4..8536ce54 100644 --- a/module/src/ssh_request_layer.c +++ b/module/src/ssh_request_layer.c @@ -5,7 +5,7 @@ * Copyright (C) 2019-2022 Maximilian Luz */ -#include +#include #include #include #include diff --git a/module/src/trace.h b/module/src/trace.h index 328861b4..e6766a9a 100644 --- a/module/src/trace.h +++ b/module/src/trace.h @@ -13,7 +13,7 @@ #include "../include/linux/surface_aggregator/serial_hub.h" -#include +#include #include TRACE_DEFINE_ENUM(SSH_FRAME_TYPE_DATA_SEQ);