Message ID | 20240805-siano-v1-1-6da2bc740267@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | media: siano: Simplify smscore_load_firmware_from_file | expand |
Em Mon, 05 Aug 2024 07:59:43 +0000 Ricardo Ribalda <ribalda@chromium.org> escreveu: > The function is never called with a loadfirmware_handler, so we can > remove some dead code. > > We can also use this as a excuse to remove some unused type definitions. > > This fixes the following smatch warning: > drivers/media/common/siano/smscoreapi.c:1172 smscore_load_firmware_from_file() error: we previously assumed 'loadfirmware_handler' could be null (see line 1150) > > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> LGTM. > --- > Originally reported by Hans. Please add a reported-by field. > --- > drivers/media/common/siano/smscoreapi.c | 15 +++++---------- > drivers/media/common/siano/smscoreapi.h | 4 ---- > 2 files changed, 5 insertions(+), 14 deletions(-) > > diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c > index b6f1eb5dbbdf..3732367e0c62 100644 > --- a/drivers/media/common/siano/smscoreapi.c > +++ b/drivers/media/common/siano/smscoreapi.c > @@ -1132,8 +1132,7 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev, > * return: 0 on success, <0 on error. > */ > static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, > - int mode, > - loadfirmware_t loadfirmware_handler) > + int mode) > { > int rc = -ENOENT; > u8 *fw_buf; > @@ -1147,8 +1146,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, > } > pr_debug("Firmware name: %s\n", fw_filename); > > - if (!loadfirmware_handler && > - !(coredev->device_flags & SMS_DEVICE_FAMILY2)) > + if (!(coredev->device_flags & SMS_DEVICE_FAMILY2)) > return -EINVAL; > > rc = request_firmware(&fw, fw_filename, coredev->device); > @@ -1166,10 +1164,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, > memcpy(fw_buf, fw->data, fw->size); > fw_buf_size = fw->size; > > - rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? > - smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) > - : loadfirmware_handler(coredev->context, fw_buf, > - fw_buf_size); > + rc = smscore_load_firmware_family2(coredev, fw_buf, > + fw_buf_size); > } > > kfree(fw_buf); > @@ -1353,8 +1349,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode) > } > > if (!(coredev->modes_supported & (1 << mode))) { > - rc = smscore_load_firmware_from_file(coredev, > - mode, NULL); > + rc = smscore_load_firmware_from_file(coredev, mode); > if (rc >= 0) > pr_debug("firmware download success\n"); > } else { > diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h > index 82d9f8a64d99..3c15082ce0e3 100644 > --- a/drivers/media/common/siano/smscoreapi.h > +++ b/drivers/media/common/siano/smscoreapi.h > @@ -97,7 +97,6 @@ typedef int (*hotplug_t)(struct smscore_device_t *coredev, > typedef int (*setmode_t)(void *context, int mode); > typedef void (*detectmode_t)(void *context, int *mode); > typedef int (*sendrequest_t)(void *context, void *buffer, size_t size); > -typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size); > typedef int (*preload_t)(void *context); > typedef int (*postload_t)(void *context); > > @@ -1102,9 +1101,6 @@ extern int smscore_register_device(struct smsdevice_params_t *params, > extern void smscore_unregister_device(struct smscore_device_t *coredev); > > extern int smscore_start_device(struct smscore_device_t *coredev); > -extern int smscore_load_firmware(struct smscore_device_t *coredev, > - char *filename, > - loadfirmware_t loadfirmware_handler); > > extern int smscore_set_device_mode(struct smscore_device_t *coredev, int mode); > extern int smscore_get_device_mode(struct smscore_device_t *coredev); > > --- > base-commit: 2c25dcc2361949bc7da730d22de36c019c6bf1e3 > change-id: 20240805-siano-c4c6a1106a39 > > Best regards, Thanks, Mauro
On 05/08/2024 11:01, Mauro Carvalho Chehab wrote: > Em Mon, 05 Aug 2024 07:59:43 +0000 > Ricardo Ribalda <ribalda@chromium.org> escreveu: > >> The function is never called with a loadfirmware_handler, so we can >> remove some dead code. >> >> We can also use this as a excuse to remove some unused type definitions. >> >> This fixes the following smatch warning: >> drivers/media/common/siano/smscoreapi.c:1172 smscore_load_firmware_from_file() error: we previously assumed 'loadfirmware_handler' could be null (see line 1150) >> >> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > LGTM. > > > >> --- >> Originally reported by Hans. > > Please add a reported-by field. I'll add that and merge this patch once it passed the gitlab CI. Regards, Hans > >> --- >> drivers/media/common/siano/smscoreapi.c | 15 +++++---------- >> drivers/media/common/siano/smscoreapi.h | 4 ---- >> 2 files changed, 5 insertions(+), 14 deletions(-) >> >> diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c >> index b6f1eb5dbbdf..3732367e0c62 100644 >> --- a/drivers/media/common/siano/smscoreapi.c >> +++ b/drivers/media/common/siano/smscoreapi.c >> @@ -1132,8 +1132,7 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev, >> * return: 0 on success, <0 on error. >> */ >> static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, >> - int mode, >> - loadfirmware_t loadfirmware_handler) >> + int mode) >> { >> int rc = -ENOENT; >> u8 *fw_buf; >> @@ -1147,8 +1146,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, >> } >> pr_debug("Firmware name: %s\n", fw_filename); >> >> - if (!loadfirmware_handler && >> - !(coredev->device_flags & SMS_DEVICE_FAMILY2)) >> + if (!(coredev->device_flags & SMS_DEVICE_FAMILY2)) >> return -EINVAL; >> >> rc = request_firmware(&fw, fw_filename, coredev->device); >> @@ -1166,10 +1164,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, >> memcpy(fw_buf, fw->data, fw->size); >> fw_buf_size = fw->size; >> >> - rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? >> - smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) >> - : loadfirmware_handler(coredev->context, fw_buf, >> - fw_buf_size); >> + rc = smscore_load_firmware_family2(coredev, fw_buf, >> + fw_buf_size); >> } >> >> kfree(fw_buf); >> @@ -1353,8 +1349,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode) >> } >> >> if (!(coredev->modes_supported & (1 << mode))) { >> - rc = smscore_load_firmware_from_file(coredev, >> - mode, NULL); >> + rc = smscore_load_firmware_from_file(coredev, mode); >> if (rc >= 0) >> pr_debug("firmware download success\n"); >> } else { >> diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h >> index 82d9f8a64d99..3c15082ce0e3 100644 >> --- a/drivers/media/common/siano/smscoreapi.h >> +++ b/drivers/media/common/siano/smscoreapi.h >> @@ -97,7 +97,6 @@ typedef int (*hotplug_t)(struct smscore_device_t *coredev, >> typedef int (*setmode_t)(void *context, int mode); >> typedef void (*detectmode_t)(void *context, int *mode); >> typedef int (*sendrequest_t)(void *context, void *buffer, size_t size); >> -typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size); >> typedef int (*preload_t)(void *context); >> typedef int (*postload_t)(void *context); >> >> @@ -1102,9 +1101,6 @@ extern int smscore_register_device(struct smsdevice_params_t *params, >> extern void smscore_unregister_device(struct smscore_device_t *coredev); >> >> extern int smscore_start_device(struct smscore_device_t *coredev); >> -extern int smscore_load_firmware(struct smscore_device_t *coredev, >> - char *filename, >> - loadfirmware_t loadfirmware_handler); >> >> extern int smscore_set_device_mode(struct smscore_device_t *coredev, int mode); >> extern int smscore_get_device_mode(struct smscore_device_t *coredev); >> >> --- >> base-commit: 2c25dcc2361949bc7da730d22de36c019c6bf1e3 >> change-id: 20240805-siano-c4c6a1106a39 >> >> Best regards, > > > > Thanks, > Mauro
diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c index b6f1eb5dbbdf..3732367e0c62 100644 --- a/drivers/media/common/siano/smscoreapi.c +++ b/drivers/media/common/siano/smscoreapi.c @@ -1132,8 +1132,7 @@ static char *smscore_get_fw_filename(struct smscore_device_t *coredev, * return: 0 on success, <0 on error. */ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, - int mode, - loadfirmware_t loadfirmware_handler) + int mode) { int rc = -ENOENT; u8 *fw_buf; @@ -1147,8 +1146,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, } pr_debug("Firmware name: %s\n", fw_filename); - if (!loadfirmware_handler && - !(coredev->device_flags & SMS_DEVICE_FAMILY2)) + if (!(coredev->device_flags & SMS_DEVICE_FAMILY2)) return -EINVAL; rc = request_firmware(&fw, fw_filename, coredev->device); @@ -1166,10 +1164,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, memcpy(fw_buf, fw->data, fw->size); fw_buf_size = fw->size; - rc = (coredev->device_flags & SMS_DEVICE_FAMILY2) ? - smscore_load_firmware_family2(coredev, fw_buf, fw_buf_size) - : loadfirmware_handler(coredev->context, fw_buf, - fw_buf_size); + rc = smscore_load_firmware_family2(coredev, fw_buf, + fw_buf_size); } kfree(fw_buf); @@ -1353,8 +1349,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode) } if (!(coredev->modes_supported & (1 << mode))) { - rc = smscore_load_firmware_from_file(coredev, - mode, NULL); + rc = smscore_load_firmware_from_file(coredev, mode); if (rc >= 0) pr_debug("firmware download success\n"); } else { diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h index 82d9f8a64d99..3c15082ce0e3 100644 --- a/drivers/media/common/siano/smscoreapi.h +++ b/drivers/media/common/siano/smscoreapi.h @@ -97,7 +97,6 @@ typedef int (*hotplug_t)(struct smscore_device_t *coredev, typedef int (*setmode_t)(void *context, int mode); typedef void (*detectmode_t)(void *context, int *mode); typedef int (*sendrequest_t)(void *context, void *buffer, size_t size); -typedef int (*loadfirmware_t)(void *context, void *buffer, size_t size); typedef int (*preload_t)(void *context); typedef int (*postload_t)(void *context); @@ -1102,9 +1101,6 @@ extern int smscore_register_device(struct smsdevice_params_t *params, extern void smscore_unregister_device(struct smscore_device_t *coredev); extern int smscore_start_device(struct smscore_device_t *coredev); -extern int smscore_load_firmware(struct smscore_device_t *coredev, - char *filename, - loadfirmware_t loadfirmware_handler); extern int smscore_set_device_mode(struct smscore_device_t *coredev, int mode); extern int smscore_get_device_mode(struct smscore_device_t *coredev);
The function is never called with a loadfirmware_handler, so we can remove some dead code. We can also use this as a excuse to remove some unused type definitions. This fixes the following smatch warning: drivers/media/common/siano/smscoreapi.c:1172 smscore_load_firmware_from_file() error: we previously assumed 'loadfirmware_handler' could be null (see line 1150) Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- Originally reported by Hans. --- drivers/media/common/siano/smscoreapi.c | 15 +++++---------- drivers/media/common/siano/smscoreapi.h | 4 ---- 2 files changed, 5 insertions(+), 14 deletions(-) --- base-commit: 2c25dcc2361949bc7da730d22de36c019c6bf1e3 change-id: 20240805-siano-c4c6a1106a39 Best regards,