From: Uwe Hermann Date: Tue, 11 Jul 2017 19:06:15 +0000 (+0200) Subject: Various log message cleanups. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=91057d2fc24c0ca058aa08c8ea6ada4eadf05ffd;p=libsigrok.git Various log message cleanups. Drop unneeded log messages, add some others that might be useful, document which ones we're intentionally not emitting. Don't log "$operation successful" type of messages in most cases, that's too verbose; logging failures only is sufficient there. baylibre-acme: Don't log "No such file or directory" messages during scan, this triggers on all kinds of unrelated devices (e.g. "AMDGPU i2c bit bus 0x91" in this case): sr: [...] baylibre-acme: Name for probe 1 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0040/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 2 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0041/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 3 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0044/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 4 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0045/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 5 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0042/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 5 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-004c/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 6 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0043/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 6 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0049/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 7 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0046/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 7 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-004f/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 8 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-0047/name”: No such file or directory sr: [...] baylibre-acme: Name for probe 8 can't be read: Failed to open file “/sys/class/i2c-adapter/i2c-1/1-004b/name”: No such file or directory --- diff --git a/src/device.c b/src/device.c index e58c1790..1394fb3b 100644 --- a/src/device.c +++ b/src/device.c @@ -546,6 +546,8 @@ SR_API int sr_dev_clear(const struct sr_dev_driver *driver) return SR_OK; } + /* No log message here, too verbose and not very useful. */ + if (driver->dev_clear) ret = driver->dev_clear(driver); else diff --git a/src/hardware/baylibre-acme/protocol.c b/src/hardware/baylibre-acme/protocol.c index 0311f68e..a6ff339b 100644 --- a/src/hardware/baylibre-acme/protocol.c +++ b/src/hardware/baylibre-acme/protocol.c @@ -166,8 +166,10 @@ SR_PRIV gboolean bl_acme_detect_probe(unsigned int addr, probe_name_path(addr, path); status = g_file_get_contents(path->str, &buf, &size, &err); if (!status) { - sr_dbg("Name for probe %d can't be read: %s", - prb_num, err->message); + /* Don't log "No such file or directory" messages. */ + if (err->code != G_FILE_ERROR_NOENT) + sr_dbg("Name for probe %d can't be read (%d): %s", + prb_num, err->code, err->message); g_string_free(path, TRUE); g_error_free(err); return ret; diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 23b42e13..5a5f3580 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -107,9 +107,6 @@ static int dev_open(struct sr_dev_inst *sdi) return SR_ERR; } devc->detached_kernel_driver = 1; - sr_dbg("Successfully detached kernel driver."); - } else { - sr_dbg("No need to detach a kernel driver."); } /* Claim interface 0. */ @@ -118,7 +115,6 @@ static int dev_open(struct sr_dev_inst *sdi) libusb_error_name(ret)); return SR_ERR; } - sr_dbg("Successfully claimed interface 0."); return SR_OK; } diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 0c94b398..8824abbd 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -251,7 +251,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_ftdi_free; } - sr_dbg("Device opened successfully."); /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { @@ -259,7 +258,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_ftdi_free; } - sr_dbg("FTDI buffers purged successfully."); /* Enable flow control in the FTDI chip. */ if ((ret = ftdi_setflowctrl(devc->ftdic, SIO_RTS_CTS_HS)) < 0) { @@ -267,7 +265,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_ftdi_free; } - sr_dbg("FTDI flow control enabled successfully."); /* Wait 100ms. */ g_usleep(100 * 1000); @@ -522,8 +519,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_ERR; } - sr_dbg("Hardware acquisition started successfully."); - std_session_send_df_header(sdi); /* Time when we should be done (for detecting trigger timeouts). */ diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 0dd0a38a..b0a59316 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -497,8 +497,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) bitpos = devc->enabled_logic_channels % 8; mask = (1 << bitpos) - 1; devc->first_partial_logic_mask = mask; - sr_dbg("DBG: %s(), num logic %zu, partial off %zu, mask 0x%02x", - __func__, devc->enabled_logic_channels, + sr_dbg("num logic %zu, partial off %zu, mask 0x%02x.", + devc->enabled_logic_channels, devc->first_partial_logic_index, devc->first_partial_logic_mask); diff --git a/src/hardware/demo/protocol.c b/src/hardware/demo/protocol.c index 38943e43..8b89d354 100644 --- a/src/hardware/demo/protocol.c +++ b/src/hardware/demo/protocol.c @@ -384,7 +384,6 @@ static void send_analog_packet(struct analog_gen *ag, ag->packet.data = ag->pattern_data + ag_pattern_pos; ag->packet.num_samples = sending_now; sr_session_send(sdi, &packet); - sr_dbg("DBG: %s() sending now: %lu", __func__, (unsigned long)sending_now); /* Whichever channel group gets there first. */ *analog_sent = MAX(*analog_sent, sending_now); @@ -461,14 +460,12 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data) /* How many samples are outstanding since the last round? */ samples_todo = (todo_us * devc->cur_samplerate + G_USEC_PER_SEC - 1) / G_USEC_PER_SEC; - sr_dbg("DBG: %s() samples_todo before adjustment: %lu", __func__, (unsigned long)samples_todo); if (devc->limit_samples > 0) { if (devc->limit_samples < devc->sent_samples) samples_todo = 0; else if (devc->limit_samples - devc->sent_samples < samples_todo) samples_todo = devc->limit_samples - devc->sent_samples; } - sr_dbg("DBG: %s() samples_todo after adjustment: %lu", __func__, (unsigned long)samples_todo); /* Calculate the actual time covered by this run back from the sample * count, rounded towards zero. This avoids getting stuck on a too-low * time delta with no samples being sent due to round-off. @@ -507,10 +504,8 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data) send_analog_packet(value, sdi, &analog_sent, devc->sent_samples + analog_done, samples_todo - analog_done); - sr_dbg("DBG: %s() analog_sent: %lu", __func__, (unsigned long)analog_sent); } analog_done += analog_sent; - sr_dbg("DBG: %s() analog_done: %lu", __func__, (unsigned long)analog_done); } } /* At this point, both logic_done and analog_done should be diff --git a/src/hardware/ftdi-la/api.c b/src/hardware/ftdi-la/api.c index 5a7ac51e..b1832ee3 100644 --- a/src/hardware/ftdi-la/api.c +++ b/src/hardware/ftdi-la/api.c @@ -178,8 +178,6 @@ static GSList *scan_all(struct ftdi_context *ftdic, GSList *options) return NULL; } - sr_dbg("Number of FTDI devices found: %d", ret); - curdev = devlist; while (curdev) { scan_device(ftdic, curdev->dev, &devices); @@ -283,7 +281,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip buffers purged successfully."); /* Reset the FTDI bitmode. */ ret = ftdi_set_bitmode(devc->ftdic, 0x00, BITMODE_RESET); @@ -292,7 +289,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip bitmode reset successfully."); ret = ftdi_set_bitmode(devc->ftdic, 0x00, BITMODE_BITBANG); if (ret < 0) { @@ -300,7 +296,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip bitbang mode entered successfully."); return SR_OK; diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 8bac10f1..332c9017 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -159,8 +159,6 @@ static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options) conn = serialcomm = NULL; serialcomm_given = FALSE; - sr_spew("scan_1x_2x_rs232() called!"); - for (l = options; l; l = l->next) { src = l->data; switch (src->key) { @@ -242,8 +240,6 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options) conn = serialcomm = NULL; devices = NULL; - sr_spew("scan_2x_bd232() called!"); - for (l = options; l; l = l->next) { src = l->data; switch (src->key) { @@ -321,8 +317,6 @@ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); exit_err: - sr_info("scan_2x_bd232(): Error!"); - sr_serial_dev_inst_free(serial); g_free(devc); sr_dev_inst_free(sdi); diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index b4168513..3b8175c8 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -423,8 +423,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) usb_source_add(sdi->session, drvc->sr_ctx, 100, ikalogic_scanalogic2_receive_data, (void *)sdi); - sr_dbg("Acquisition started successfully."); - std_session_send_df_header(sdi); devc->next_state = STATE_SAMPLE; diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index 79585f06..9f8f2506 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -143,7 +143,6 @@ static int dev_open(struct sr_dev_inst *sdi) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI chip interface A set successfully."); /* Open the device. */ ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID, @@ -153,7 +152,6 @@ static int dev_open(struct sr_dev_inst *sdi) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI device opened successfully."); /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { @@ -161,7 +159,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip buffers purged successfully."); /* Reset the FTDI bitmode. */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET); @@ -170,7 +167,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip bitmode reset successfully."); /* Set FTDI bitmode to "sync FIFO". */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_SYNCFF); @@ -179,7 +175,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip sync FIFO mode entered successfully."); /* Set the FTDI latency timer to 2. */ ret = ftdi_set_latency_timer(devc->ftdic, 2); @@ -188,7 +183,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip latency timer set successfully."); /* Set the FTDI read data chunk size to 64kB. */ ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024); @@ -197,7 +191,6 @@ static int dev_open(struct sr_dev_inst *sdi) ret, ftdi_get_error_string(devc->ftdic)); goto err_dev_open_close_ftdic; } - sr_dbg("FTDI chip read data chunk size set successfully."); /* Get the ScanaPLUS device ID from the FTDI EEPROM. */ if ((ret = scanaplus_get_device_id(devc)) < 0) { diff --git a/src/hardware/motech-lps-30x/api.c b/src/hardware/motech-lps-30x/api.c index 5ec71e68..88e4449e 100644 --- a/src/hardware/motech-lps-30x/api.c +++ b/src/hardware/motech-lps-30x/api.c @@ -386,8 +386,6 @@ static GSList *do_scan(lps_modelid modelid, struct sr_dev_driver *drv, GSList *o devc = NULL; conn = serialcomm = NULL; - sr_spew("scan() called!"); - /* Process and check options. */ if (sr_serial_extract_options(options, &conn, &serialcomm) != SR_OK) return NULL; diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index aaff5115..dbe79c6a 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -80,7 +80,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI chip interface B set successfully."); /* Check for the device and temporarily open it. */ ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID, @@ -92,7 +91,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI device opened successfully."); /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { @@ -100,7 +98,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip buffers purged successfully."); /* Reset the FTDI bitmode. */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET); @@ -109,7 +106,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip bitmode reset successfully."); /* Set the FTDI latency timer to 16. */ ret = ftdi_set_latency_timer(devc->ftdic, 16); @@ -118,7 +114,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip latency timer set successfully."); /* Set the FTDI read data chunk size to 64kB. */ ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024); @@ -127,7 +122,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip read data chunk size set successfully."); return SR_OK; diff --git a/src/hardware/uni-t-dmm/protocol.c b/src/hardware/uni-t-dmm/protocol.c index 6dc8980e..4114aec4 100644 --- a/src/hardware/uni-t-dmm/protocol.c +++ b/src/hardware/uni-t-dmm/protocol.c @@ -111,9 +111,6 @@ static int hid_chip_init(struct sr_dev_inst *sdi, uint16_t baudrate) libusb_error_name(ret)); return SR_ERR; } - sr_dbg("Successfully detached kernel driver."); - } else { - sr_dbg("No need to detach a kernel driver."); } /* Claim interface 0. */ @@ -122,7 +119,6 @@ static int hid_chip_init(struct sr_dev_inst *sdi, uint16_t baudrate) libusb_error_name(ret)); return SR_ERR; } - sr_dbg("Successfully claimed interface 0."); /* Set data for the HID feature report (e.g. baudrate). */ buf[0] = baudrate & 0xff; /* Baudrate, LSB */ @@ -158,8 +154,6 @@ static int hid_chip_init(struct sr_dev_inst *sdi, uint16_t baudrate) return SR_ERR; } - sr_dbg("Successfully sent initial HID feature report."); - return SR_OK; } diff --git a/src/hwdriver.c b/src/hwdriver.c index fbc5fe7a..3e6b0012 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -394,6 +394,8 @@ SR_API int sr_driver_init(struct sr_context *ctx, struct sr_dev_driver *driver) return SR_ERR_ARG; } + /* No log message here, too verbose and not very useful. */ + if ((ret = driver->init(driver, ctx)) < 0) sr_err("Failed to initialize the driver: %d.", ret); @@ -527,8 +529,7 @@ SR_API GSList *sr_driver_scan(struct sr_dev_driver *driver, GSList *options) l = driver->scan(driver, options); - sr_spew("Scan of '%s' found %d devices.", driver->name, - g_slist_length(l)); + sr_spew("Scan found %d devices (%s).", g_slist_length(l), driver->name); return l; } @@ -548,6 +549,8 @@ SR_PRIV void sr_hw_cleanup_all(const struct sr_context *ctx) if (!ctx) return; + sr_dbg("Cleaning up all drivers."); + drivers = sr_driver_list(ctx); for (i = 0; drivers[i]; i++) { if (drivers[i]->cleanup) @@ -581,7 +584,6 @@ SR_PRIV struct sr_config *sr_config_new(uint32_t key, GVariant *data) */ SR_PRIV void sr_config_free(struct sr_config *src) { - if (!src || !src->data) { sr_err("%s: invalid data!", __func__); return; @@ -589,7 +591,6 @@ SR_PRIV void sr_config_free(struct sr_config *src) g_variant_unref(src->data); g_free(src); - } /** @private */ diff --git a/src/scpi/scpi_usbtmc_libusb.c b/src/scpi/scpi_usbtmc_libusb.c index 5e8b2676..6f2bc819 100644 --- a/src/scpi/scpi_usbtmc_libusb.c +++ b/src/scpi/scpi_usbtmc_libusb.c @@ -155,7 +155,7 @@ static GSList *scpi_usbtmc_libusb_scan(struct drv_context *drvc) } libusb_free_device_list(devlist, 1); - sr_dbg("Found %d device(s).", g_slist_length(resources)); + /* No log message for #devices found (caller will log that). */ return resources; } diff --git a/src/usb.c b/src/usb.c index c4d55673..96df219f 100644 --- a/src/usb.c +++ b/src/usb.c @@ -329,8 +329,7 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn) if ((mstr = g_match_info_fetch(match, 2))) pid = strtoul(mstr, NULL, 16); g_free(mstr); - sr_dbg("Trying to find USB device with VID:PID = %04x:%04x.", - vid, pid); + /* Trying to find USB device via VID:PID. */ } else { g_match_info_unref(match); g_regex_unref(reg); @@ -343,8 +342,7 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn) if ((mstr = g_match_info_fetch(match, 2))) addr = strtoul(mstr, NULL, 10); g_free(mstr); - sr_dbg("Trying to find USB device with bus.address = " - "%d.%d.", bus, addr); + /* Trying to find USB device via bus.address. */ } } g_match_info_unref(match); @@ -392,7 +390,7 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn) } libusb_free_device_list(devlist, 1); - sr_dbg("Found %d device(s).", g_slist_length(devices)); + /* No log message for #devices found (caller will log that). */ return devices; }