Skip to content

Commit 4e71d26

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: rename float_to_int() to amd_sfh_float_to_int()
Current amd_sfh driver has float_to_int() to convert units from float to int. This is fine until this function gets called outside of the current scope of file. Add a prefix "amd_sfh" to float_to_int() so that function represents the driver name. This function will be called by multiple callers in the next patch. Link: https://lore.kernel.org/all/ad064333-48a4-4cfa-9428-69e8a7c44667@redhat.com/ Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Co-developed-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 3f10e21 commit 4e71d26

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void get_common_inputs(struct common_input_property *common, int report_i
132132
common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM;
133133
}
134134

135-
static int float_to_int(u32 flt32_val)
135+
int amd_sfh_float_to_int(u32 flt32_val)
136136
{
137137
int fraction, shift, mantissa, sign, exp, zeropre;
138138

@@ -201,9 +201,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
201201
OFFSET_SENSOR_DATA_DEFAULT;
202202
memcpy_fromio(&accel_data, sensoraddr, sizeof(struct sfh_accel_data));
203203
get_common_inputs(&acc_input.common_property, report_id);
204-
acc_input.in_accel_x_value = float_to_int(accel_data.acceldata.x) / 100;
205-
acc_input.in_accel_y_value = float_to_int(accel_data.acceldata.y) / 100;
206-
acc_input.in_accel_z_value = float_to_int(accel_data.acceldata.z) / 100;
204+
acc_input.in_accel_x_value = amd_sfh_float_to_int(accel_data.acceldata.x) / 100;
205+
acc_input.in_accel_y_value = amd_sfh_float_to_int(accel_data.acceldata.y) / 100;
206+
acc_input.in_accel_z_value = amd_sfh_float_to_int(accel_data.acceldata.z) / 100;
207207
memcpy(input_report, &acc_input, sizeof(acc_input));
208208
report_size = sizeof(acc_input);
209209
break;
@@ -212,9 +212,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
212212
OFFSET_SENSOR_DATA_DEFAULT;
213213
memcpy_fromio(&gyro_data, sensoraddr, sizeof(struct sfh_gyro_data));
214214
get_common_inputs(&gyro_input.common_property, report_id);
215-
gyro_input.in_angel_x_value = float_to_int(gyro_data.gyrodata.x) / 1000;
216-
gyro_input.in_angel_y_value = float_to_int(gyro_data.gyrodata.y) / 1000;
217-
gyro_input.in_angel_z_value = float_to_int(gyro_data.gyrodata.z) / 1000;
215+
gyro_input.in_angel_x_value = amd_sfh_float_to_int(gyro_data.gyrodata.x) / 1000;
216+
gyro_input.in_angel_y_value = amd_sfh_float_to_int(gyro_data.gyrodata.y) / 1000;
217+
gyro_input.in_angel_z_value = amd_sfh_float_to_int(gyro_data.gyrodata.z) / 1000;
218218
memcpy(input_report, &gyro_input, sizeof(gyro_input));
219219
report_size = sizeof(gyro_input);
220220
break;
@@ -223,9 +223,9 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
223223
OFFSET_SENSOR_DATA_DEFAULT;
224224
memcpy_fromio(&mag_data, sensoraddr, sizeof(struct sfh_mag_data));
225225
get_common_inputs(&magno_input.common_property, report_id);
226-
magno_input.in_magno_x = float_to_int(mag_data.magdata.x) / 100;
227-
magno_input.in_magno_y = float_to_int(mag_data.magdata.y) / 100;
228-
magno_input.in_magno_z = float_to_int(mag_data.magdata.z) / 100;
226+
magno_input.in_magno_x = amd_sfh_float_to_int(mag_data.magdata.x) / 100;
227+
magno_input.in_magno_y = amd_sfh_float_to_int(mag_data.magdata.y) / 100;
228+
magno_input.in_magno_z = amd_sfh_float_to_int(mag_data.magdata.z) / 100;
229229
magno_input.in_magno_accuracy = mag_data.accuracy / 100;
230230
memcpy(input_report, &magno_input, sizeof(magno_input));
231231
report_size = sizeof(magno_input);
@@ -235,13 +235,15 @@ static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id,
235235
OFFSET_SENSOR_DATA_DEFAULT;
236236
memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data));
237237
get_common_inputs(&als_input.common_property, report_id);
238-
als_input.illuminance_value = float_to_int(als_data.lux);
238+
als_input.illuminance_value = amd_sfh_float_to_int(als_data.lux);
239239

240240
memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info));
241241
if (binfo.sbase.s_prop[ALS_IDX].sf.feat & 0x2) {
242242
als_input.light_color_temp = als_data.light_color_temp;
243-
als_input.chromaticity_x_value = float_to_int(als_data.chromaticity_x);
244-
als_input.chromaticity_y_value = float_to_int(als_data.chromaticity_y);
243+
als_input.chromaticity_x_value =
244+
amd_sfh_float_to_int(als_data.chromaticity_x);
245+
als_input.chromaticity_y_value =
246+
amd_sfh_float_to_int(als_data.chromaticity_y);
245247
}
246248

247249
report_size = sizeof(als_input);

drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,5 @@ struct hpd_status {
166166

167167
void sfh_interface_init(struct amd_mp2_dev *mp2);
168168
void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops);
169+
int amd_sfh_float_to_int(u32 flt32_val);
169170
#endif

0 commit comments

Comments
 (0)