]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cros_ec: Convert dm_cros_ec_get_ops into an inline function and constify dm_cros_ec_ops
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Fri, 12 Jun 2026 01:59:06 +0000 (03:59 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 29 Jun 2026 21:29:44 +0000 (15:29 -0600)
Convert dm_cros_ec_get_ops into an inline function to improve compiler
code coverage, and constify struct dm_cros_ec_ops in a few places.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/misc/cros_ec.c
include/cros_ec.h

index c3e647edfac62dae60af2f68c6822557ffdec6bc..e163224b8e3631cc8103e94a5f672dd12b16524c 100644 (file)
@@ -258,7 +258,7 @@ static int send_command_proto3(struct cros_ec_dev *cdev,
                               const void *dout, int dout_len,
                               uint8_t **dinp, int din_len)
 {
-       struct dm_cros_ec_ops *ops;
+       const struct dm_cros_ec_ops *ops;
        int out_bytes, in_bytes;
        int rv;
 
@@ -287,7 +287,7 @@ static int send_command(struct cros_ec_dev *dev, uint cmd, int cmd_version,
                        const void *dout, int dout_len,
                        uint8_t **dinp, int din_len)
 {
-       struct dm_cros_ec_ops *ops;
+       const struct dm_cros_ec_ops *ops;
        int ret = -1;
 
        /* Handle protocol version 3 support */
@@ -756,9 +756,8 @@ int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
 static int cros_ec_check_version(struct udevice *dev)
 {
        struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
+       const struct dm_cros_ec_ops *ops;
        struct ec_params_hello req;
-
-       struct dm_cros_ec_ops *ops;
        int ret;
 
        ops = dm_cros_ec_get_ops(dev);
@@ -1638,7 +1637,7 @@ int cros_ec_vstore_write(struct udevice *dev, int slot, const uint8_t *data,
 
 int cros_ec_get_switches(struct udevice *dev)
 {
-       struct dm_cros_ec_ops *ops;
+       const struct dm_cros_ec_ops *ops;
        int ret;
 
        ops = dm_cros_ec_get_ops(dev);
index 4ef34815e35c4f66646a34377bcb14e3b7a762c5..6e5153ceb6a6bd5adfa8235cacb45a155d3d64fc 100644 (file)
@@ -12,6 +12,7 @@
 #include <ec_commands.h>
 #include <cros_ec_message.h>
 #include <asm/gpio.h>
+#include <dm/device.h>
 #include <dm/of_extra.h>
 
 /*
@@ -316,8 +317,10 @@ struct dm_cros_ec_ops {
        int (*get_switches)(struct udevice *dev);
 };
 
-#define dm_cros_ec_get_ops(dev) \
-               ((struct dm_cros_ec_ops *)(dev)->driver->ops)
+static inline const struct dm_cros_ec_ops *dm_cros_ec_get_ops(struct udevice *dev)
+{
+       return (const struct dm_cros_ec_ops *)(dev->driver->ops);
+}
 
 int cros_ec_register(struct udevice *dev);