Ajay, please squash this into your patch if it's OK.

I took the liberty of removing one label that was not used.

Signed-off-by: Heikki Krogerus <heikki.kroge...@linux.intel.com>
---
 drivers/usb/typec/ucsi/ucsi_ccg.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c 
b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 5508beec08e3..50e5ac1d2d0a 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -180,6 +180,8 @@ struct ucsi_ccg {
        int irq;
        struct work_struct work;
        struct mutex lock; /* to sync between user and driver thread */
+
+       u16 fw_build;
 };
 
 static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)
@@ -687,7 +689,7 @@ static bool ccg_check_vendor_version(struct ucsi_ccg *uc,
        /* Check if the fw build is for supported vendors.
         * Add all supported vendors here.
         */
-       if (app->build != (('n' << 8) | 'v')) {
+       if (app->build != uc->fw_build) {
                dev_info(dev, "current fw is not from supported vendor\n");
                return false;
        }
@@ -695,7 +697,7 @@ static bool ccg_check_vendor_version(struct ucsi_ccg *uc,
        /* Check if the new fw build is for supported vendors
         * Add all supported vendors here.
         */
-       if (fw_cfg->app.build != (('n' << 8) | 'v')) {
+       if (fw_cfg->app.build != uc->fw_build) {
                dev_info(dev, "new fw is not from supported vendor\n");
                return false;
        }
@@ -721,14 +723,14 @@ static bool ccg_check_fw_version(struct ucsi_ccg *uc, 
const char *fw_name,
         * last part of fw image is fw cfg table and signature
         */
        if (fw->size < sizeof(fw_cfg) + FW_CFG_TABLE_SIG_SIZE)
-               goto not_signed_fw;
+               goto out_release_firmware;
 
        memcpy((uint8_t *)&fw_cfg, fw->data + fw->size -
               sizeof(fw_cfg) - FW_CFG_TABLE_SIG_SIZE, sizeof(fw_cfg));
 
        if (fw_cfg.identity != ('F' | 'W' << 8 | 'C' << 16 | 'T' << 24)) {
                dev_info(dev, "not a signed image\n");
-               goto not_signed_fw;
+               goto out_release_firmware;
        }
 
        /* compare input version with FWCT version */
@@ -738,13 +740,12 @@ static bool ccg_check_fw_version(struct ucsi_ccg *uc, 
const char *fw_name,
                        fw_cfg.app.ver << 24;
 
        if (!ccg_check_vendor_version(uc, app, &fw_cfg))
-               goto not_supported_version;
+               goto out_release_firmware;
 
        if (new_version > cur_version)
                is_later = true;
 
-not_supported_version:
-not_signed_fw:
+out_release_firmware:
        release_firmware(fw);
        return is_later;
 }
@@ -1085,6 +1086,14 @@ static int ucsi_ccg_probe(struct i2c_client *client,
        mutex_init(&uc->lock);
        INIT_WORK(&uc->work, ccg_update_firmware);
 
+       /* REVISIT: This probable does not need to be fatal. */
+       status = device_property_read_u16(dev, "ccgx,firmware-build",
+                                         &uc->fw_build);
+       if (status) {
+               dev_err(uc->dev, "faild to get FW build\n");
+               return status;
+       }
+
        /* reset ccg device and initialize ucsi */
        status = ucsi_ccg_init(uc);
        if (status < 0) {
-- 
2.20.1

Reply via email to