From patchwork Tue Oct 7 20:02:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 397434 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 9CE2214011E for ; Wed, 8 Oct 2014 07:03:41 +1100 (EST) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xbayx-0001r6-9M; Tue, 07 Oct 2014 20:03:39 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Xbayw-0001qt-BS for tpmdd-devel@lists.sourceforge.net; Tue, 07 Oct 2014 20:03:38 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.43 as permitted sender) client-ip=74.125.82.43; envelope-from=christophe.ricard@gmail.com; helo=mail-wg0-f43.google.com; Received: from mail-wg0-f43.google.com ([74.125.82.43]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1Xbays-00055z-3C for tpmdd-devel@lists.sourceforge.net; Tue, 07 Oct 2014 20:03:38 +0000 Received: by mail-wg0-f43.google.com with SMTP id m15so10187992wgh.2 for ; Tue, 07 Oct 2014 13:03:27 -0700 (PDT) X-Received: by 10.180.86.73 with SMTP id n9mr29801168wiz.30.1412712207893; Tue, 07 Oct 2014 13:03:27 -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 lk6sm22017609wjb.26.2014.10.07.13.03.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Oct 2014 13:03:26 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: peterhuewe@gmx.de, ashley@ashleylai.com, tpmdd@selhorst.net Date: Tue, 7 Oct 2014 22:02:58 +0200 Message-Id: <1412712189-1234-6-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412712189-1234-1-git-send-email-christophe-h.ricard@st.com> References: <1412712189-1234-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: 1Xbays-00055z-3C Cc: devicetree@vger.kernel.org, christophe.ricard@gmail.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, jean-luc.blanc@st.com Subject: [tpmdd-devel] [PATCH 05/16] 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 | 103 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index 098f881..b20f148 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c @@ -295,7 +295,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; @@ -305,15 +305,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; @@ -323,9 +323,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() */ /* @@ -392,14 +392,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; @@ -479,7 +479,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; @@ -494,9 +494,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) { @@ -504,7 +504,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; } } @@ -514,8 +514,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; @@ -523,17 +523,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; } @@ -544,7 +544,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; } /* @@ -628,7 +628,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; @@ -637,13 +637,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; } @@ -651,7 +651,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; } @@ -659,7 +659,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; } @@ -680,8 +680,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); } @@ -689,26 +689,26 @@ 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; } - err = gpio_request(platform_data->io_serirq, "TPM IO_SERIRQ"); - if (err) + r = gpio_request(platform_data->io_serirq, "TPM IO_SERIRQ"); + if (r) goto _gpio_init2; clear_interruption(tpm_dev); - err = request_irq(gpio_to_irq(platform_data->io_serirq), + r = request_irq(gpio_to_irq(platform_data->io_serirq), &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", gpio_to_irq(platform_data->io_serirq)); 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 @@ -718,17 +718,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; @@ -753,7 +753,7 @@ _tpm_clean_answer: tpm_remove_hardware(chip->dev); end: pr_info("TPM I2C initialisation fail\n"); - return err; + return r; } /* @@ -783,14 +783,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() */ /* @@ -803,20 +802,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