Message ID | 20201203153950.13772-1-bongsu.jeon@samsung.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] nfc: s3fwrn5: skip the NFC bootloader mode | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 95 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Fri, Dec 04, 2020 at 12:39:50AM +0900, Bongsu Jeon wrote: > From: Bongsu Jeon <bongsu.jeon@samsung.com> > > If there isn't proper NFC firmware image, > Bootloader mode will be skipped. Wrap your commit msg as described in submitting patches (so at 75 character). > > Signed-off-by: Bongsu Jeon <bongsu.jeon@samsung.com> > --- > drivers/nfc/s3fwrn5/core.c | 44 ++++++++++++++++++++++++---------- > drivers/nfc/s3fwrn5/firmware.c | 11 +-------- > drivers/nfc/s3fwrn5/firmware.h | 1 + > 3 files changed, 33 insertions(+), 23 deletions(-) > > diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c > index f8e5d78d9078..df89bc5d7338 100644 > --- a/drivers/nfc/s3fwrn5/core.c > +++ b/drivers/nfc/s3fwrn5/core.c > @@ -20,13 +20,26 @@ > NFC_PROTO_ISO14443_B_MASK | \ > NFC_PROTO_ISO15693_MASK) > > +static int s3fwrn5_firmware_init(struct s3fwrn5_info *info) > +{ > + struct s3fwrn5_fw_info *fw_info = &info->fw_info; > + int ret; > + > + s3fwrn5_fw_init(fw_info, "sec_s3fwrn5_firmware.bin"); > + > + /* Get firmware data */ > + ret = s3fwrn5_fw_request_firmware(fw_info); > + if (ret < 0) > + dev_err(&fw_info->ndev->nfc_dev->dev, > + "Failed to get fw file, ret=%02x\n", ret); > + return ret; > +} > + > static int s3fwrn5_firmware_update(struct s3fwrn5_info *info) > { > bool need_update; > int ret; > > - s3fwrn5_fw_init(&info->fw_info, "sec_s3fwrn5_firmware.bin"); > - > /* Update firmware */ > > s3fwrn5_set_wake(info, false); > @@ -109,21 +122,26 @@ static int s3fwrn5_nci_post_setup(struct nci_dev *ndev) > struct s3fwrn5_info *info = nci_get_drvdata(ndev); > int ret; > > - ret = s3fwrn5_firmware_update(info); > - if (ret < 0) > - goto out; > + if (s3fwrn5_firmware_init(info) == 0) { if (s3fwrn5_firmware_init(info)) { // skip bootloader mode ret = 0; goto out; } so entire next block won't have to be indented. This follows usual pattern of error handling. Best regards, Krzysztof > + ret = s3fwrn5_firmware_update(info); > + if (ret < 0) > + goto out; > > - /* NCI core reset */ > - > - s3fwrn5_set_mode(info, S3FWRN5_MODE_NCI); > - s3fwrn5_set_wake(info, true); > + /* NCI core reset */ > > - ret = nci_core_reset(info->ndev); > - if (ret < 0) > - goto out; > + s3fwrn5_set_mode(info, S3FWRN5_MODE_NCI); > + s3fwrn5_set_wake(info, true); > > - ret = nci_core_init(info->ndev); > + ret = nci_core_reset(info->ndev); > + if (ret < 0) > + goto out; > > + ret = nci_core_init(info->ndev); > + } else { > + dev_info(&info->ndev->nfc_dev->dev, > + "skip bootloader mode\n"); > + ret = 0; > + } > out: > return ret; > }
diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c index f8e5d78d9078..df89bc5d7338 100644 --- a/drivers/nfc/s3fwrn5/core.c +++ b/drivers/nfc/s3fwrn5/core.c @@ -20,13 +20,26 @@ NFC_PROTO_ISO14443_B_MASK | \ NFC_PROTO_ISO15693_MASK) +static int s3fwrn5_firmware_init(struct s3fwrn5_info *info) +{ + struct s3fwrn5_fw_info *fw_info = &info->fw_info; + int ret; + + s3fwrn5_fw_init(fw_info, "sec_s3fwrn5_firmware.bin"); + + /* Get firmware data */ + ret = s3fwrn5_fw_request_firmware(fw_info); + if (ret < 0) + dev_err(&fw_info->ndev->nfc_dev->dev, + "Failed to get fw file, ret=%02x\n", ret); + return ret; +} + static int s3fwrn5_firmware_update(struct s3fwrn5_info *info) { bool need_update; int ret; - s3fwrn5_fw_init(&info->fw_info, "sec_s3fwrn5_firmware.bin"); - /* Update firmware */ s3fwrn5_set_wake(info, false); @@ -109,21 +122,26 @@ static int s3fwrn5_nci_post_setup(struct nci_dev *ndev) struct s3fwrn5_info *info = nci_get_drvdata(ndev); int ret; - ret = s3fwrn5_firmware_update(info); - if (ret < 0) - goto out; + if (s3fwrn5_firmware_init(info) == 0) { + ret = s3fwrn5_firmware_update(info); + if (ret < 0) + goto out; - /* NCI core reset */ - - s3fwrn5_set_mode(info, S3FWRN5_MODE_NCI); - s3fwrn5_set_wake(info, true); + /* NCI core reset */ - ret = nci_core_reset(info->ndev); - if (ret < 0) - goto out; + s3fwrn5_set_mode(info, S3FWRN5_MODE_NCI); + s3fwrn5_set_wake(info, true); - ret = nci_core_init(info->ndev); + ret = nci_core_reset(info->ndev); + if (ret < 0) + goto out; + ret = nci_core_init(info->ndev); + } else { + dev_info(&info->ndev->nfc_dev->dev, + "skip bootloader mode\n"); + ret = 0; + } out: return ret; } diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c index 4cde6dd5c019..4b5352e2b915 100644 --- a/drivers/nfc/s3fwrn5/firmware.c +++ b/drivers/nfc/s3fwrn5/firmware.c @@ -280,7 +280,7 @@ static int s3fwrn5_fw_complete_update_mode(struct s3fwrn5_fw_info *fw_info) #define S3FWRN5_FW_IMAGE_HEADER_SIZE 44 -static int s3fwrn5_fw_request_firmware(struct s3fwrn5_fw_info *fw_info) +int s3fwrn5_fw_request_firmware(struct s3fwrn5_fw_info *fw_info) { struct s3fwrn5_fw_image *fw = &fw_info->fw; u32 sig_off; @@ -358,15 +358,6 @@ int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info) struct s3fwrn5_fw_cmd_get_bootinfo_rsp bootinfo; int ret; - /* Get firmware data */ - - ret = s3fwrn5_fw_request_firmware(fw_info); - if (ret < 0) { - dev_err(&fw_info->ndev->nfc_dev->dev, - "Failed to get fw file, ret=%02x\n", ret); - return ret; - } - /* Get bootloader info */ ret = s3fwrn5_fw_get_bootinfo(fw_info, &bootinfo); diff --git a/drivers/nfc/s3fwrn5/firmware.h b/drivers/nfc/s3fwrn5/firmware.h index 3c83e6730d30..3a82ce5837fb 100644 --- a/drivers/nfc/s3fwrn5/firmware.h +++ b/drivers/nfc/s3fwrn5/firmware.h @@ -89,6 +89,7 @@ struct s3fwrn5_fw_info { char parity; }; +int s3fwrn5_fw_request_firmware(struct s3fwrn5_fw_info *fw_info); void s3fwrn5_fw_init(struct s3fwrn5_fw_info *fw_info, const char *fw_name); int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info); bool s3fwrn5_fw_check_version(const struct s3fwrn5_fw_info *fw_info, u32 version);