From patchwork Mon Oct 13 20:23:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 399304 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 6A4EC140119 for ; Tue, 14 Oct 2014 07:24:12 +1100 (EST) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XdmA6-0002yD-7E; Mon, 13 Oct 2014 20:24:10 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XdmA4-0002y1-Hj for tpmdd-devel@lists.sourceforge.net; Mon, 13 Oct 2014 20:24:08 +0000 Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.48 as permitted sender) client-ip=74.125.82.48; envelope-from=christophe.ricard@gmail.com; helo=mail-wg0-f48.google.com; Received: from mail-wg0-f48.google.com ([74.125.82.48]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1XdmA3-0007G7-HQ for tpmdd-devel@lists.sourceforge.net; Mon, 13 Oct 2014 20:24:08 +0000 Received: by mail-wg0-f48.google.com with SMTP id k14so9361464wgh.19 for ; Mon, 13 Oct 2014 13:24:01 -0700 (PDT) X-Received: by 10.180.104.229 with SMTP id gh5mr1261806wib.42.1413231841362; Mon, 13 Oct 2014 13:24:01 -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.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Oct 2014 13:23:59 -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:32 +0200 Message-Id: <1413231817-5174-11-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: 1XdmA3-0007G7-HQ 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 10/15] tpm/tpm_i2c_stm_st33: Few code cleanup 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 Cleanup code indentation, braces, test variable when NULL. Signed-off-by: Christophe Ricard --- drivers/char/tpm/tpm_i2c_stm_st33.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c b/drivers/char/tpm/tpm_i2c_stm_st33.c index 6980708..cc5aef3 100644 --- a/drivers/char/tpm/tpm_i2c_stm_st33.c +++ b/drivers/char/tpm/tpm_i2c_stm_st33.c @@ -27,7 +27,7 @@ * * @Synopsis: * 09/15/2010: First shot driver tpm_tis driver for - lpc is used as model. + * lpc is used as model. */ #include @@ -396,7 +396,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, long r; u8 status; - if (chip->vendor.irq) { + if (chip->vendor.irq) { r = wait_for_serirq_timeout(chip, ((tpm_stm_i2c_status (chip) & mask) == mask), timeout); @@ -432,8 +432,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, chip->vendor.timeout_c, - &chip->vendor.read_queue) - == 0) { + &chip->vendor.read_queue) == 0) { burstcnt = get_burstcount(chip); if (burstcnt < 0) return burstcnt; @@ -485,7 +484,7 @@ static int tpm_stm_i2c_send(struct tpm_chip *chip, unsigned char *buf, struct i2c_client *client; struct tpm_stm_dev *tpm_dev; - if (chip == NULL) + if (!chip) return -EBUSY; if (len < TPM_HEADER_SIZE) return -EBUSY; @@ -562,7 +561,7 @@ static int tpm_stm_i2c_recv(struct tpm_chip *chip, unsigned char *buf, int size = 0; int expected; - if (chip == NULL) + if (!chip) return -EBUSY; if (count < TPM_HEADER_SIZE) { @@ -583,7 +582,7 @@ static int tpm_stm_i2c_recv(struct tpm_chip *chip, unsigned char *buf, } size += recv_data(chip, &buf[TPM_HEADER_SIZE], - expected - TPM_HEADER_SIZE); + expected - TPM_HEADER_SIZE); if (size < expected) { dev_err(chip->dev, "Unable to read remainder of result\n"); size = -ETIME; @@ -663,7 +662,7 @@ static int tpm_stm_i2c_request_resources(struct i2c_client *client, int r; pdata = client->dev.platform_data; - if (pdata == NULL) { + if (!pdata) { pr_err("No platform data\n"); return -EINVAL; } @@ -695,12 +694,12 @@ static int tpm_stm_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int r; - u8 intmask; + u8 intmask = 0; struct tpm_chip *chip; struct st33zp24_platform_data *platform_data; struct tpm_stm_dev *tpm_dev; - if (client == NULL) { + if (!client) { pr_info("%s: i2c client is NULL. Device not accessible.\n", __func__); return -ENODEV; @@ -762,8 +761,7 @@ tpm_stm_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) clear_interruption(tpm_dev); r = devm_request_threaded_irq(&client->dev, client->irq, NULL, - tpm_ioserirq_handler, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT, + tpm_ioserirq_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "TPM SERIRQ management", chip); if (r < 0) { dev_err(chip->dev , "TPM SERIRQ signals %d not available\n", @@ -811,7 +809,7 @@ _tpm_clean_answer: /* * tpm_stm_i2c_remove remove the TPM device * @param: client, the i2c_client drescription (TPM I2C description). - clear_bit(0, &chip->is_open); + * clear_bit(0, &chip->is_open); * @return: 0 in case of success. */ static int tpm_stm_i2c_remove(struct i2c_client *client) @@ -841,6 +839,7 @@ static int tpm_stm_i2c_pm_suspend(struct device *dev) gpio_set_value(pin_infos->io_lpcpd, 0); else r = tpm_pm_suspend(dev); + return r; } /* tpm_stm_i2c_suspend() */ @@ -875,6 +874,7 @@ static const struct i2c_device_id tpm_stm_i2c_id[] = { {TPM_ST33_I2C, 0}, {} }; +MODULE_DEVICE_TABLE(i2c, tpm_stm_i2c_id); #ifdef CONFIG_OF static const struct of_device_id of_st33zp24_i2c_match[] = { @@ -884,7 +884,6 @@ static const struct of_device_id of_st33zp24_i2c_match[] = { MODULE_DEVICE_TABLE(of, of_st33zp24_i2c_match); #endif -MODULE_DEVICE_TABLE(i2c, tpm_stm_i2c_id); static SIMPLE_DEV_PM_OPS(tpm_stm_i2c_ops, tpm_stm_i2c_pm_suspend, tpm_stm_i2c_pm_resume); static struct i2c_driver tpm_stm_i2c_driver = { @@ -893,7 +892,7 @@ static struct i2c_driver tpm_stm_i2c_driver = { .name = TPM_ST33_I2C, .pm = &tpm_stm_i2c_ops, .of_match_table = of_match_ptr(of_st33zp24_i2c_match), - }, + }, .probe = tpm_stm_i2c_probe, .remove = tpm_stm_i2c_remove, .id_table = tpm_stm_i2c_id