From patchwork Mon Oct 13 20:23:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 399300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 66EBC1400B0 for ; Tue, 14 Oct 2014 07:24:02 +1100 (EST) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xdm9w-0005r6-JX; Mon, 13 Oct 2014 20:24:00 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xdm9v-0005qs-LI for tpmdd-devel@lists.sourceforge.net; Mon, 13 Oct 2014 20:23:59 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 209.85.212.171 as permitted sender) client-ip=209.85.212.171; envelope-from=christophe.ricard@gmail.com; helo=mail-wi0-f171.google.com; Received: from mail-wi0-f171.google.com ([209.85.212.171]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Xdm9u-0004oP-F3 for tpmdd-devel@lists.sourceforge.net; Mon, 13 Oct 2014 20:23:59 +0000 Received: by mail-wi0-f171.google.com with SMTP id em10so8378035wid.10 for ; Mon, 13 Oct 2014 13:23:52 -0700 (PDT) X-Received: by 10.194.134.135 with SMTP id pk7mr609153wjb.63.1413231832285; Mon, 13 Oct 2014 13:23:52 -0700 (PDT) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by mx.google.com with ESMTPSA id p2sm13358739wiy.1.2014.10.13.13.23.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Oct 2014 13:23:51 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: peterhuewe@gmx.de, ashley@ashleylai.com, tpmdd@selhorst.net Date: Mon, 13 Oct 2014 22:23:28 +0200 Message-Id: <1413231817-5174-7-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1413231817-5174-1-git-send-email-christophe-h.ricard@st.com> References: <1413231817-5174-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (christophe.ricard[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1Xdm9u-0004oP-F3 Cc: devicetree@vger.kernel.org, christophe.ricard@gmail.com, jean-luc.blanc@st.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com Subject: [tpmdd-devel] [PATCH v3 06/15] tpm/tpm_i2c_stm_st33: Replace err/rc/ret by r for a function return code X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net Some functions return err, rc or ret for a status code. Return r instead for all of them. Signed-off-by: Christophe Ricard --- drivers/char/tpm/tpm_i2c_stm_st33.c | 97 ++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index 71ef1da..4997eff 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c @@ -292,7 +292,7 @@ static int check_locality(struct tpm_chip *chip) static int request_locality(struct tpm_chip *chip) { unsigned long stop; - long rc; + long r; struct tpm_stm_dev *tpm_dev; u8 data; @@ -302,15 +302,15 @@ static int request_locality(struct tpm_chip *chip) return chip->vendor.locality; data = TPM_ACCESS_REQUEST_USE; - rc = I2C_WRITE_DATA(tpm_dev, TPM_ACCESS, &data, 1); - if (rc < 0) + r = I2C_WRITE_DATA(tpm_dev, TPM_ACCESS, &data, 1); + if (r < 0) goto end; if (chip->vendor.irq) { - rc = wait_for_serirq_timeout(chip, (check_locality + r = wait_for_serirq_timeout(chip, (check_locality (chip) >= 0), chip->vendor.timeout_a); - if (rc > 0) + if (r > 0) return chip->vendor.locality; } else { stop = jiffies + chip->vendor.timeout_a; @@ -320,9 +320,9 @@ static int request_locality(struct tpm_chip *chip) msleep(TPM_TIMEOUT); } while (time_before(jiffies, stop)); } - rc = -EACCES; + r = -EACCES; end: - return rc; + return r; } /* request_locality() */ /* @@ -389,14 +389,14 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, wait_queue_head_t *queue) { unsigned long stop; - long rc; + long r; u8 status; if (chip->vendor.irq) { - rc = wait_for_serirq_timeout(chip, ((tpm_stm_i2c_status + r = wait_for_serirq_timeout(chip, ((tpm_stm_i2c_status (chip) & mask) == mask), timeout); - if (rc > 0) + if (r > 0) return 0; } else { stop = jiffies + timeout; @@ -476,7 +476,7 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, { u32 status, i, size; int burstcnt = 0; - int ret; + int r; u8 data; struct i2c_client *client; struct tpm_stm_dev *tpm_dev; @@ -491,9 +491,9 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, client->flags = 0; - ret = request_locality(chip); - if (ret < 0) - return ret; + r = request_locality(chip); + if (r < 0) + return r; status = tpm_stm_i2c_status(chip); if ((status & TPM_STS_COMMAND_READY) == 0) { @@ -501,7 +501,7 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, if (wait_for_stat (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b, &chip->vendor.int_queue) < 0) { - ret = -ETIME; + r = -ETIME; goto out_err; } } @@ -511,8 +511,8 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, if (burstcnt < 0) return burstcnt; size = min_t(int, len - i - 1, burstcnt); - ret = I2C_WRITE_DATA(tpm_dev, TPM_DATA_FIFO, buf, size); - if (ret < 0) + r = I2C_WRITE_DATA(tpm_dev, TPM_DATA_FIFO, buf, size); + if (r < 0) goto out_err; i += size; @@ -520,17 +520,17 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, status = tpm_stm_i2c_status(chip); if ((status & TPM_STS_DATA_EXPECT) == 0) { - ret = -EIO; + r = -EIO; goto out_err; } - ret = I2C_WRITE_DATA(tpm_dev, TPM_DATA_FIFO, buf + len - 1, 1); - if (ret < 0) + r = I2C_WRITE_DATA(tpm_dev, TPM_DATA_FIFO, buf + len - 1, 1); + if (r < 0) goto out_err; status = tpm_stm_i2c_status(chip); if ((status & TPM_STS_DATA_EXPECT) != 0) { - ret = -EIO; + r = -EIO; goto out_err; } @@ -541,7 +541,7 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, out_err: tpm_stm_i2c_cancel(chip); release_locality(chip); - return ret; + return r; } /* @@ -625,7 +625,7 @@ MODULE_PARM_DESC(power_mgt, "Power Management"); static int tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - int err; + int r; u8 intmask; struct tpm_chip *chip; struct st33zp24_platform_data *platform_data; @@ -634,13 +634,13 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) if (client == NULL) { pr_info("%s: i2c client is NULL. Device not accessible.\n", __func__); - err = -ENODEV; + r = -ENODEV; goto end; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_info(&client->dev, "client not i2c capable\n"); - err = -ENODEV; + r = -ENODEV; goto end; } @@ -648,7 +648,7 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) GFP_KERNEL); if (!tpm_dev) { dev_info(&client->dev, "cannot allocate memory for tpm data\n"); - err = -ENOMEM; + r = -ENOMEM; goto _tpm_clean_answer; } @@ -656,7 +656,7 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!platform_data) { dev_info(&client->dev, "chip not available\n"); - err = -ENODEV; + r = -ENODEV; goto _tpm_clean_answer; } @@ -677,8 +677,8 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) chip->vendor.locality = LOCALITY0; if (power_mgt) { - err = gpio_request(platform_data->io_lpcpd, "TPM IO_LPCPD"); - if (err) + r = gpio_request(platform_data->io_lpcpd, "TPM IO_LPCPD"); + if (r) goto _gpio_init1; gpio_set_value(platform_data->io_lpcpd, 1); } @@ -686,7 +686,7 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) if (interrupts) { init_completion(&tpm_dev->irq_detection); if (request_locality(chip) != LOCALITY0) { - err = -ENODEV; + r = -ENODEV; goto _tpm_clean_answer; } @@ -695,14 +695,14 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) &tpm_ioserirq_handler, IRQF_TRIGGER_HIGH, "TPM SERIRQ management", chip); - if (err < 0) { + if (r < 0) { dev_err(chip->dev , "TPM SERIRQ signals %d not available\n", client->irq); goto _irq_set; } - err = I2C_READ_DATA(tpm_dev, TPM_INT_ENABLE, &intmask, 1); - if (err < 0) + r = I2C_READ_DATA(tpm_dev, TPM_INT_ENABLE, &intmask, 1); + if (r < 0) goto _irq_set; intmask |= TPM_INTF_CMD_READY_INT @@ -712,17 +712,17 @@ tpm_st33_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) | TPM_INTF_STS_VALID_INT | TPM_INTF_DATA_AVAIL_INT; - err = I2C_WRITE_DATA(tpm_dev, TPM_INT_ENABLE, &intmask, 1); - if (err < 0) + r = I2C_WRITE_DATA(tpm_dev, TPM_INT_ENABLE, &intmask, 1); + if (r < 0) goto _irq_set; intmask = TPM_GLOBAL_INT_ENABLE; - err = I2C_WRITE_DATA(tpm_dev, (TPM_INT_ENABLE + 3), &intmask, 1); - if (err < 0) + r = I2C_WRITE_DATA(tpm_dev, (TPM_INT_ENABLE + 3), &intmask, 1); + if (r < 0) goto _irq_set; - err = I2C_READ_DATA(tpm_dev, TPM_INT_STATUS, &intmask, 1); - if (err < 0) + r = I2C_READ_DATA(tpm_dev, TPM_INT_STATUS, &intmask, 1); + if (r < 0) goto _irq_set; chip->vendor.irq = interrupts; @@ -744,7 +744,7 @@ _tpm_clean_answer: tpm_remove_hardware(chip->dev); end: pr_info("TPM I2C initialisation fail\n"); - return err; + return r; } /* @@ -774,14 +774,13 @@ static int tpm_st33_i2c_remove(struct i2c_client *client) static int tpm_st33_i2c_pm_suspend(struct device *dev) { struct st33zp24_platform_data *pin_infos = dev->platform_data; - int ret = 0; + int r = 0; if (power_mgt) gpio_set_value(pin_infos->io_lpcpd, 0); else - ret = tpm_pm_suspend(dev); - - return ret; + r = tpm_pm_suspend(dev); + return r; } /* tpm_st33_i2c_suspend() */ /* @@ -794,20 +793,20 @@ static int tpm_st33_i2c_pm_resume(struct device *dev) struct tpm_chip *chip = dev_get_drvdata(dev); struct st33zp24_platform_data *pin_infos = dev->platform_data; - int ret = 0; + int r = 0; if (power_mgt) { gpio_set_value(pin_infos->io_lpcpd, 1); - ret = wait_for_serirq_timeout(chip, + r = wait_for_serirq_timeout(chip, (chip->ops->status(chip) & TPM_STS_VALID) == TPM_STS_VALID, chip->vendor.timeout_b); } else { - ret = tpm_pm_resume(dev); - if (!ret) + r = tpm_pm_resume(dev); + if (!r) tpm_do_selftest(chip); } - return ret; + return r; } /* tpm_st33_i2c_pm_resume() */ #endif