Switch to the __DEVICE_ATTR() macro which can handle callbacks taking both const and non-const attribute structure arguments. Allow the step-wise migration of the drivers. Also use container_of_const() over container_of() to avoid casting away the constness accidentally.
Showing the changes to include (1 of 2 files). Show all
Unified · Split
| @@ -15,10 +15,10 @@ struct sensor_device_attribute{ · 14 unmodified lines | ||
| 15 | 15 | int index; |
| 16 | 16 | }; |
| 17 | 17 | #define to_sensor_dev_attr(_dev_attr) \ |
| 18 | − container_of(_dev_attr, struct sensor_device_attribute, dev_attr) | |
| 18 | + container_of_const(_dev_attr, struct sensor_device_attribute, dev_attr) | |
| 19 | 19 | |
| 20 | −#define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ | |
| 21 | − { .dev_attr = __ATTR(_name, _mode, _show, _store), \ | |
| 20 | +#define SENSOR_ATTR(_name, _mode, _show, _store, _index) \ | |
| 21 | + { .dev_attr = __DEVICE_ATTR(_name, _mode, _show, _store), \ | |
| 22 | 22 | .index = _index } |
| 23 | 23 | |
| 24 | 24 | #define SENSOR_ATTR_RO(_name, _func, _index) \ |
| @@ -49,11 +49,11 @@ struct sensor_device_attribute_2 { · 24 unmodified lines | ||
| 49 | 49 | u8 nr; |
| 50 | 50 | }; |
| 51 | 51 | #define to_sensor_dev_attr_2(_dev_attr) \ |
| 52 | − container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr) | |
| 52 | + container_of_const(_dev_attr, struct sensor_device_attribute_2, dev_attr) | |
| 53 | 53 | |
| 54 | −#define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ | |
| 55 | − { .dev_attr = __ATTR(_name, _mode, _show, _store), \ | |
| 56 | − .index = _index, \ | |
| 54 | +#define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \ | |
| 55 | + { .dev_attr = __DEVICE_ATTR(_name, _mode, _show, _store), \ | |
| 56 | + .index = _index, \ | |
| 57 | 57 | .nr = _nr } |
| 58 | 58 | |
| 59 | 59 | #define SENSOR_ATTR_2_RO(_name, _func, _nr, _index) \ |