Skip to content

Commit

Permalink
move get_i2c_device_numbers_using_udev() from udev_i2c_util.c to i2c_…
Browse files Browse the repository at this point in the history
…bus_core.c
  • Loading branch information
rockowitz committed Nov 9, 2024
1 parent e64be9c commit 58fd947
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
35 changes: 35 additions & 0 deletions src/i2c/i2c_bus_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,41 @@ i2c_non_async_scan(GPtrArray * i2c_buses) {
// Attached buses
//


// moved from udev_i2c_util.c


/** Gets the numbers of I2C devices
*
* \param include_ignorable_devices if true, do not exclude SMBus and other ignorable devices
* \return sorted #Byte_Value_Array of I2C device numbers, caller is responsible for freeing
*/
Byte_Value_Array
get_i2c_device_numbers_using_udev(bool include_ignorable_devices) {
bool debug = false;
DBGF(debug, "Starting.");

Byte_Value_Array bva = bva_create();

GPtrArray * summaries = get_i2c_devices_using_udev();
if (summaries) {
for (int ndx = 0; ndx < summaries->len; ndx++) {
Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx);
int busno = udev_i2c_device_summary_busno(summary);
assert(busno >= 0);
assert(busno <= 127);
if ( include_ignorable_devices || !sysfs_is_ignorable_i2c_device(busno) )
bva_append(bva, busno);
}
free_udev_device_summaries(summaries);
}

if (debug)
bva_report(bva, "Returning I2c bus numbers:");
return bva;
}


Bit_Set_256 attached_buses;


Expand Down
5 changes: 5 additions & 0 deletions src/i2c/i2c_bus_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ Status_Errno i2c_check_bus2(I2C_Bus_Info * businfo);
Error_Info * i2c_check_open_bus_alive(Display_Handle * dh);

// Bus inventory - detect and probe buses

Byte_Value_Array // one byte for each I2C bus number
get_i2c_device_numbers_using_udev(bool include_ignorable_devices);


Bit_Set_256 buses_bitset_from_businfo_array(GPtrArray * buses, bool only_connected); // buses: array of I2C_Bus_Info
GPtrArray * i2c_detect_buses0();
int i2c_detect_buses(); // creates internal array of Bus_Info for I2C buses
Expand Down
29 changes: 0 additions & 29 deletions src/util/udev_i2c_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,35 +179,6 @@ is_smbus_device_summary(GPtrArray * summaries, char * sbusno) {
#endif


/** Gets the numbers of I2C devices
*
* \param include_ignorable_devices if true, do not exclude SMBus and other ignorable devices
* \return sorted #Byte_Value_Array of I2C device numbers, caller is responsible for freeing
*/
Byte_Value_Array
get_i2c_device_numbers_using_udev(bool include_ignorable_devices) {
bool debug = false;
DBGF(debug, "Starting.");

Byte_Value_Array bva = bva_create();

GPtrArray * summaries = get_i2c_devices_using_udev();
if (summaries) {
for (int ndx = 0; ndx < summaries->len; ndx++) {
Udev_Device_Summary * summary = g_ptr_array_index(summaries, ndx);
int busno = udev_i2c_device_summary_busno(summary);
assert(busno >= 0);
assert(busno <= 127);
if ( include_ignorable_devices || !sysfs_is_ignorable_i2c_device(busno) )
bva_append(bva, busno);
}
free_udev_device_summaries(summaries);
}

if (debug)
bva_report(bva, "Returning I2c bus numbers:");
return bva;
}


/** Gets the bus numbers of I2C devices reported by UDEV,
Expand Down
2 changes: 0 additions & 2 deletions src/util/udev_i2c_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ report_i2c_udev_device_summaries(
int depth) ;


Byte_Value_Array // one byte for each I2C bus number
get_i2c_device_numbers_using_udev(bool include_ignorable_devices);

/** Signature of function that tests sys attribute name */
typedef bool (*Sysattr_Name_Filter)(const char * sysattr_name);
Expand Down

0 comments on commit 58fd947

Please sign in to comment.