trace_thermal_zone_trip(tz, thermal_zone_trip_id(tz, trip), trip->type);
 
        if (trip->type == THERMAL_TRIP_CRITICAL)
-               tz->ops->critical(tz);
-       else if (tz->ops->hot)
-               tz->ops->hot(tz);
+               tz->ops.critical(tz);
+       else if (tz->ops.hot)
+               tz->ops.hot(tz);
 }
 
 static void handle_thermal_trip(struct thermal_zone_device *tz,
                return ret;
        }
 
-       if (tz->ops->change_mode)
-               ret = tz->ops->change_mode(tz, mode);
+       if (tz->ops.change_mode)
+               ret = tz->ops.change_mode(tz, mode);
 
        if (!ret)
                tz->mode = mode;
        struct thermal_zone_device *pos = NULL;
 
        list_for_each_entry(pos, &thermal_tz_list, node) {
-               if (pos->ops->bind) {
-                       ret = pos->ops->bind(pos, cdev);
+               if (pos->ops.bind) {
+                       ret = pos->ops.bind(pos, cdev);
                        if (ret)
                                print_bind_err_msg(pos, cdev, ret);
                }
 
        /* Unbind all thermal zones associated with 'this' cdev */
        list_for_each_entry(tz, &thermal_tz_list, node) {
-               if (tz->ops->unbind)
-                       tz->ops->unbind(tz, cdev);
+               if (tz->ops.unbind)
+                       tz->ops.unbind(tz, cdev);
        }
 
        mutex_unlock(&thermal_list_lock);
        int ret;
        struct thermal_cooling_device *pos = NULL;
 
-       if (!tz->ops->bind)
+       if (!tz->ops.bind)
                return;
 
        mutex_lock(&thermal_list_lock);
 
        list_for_each_entry(pos, &thermal_cdev_list, node) {
-               ret = tz->ops->bind(tz, pos);
+               ret = tz->ops.bind(tz, pos);
                if (ret)
                        print_bind_err_msg(tz, pos, ret);
        }
 {
        int i, ret = -EINVAL;
 
-       if (tz->ops->get_crit_temp)
-               return tz->ops->get_crit_temp(tz, temp);
+       if (tz->ops.get_crit_temp)
+               return tz->ops.get_crit_temp(tz, temp);
 
        mutex_lock(&tz->lock);
 
                                        const struct thermal_trip *trips,
                                        int num_trips, int mask,
                                        void *devdata,
-                                       struct thermal_zone_device_ops *ops,
+                                       const struct thermal_zone_device_ops *ops,
                                        const struct thermal_zone_params *tzp,
                                        int passive_delay, int polling_delay)
 {
        tz->id = id;
        strscpy(tz->type, type, sizeof(tz->type));
 
-       if (!ops->critical)
-               ops->critical = thermal_zone_device_critical;
+       tz->ops = *ops;
+       if (!tz->ops.critical)
+               tz->ops.critical = thermal_zone_device_critical;
 
-       tz->ops = ops;
        tz->device.class = thermal_class;
        tz->devdata = devdata;
        memcpy(tz->trips, trips, num_trips * sizeof(*trips));
 struct thermal_zone_device *thermal_tripless_zone_device_register(
                                        const char *type,
                                        void *devdata,
-                                       struct thermal_zone_device_ops *ops,
+                                       const struct thermal_zone_device_ops *ops,
                                        const struct thermal_zone_params *tzp)
 {
        return thermal_zone_device_register_with_trips(type, NULL, 0, 0, devdata,
 
        /* Unbind all cdevs associated with 'this' thermal zone */
        list_for_each_entry(cdev, &thermal_cdev_list, node)
-               if (tz->ops->unbind)
-                       tz->ops->unbind(tz, cdev);
+               if (tz->ops.unbind)
+                       tz->ops.unbind(tz, cdev);
 
        mutex_unlock(&thermal_list_lock);
 
 
 {
        enum thermal_trend trend;
 
-       if (tz->emul_temperature || !tz->ops->get_trend ||
-           tz->ops->get_trend(tz, trip, &trend)) {
+       if (tz->emul_temperature || !tz->ops.get_trend ||
+           tz->ops.get_trend(tz, trip, &trend)) {
                if (tz->temperature > tz->last_temperature)
                        trend = THERMAL_TREND_RAISING;
                else if (tz->temperature < tz->last_temperature)
  * temperature and fill @temp.
  *
  * Both tz and tz->ops must be valid pointers when calling this function,
- * and the tz->ops->get_temp callback must be provided.
+ * and the tz->ops.get_temp callback must be provided.
  * The function must be called under tz->lock.
  *
  * Return: On success returns 0, an error code otherwise
 
        lockdep_assert_held(&tz->lock);
 
-       ret = tz->ops->get_temp(tz, temp);
+       ret = tz->ops.get_temp(tz, temp);
 
        if (IS_ENABLED(CONFIG_THERMAL_EMULATION) && tz->emul_temperature) {
                for_each_trip(tz, trip) {
 
        mutex_lock(&tz->lock);
 
-       if (!tz->ops->get_temp) {
+       if (!tz->ops.get_temp) {
                ret = -EINVAL;
                goto unlock;
        }
 
 
        mutex_lock(&tz->lock);
 
-       ret = tz->ops->get_crit_temp(tz, &temperature);
+       ret = tz->ops.get_crit_temp(tz, &temperature);
 
        mutex_unlock(&tz->lock);
 
 static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz)
 {
        int temp;
-       return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp);
+       return tz->ops.get_crit_temp && !tz->ops.get_crit_temp(tz, &temp);
 }
 
 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
 
  */
 static void thermal_of_zone_unregister(struct thermal_zone_device *tz)
 {
-       struct thermal_zone_device_ops *ops = tz->ops;
-
        thermal_zone_device_disable(tz);
        thermal_zone_device_unregister(tz);
-       kfree(ops);
 }
 
 /**
 static struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor, int id, void *data,
                                                            const struct thermal_zone_device_ops *ops)
 {
+       struct thermal_zone_device_ops of_ops = *ops;
        struct thermal_zone_device *tz;
        struct thermal_trip *trips;
        struct thermal_zone_params tzp = {};
-       struct thermal_zone_device_ops *of_ops;
        struct device_node *np;
        const char *action;
        int delay, pdelay;
        int ntrips, mask;
        int ret;
 
-       of_ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL);
-       if (!of_ops)
-               return ERR_PTR(-ENOMEM);
-
        np = of_thermal_zone_find(sensor, id);
        if (IS_ERR(np)) {
                if (PTR_ERR(np) != -ENODEV)
                        pr_err("Failed to find thermal zone for %pOFn id=%d\n", sensor, id);
-               ret = PTR_ERR(np);
-               goto out_kfree_of_ops;
+               return ERR_CAST(np);
        }
 
        trips = thermal_of_trips_init(np, &ntrips);
        if (IS_ERR(trips)) {
                pr_err("Failed to find trip points for %pOFn id=%d\n", sensor, id);
-               ret = PTR_ERR(trips);
-               goto out_kfree_of_ops;
+               return ERR_CAST(trips);
        }
 
        ret = thermal_of_monitor_init(np, &delay, &pdelay);
 
        thermal_of_parameters_init(np, &tzp);
 
-       of_ops->bind = thermal_of_bind;
-       of_ops->unbind = thermal_of_unbind;
+       of_ops.bind = thermal_of_bind;
+       of_ops.unbind = thermal_of_unbind;
 
        mask = GENMASK_ULL((ntrips) - 1, 0);
 
        ret = of_property_read_string(np, "critical-action", &action);
        if (!ret)
-               if (!of_ops->critical && !strcasecmp(action, "reboot"))
-                       of_ops->critical = thermal_zone_device_critical_reboot;
+               if (!of_ops.critical && !strcasecmp(action, "reboot"))
+                       of_ops.critical = thermal_zone_device_critical_reboot;
 
        tz = thermal_zone_device_register_with_trips(np->name, trips, ntrips,
-                                                    mask, data, of_ops, &tzp,
+                                                    mask, data, &of_ops, &tzp,
                                                     pdelay, delay);
        if (IS_ERR(tz)) {
                ret = PTR_ERR(tz);
 
 out_kfree_trips:
        kfree(trips);
-out_kfree_of_ops:
-       kfree(of_ops);
 
        return ERR_PTR(ret);
 }
 
        trip = &tz->trips[trip_id];
 
        if (temp != trip->temperature) {
-               if (tz->ops->set_trip_temp) {
-                       ret = tz->ops->set_trip_temp(tz, trip_id, temp);
+               if (tz->ops.set_trip_temp) {
+                       ret = tz->ops.set_trip_temp(tz, trip_id, temp);
                        if (ret)
                                goto unlock;
                }
        trip = &tz->trips[trip_id];
 
        if (hyst != trip->hysteresis) {
-               if (tz->ops->set_trip_hyst) {
-                       ret = tz->ops->set_trip_hyst(tz, trip_id, hyst);
+               if (tz->ops.set_trip_hyst) {
+                       ret = tz->ops.set_trip_hyst(tz, trip_id, hyst);
                        if (ret)
                                goto unlock;
                }
 
        mutex_lock(&tz->lock);
 
-       if (!tz->ops->set_emul_temp)
+       if (!tz->ops.set_emul_temp)
                tz->emul_temperature = temperature;
        else
-               ret = tz->ops->set_emul_temp(tz, temperature);
+               ret = tz->ops.set_emul_temp(tz, temperature);
 
        if (!ret)
                __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
                                        tz->trip_hyst_attrs[indx].name;
                tz->trip_hyst_attrs[indx].attr.attr.mode = S_IRUGO;
                tz->trip_hyst_attrs[indx].attr.show = trip_point_hyst_show;
-               if (tz->ops->set_trip_hyst) {
+               if (tz->ops.set_trip_hyst) {
                        tz->trip_hyst_attrs[indx].attr.attr.mode |= S_IWUSR;
                        tz->trip_hyst_attrs[indx].attr.store =
                                        trip_point_hyst_store;
 
 
        lockdep_assert_held(&tz->lock);
 
-       if (!tz->ops->set_trips)
+       if (!tz->ops.set_trips)
                return;
 
        for_each_trip(tz, trip) {
         * Set a temperature window. When this window is left the driver
         * must inform the thermal core via thermal_zone_device_update.
         */
-       ret = tz->ops->set_trips(tz, low, high);
+       ret = tz->ops.set_trips(tz, low, high);
        if (ret)
                dev_err(&tz->device, "Failed to set trips: %d\n", ret);
 }
 
        int prev_low_trip;
        int prev_high_trip;
        atomic_t need_update;
-       struct thermal_zone_device_ops *ops;
+       struct thermal_zone_device_ops ops;
        struct thermal_zone_params *tzp;
        struct thermal_governor *governor;
        void *governor_data;
                                        const struct thermal_trip *trips,
                                        int num_trips, int mask,
                                        void *devdata,
-                                       struct thermal_zone_device_ops *ops,
+                                       const struct thermal_zone_device_ops *ops,
                                        const struct thermal_zone_params *tzp,
                                        int passive_delay, int polling_delay);
 
 struct thermal_zone_device *thermal_tripless_zone_device_register(
                                        const char *type,
                                        void *devdata,
-                                       struct thermal_zone_device_ops *ops,
+                                       const struct thermal_zone_device_ops *ops,
                                        const struct thermal_zone_params *tzp);
 
 void thermal_zone_device_unregister(struct thermal_zone_device *tz);
                                        const struct thermal_trip *trips,
                                        int num_trips, int mask,
                                        void *devdata,
-                                       struct thermal_zone_device_ops *ops,
+                                       const struct thermal_zone_device_ops *ops,
                                        const struct thermal_zone_params *tzp,
                                        int passive_delay, int polling_delay)
 { return ERR_PTR(-ENODEV); }