Commit edfa5366 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Jakub Kicinski

nfc: s3fwrn5: simplify dereferencing pointer to struct device

Simplify the code dereferencing several pointers to reach the struct
device.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent f141cfe3
...@@ -357,6 +357,7 @@ s3fwrn5_fw_is_custom(const struct s3fwrn5_fw_cmd_get_bootinfo_rsp *bootinfo) ...@@ -357,6 +357,7 @@ s3fwrn5_fw_is_custom(const struct s3fwrn5_fw_cmd_get_bootinfo_rsp *bootinfo)
int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info) int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info)
{ {
struct device *dev = &fw_info->ndev->nfc_dev->dev;
struct s3fwrn5_fw_cmd_get_bootinfo_rsp bootinfo; struct s3fwrn5_fw_cmd_get_bootinfo_rsp bootinfo;
int ret; int ret;
...@@ -364,8 +365,7 @@ int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info) ...@@ -364,8 +365,7 @@ int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info)
ret = s3fwrn5_fw_get_bootinfo(fw_info, &bootinfo); ret = s3fwrn5_fw_get_bootinfo(fw_info, &bootinfo);
if (ret < 0) { if (ret < 0) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Failed to get bootinfo, ret=%02x\n", ret);
"Failed to get bootinfo, ret=%02x\n", ret);
goto err; goto err;
} }
...@@ -373,8 +373,7 @@ int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info) ...@@ -373,8 +373,7 @@ int s3fwrn5_fw_setup(struct s3fwrn5_fw_info *fw_info)
ret = s3fwrn5_fw_get_base_addr(&bootinfo, &fw_info->base_addr); ret = s3fwrn5_fw_get_base_addr(&bootinfo, &fw_info->base_addr);
if (ret < 0) { if (ret < 0) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Unknown hardware version\n");
"Unknown hardware version\n");
goto err; goto err;
} }
...@@ -409,6 +408,7 @@ bool s3fwrn5_fw_check_version(const struct s3fwrn5_fw_info *fw_info, u32 version ...@@ -409,6 +408,7 @@ bool s3fwrn5_fw_check_version(const struct s3fwrn5_fw_info *fw_info, u32 version
int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
{ {
struct device *dev = &fw_info->ndev->nfc_dev->dev;
struct s3fwrn5_fw_image *fw = &fw_info->fw; struct s3fwrn5_fw_image *fw = &fw_info->fw;
u8 hash_data[SHA1_DIGEST_SIZE]; u8 hash_data[SHA1_DIGEST_SIZE];
struct crypto_shash *tfm; struct crypto_shash *tfm;
...@@ -421,8 +421,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) ...@@ -421,8 +421,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
tfm = crypto_alloc_shash("sha1", 0, 0); tfm = crypto_alloc_shash("sha1", 0, 0);
if (IS_ERR(tfm)) { if (IS_ERR(tfm)) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Cannot allocate shash (code=%pe)\n", tfm);
"Cannot allocate shash (code=%pe)\n", tfm);
return PTR_ERR(tfm); return PTR_ERR(tfm);
} }
...@@ -430,21 +429,18 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) ...@@ -430,21 +429,18 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
crypto_free_shash(tfm); crypto_free_shash(tfm);
if (ret) { if (ret) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Cannot compute hash (code=%d)\n", ret);
"Cannot compute hash (code=%d)\n", ret);
return ret; return ret;
} }
/* Firmware update process */ /* Firmware update process */
dev_info(&fw_info->ndev->nfc_dev->dev, dev_info(dev, "Firmware update: %s\n", fw_info->fw_name);
"Firmware update: %s\n", fw_info->fw_name);
ret = s3fwrn5_fw_enter_update_mode(fw_info, hash_data, ret = s3fwrn5_fw_enter_update_mode(fw_info, hash_data,
SHA1_DIGEST_SIZE, fw_info->sig, fw_info->sig_size); SHA1_DIGEST_SIZE, fw_info->sig, fw_info->sig_size);
if (ret < 0) { if (ret < 0) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Unable to enter update mode\n");
"Unable to enter update mode\n");
return ret; return ret;
} }
...@@ -452,21 +448,18 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info) ...@@ -452,21 +448,18 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
ret = s3fwrn5_fw_update_sector(fw_info, ret = s3fwrn5_fw_update_sector(fw_info,
fw_info->base_addr + off, fw->image + off); fw_info->base_addr + off, fw->image + off);
if (ret < 0) { if (ret < 0) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Firmware update error (code=%d)\n", ret);
"Firmware update error (code=%d)\n", ret);
return ret; return ret;
} }
} }
ret = s3fwrn5_fw_complete_update_mode(fw_info); ret = s3fwrn5_fw_complete_update_mode(fw_info);
if (ret < 0) { if (ret < 0) {
dev_err(&fw_info->ndev->nfc_dev->dev, dev_err(dev, "Unable to complete update mode\n");
"Unable to complete update mode\n");
return ret; return ret;
} }
dev_info(&fw_info->ndev->nfc_dev->dev, dev_info(dev, "Firmware update: success\n");
"Firmware update: success\n");
return ret; return ret;
} }
......
...@@ -47,6 +47,7 @@ const struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = { ...@@ -47,6 +47,7 @@ const struct nci_driver_ops s3fwrn5_nci_prop_ops[4] = {
int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name) int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name)
{ {
struct device *dev = &info->ndev->nfc_dev->dev;
const struct firmware *fw; const struct firmware *fw;
struct nci_prop_fw_cfg_cmd fw_cfg; struct nci_prop_fw_cfg_cmd fw_cfg;
struct nci_prop_set_rfreg_cmd set_rfreg; struct nci_prop_set_rfreg_cmd set_rfreg;
...@@ -55,7 +56,7 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name) ...@@ -55,7 +56,7 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name)
int i, len; int i, len;
int ret; int ret;
ret = request_firmware(&fw, fw_name, &info->ndev->nfc_dev->dev); ret = request_firmware(&fw, fw_name, dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -77,13 +78,11 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name) ...@@ -77,13 +78,11 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name)
/* Start rfreg configuration */ /* Start rfreg configuration */
dev_info(&info->ndev->nfc_dev->dev, dev_info(dev, "rfreg configuration update: %s\n", fw_name);
"rfreg configuration update: %s\n", fw_name);
ret = nci_prop_cmd(info->ndev, NCI_PROP_START_RFREG, 0, NULL); ret = nci_prop_cmd(info->ndev, NCI_PROP_START_RFREG, 0, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(&info->ndev->nfc_dev->dev, dev_err(dev, "Unable to start rfreg update\n");
"Unable to start rfreg update\n");
goto out; goto out;
} }
...@@ -97,8 +96,7 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name) ...@@ -97,8 +96,7 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name)
ret = nci_prop_cmd(info->ndev, NCI_PROP_SET_RFREG, ret = nci_prop_cmd(info->ndev, NCI_PROP_SET_RFREG,
len+1, (__u8 *)&set_rfreg); len+1, (__u8 *)&set_rfreg);
if (ret < 0) { if (ret < 0) {
dev_err(&info->ndev->nfc_dev->dev, dev_err(dev, "rfreg update error (code=%d)\n", ret);
"rfreg update error (code=%d)\n", ret);
goto out; goto out;
} }
set_rfreg.index++; set_rfreg.index++;
...@@ -110,13 +108,11 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name) ...@@ -110,13 +108,11 @@ int s3fwrn5_nci_rf_configure(struct s3fwrn5_info *info, const char *fw_name)
ret = nci_prop_cmd(info->ndev, NCI_PROP_STOP_RFREG, ret = nci_prop_cmd(info->ndev, NCI_PROP_STOP_RFREG,
sizeof(stop_rfreg), (__u8 *)&stop_rfreg); sizeof(stop_rfreg), (__u8 *)&stop_rfreg);
if (ret < 0) { if (ret < 0) {
dev_err(&info->ndev->nfc_dev->dev, dev_err(dev, "Unable to stop rfreg update\n");
"Unable to stop rfreg update\n");
goto out; goto out;
} }
dev_info(&info->ndev->nfc_dev->dev, dev_info(dev, "rfreg configuration update: success\n");
"rfreg configuration update: success\n");
out: out:
release_firmware(fw); release_firmware(fw);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment