From patchwork Mon Jun 6 14:24:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 852212 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p56EHWVJ028478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 6 Jun 2011 14:17:53 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QTacA-00014D-MN; Mon, 06 Jun 2011 14:17:11 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QTac9-0006Rl-Kk; Mon, 06 Jun 2011 14:17:09 +0000 Received: from ppsw-52.csi.cam.ac.uk ([131.111.8.152]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QTabK-0006Fv-IC for linux-arm-kernel@lists.infradead.org; Mon, 06 Jun 2011 14:16:20 +0000 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from arcturus.eng.cam.ac.uk ([129.169.154.73]:59505 helo=localhost.eng.cam.ac.uk) by ppsw-52.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.159]:465) with esmtpsa (LOGIN:jic23) (TLSv1:DHE-RSA-AES256-SHA:256) id 1QTabJ-00026u-DP (Exim 4.72) (return-path ); Mon, 06 Jun 2011 15:16:17 +0100 From: Jonathan Cameron To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/3] pxa2xx trizeps4 pcmcia: code cleanup Date: Mon, 6 Jun 2011 15:24:15 +0100 Message-Id: <1307370255-15963-4-git-send-email-jic23@cam.ac.uk> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1307370255-15963-1-git-send-email-jic23@cam.ac.uk> References: <1307370255-15963-1-git-send-email-jic23@cam.ac.uk> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110606_101618_929691_B7F8676F X-CRM114-Status: GOOD ( 20.58 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [131.111.8.152 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: marek.vasut@gmail.com, eric.y.miao@gmail.com, Jonathan Cameron X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 06 Jun 2011 14:17:53 +0000 (UTC) Check patch warnings and use of more modern gpio allocation etc. More can be done in here, but this is a start. Getting these cleaned up will make shared functionality much easier to spot and patches easier to review. Signed-off-by: Jonathan Cameron --- drivers/pcmcia/pxa2xx_trizeps4.c | 91 ++++++++++++++++++------------------- 1 files changed, 44 insertions(+), 47 deletions(-) diff --git a/drivers/pcmcia/pxa2xx_trizeps4.c b/drivers/pcmcia/pxa2xx_trizeps4.c index 57ddb96..e275402 100644 --- a/drivers/pcmcia/pxa2xx_trizeps4.c +++ b/drivers/pcmcia/pxa2xx_trizeps4.c @@ -42,16 +42,12 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt) */ switch (skt->nr) { case 0: - if (gpio_request(GPIO_PRDY, "cf_irq") < 0) { - pr_err("%s: sock %d unable to request gpio %d\n", __func__, - skt->nr, GPIO_PRDY); - return -EBUSY; - } - if (gpio_direction_input(GPIO_PRDY) < 0) { - pr_err("%s: sock %d unable to set input gpio %d\n", __func__, - skt->nr, GPIO_PRDY); - gpio_free(GPIO_PRDY); - return -EINVAL; + ret = gpio_request_one(GPIO_PRDY, GPIOF_IN, "cf_irq"); + if (ret < 0) { + pr_err("%s: sock %d unable to request gpio %d\n", + __func__, + skt->nr, GPIO_PRDY); + return ret; } skt->socket.pci_irq = IRQ_GPIO(GPIO_PRDY); break; @@ -59,32 +55,28 @@ static int trizeps_pcmcia_hw_init(struct soc_pcmcia_socket *skt) break; } /* release the reset of this card */ - pr_debug("%s: sock %d irq %d\n", __func__, skt->nr, skt->socket.pci_irq); + pr_debug("%s: sock %d irq %d\n", __func__, skt->nr, + skt->socket.pci_irq); /* supplementory irqs for the socket */ for (i = 0; i < ARRAY_SIZE(irqs); i++) { if (irqs[i].sock != skt->nr) continue; - if (gpio_request(irq_to_gpio(irqs[i].irq), irqs[i].str) < 0) { + ret = gpio_request_one(irq_to_gpio(irqs[i].irq), GPIOF_IN, + irqs[i].str); + if (ret < 0) { pr_err("%s: sock %d unable to request gpio %d\n", __func__, skt->nr, irq_to_gpio(irqs[i].irq)); - ret = -EBUSY; - goto error; - } - if (gpio_direction_input(irq_to_gpio(irqs[i].irq)) < 0) { - pr_err("%s: sock %d unable to set input gpio %d\n", - __func__, skt->nr, irq_to_gpio(irqs[i].irq)); - ret = -EINVAL; goto error; } } return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); error: - for (; i >= 0; i--) { + for (; i >= 0; i--) gpio_free(irq_to_gpio(irqs[i].irq)); - } - return (ret); + + return ret; } static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) @@ -94,6 +86,7 @@ static void trizeps_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) gpio_free(GPIO_PRDY); for (i = 0; i < ARRAY_SIZE(irqs); i++) gpio_free(irq_to_gpio(irqs[i].irq)); + soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); } static unsigned long trizeps_pcmcia_status[2]; @@ -101,32 +94,25 @@ static unsigned long trizeps_pcmcia_status[2]; static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) { - unsigned short status = 0, change; + unsigned short status, change; + status = CFSR_readw(); change = (status ^ trizeps_pcmcia_status[skt->nr]) & ConXS_CFSR_BVD_MASK; - if (change) { + if (change) trizeps_pcmcia_status[skt->nr] = status; - if (status & ConXS_CFSR_BVD1) { - /* enable_irq empty */ - } else { - /* disable_irq empty */ - } - } switch (skt->nr) { case 0: /* just fill in fix states */ - state->detect = gpio_get_value(GPIO_PCD) ? 0 : 1; - state->ready = gpio_get_value(GPIO_PRDY) ? 1 : 0; - state->bvd1 = (status & ConXS_CFSR_BVD1) ? 1 : 0; - state->bvd2 = (status & ConXS_CFSR_BVD2) ? 1 : 0; - state->vs_3v = (status & ConXS_CFSR_VS1) ? 0 : 1; - state->vs_Xv = (status & ConXS_CFSR_VS2) ? 0 : 1; + state->detect = !gpio_get_value(GPIO_PCD); + state->ready = !!gpio_get_value(GPIO_PRDY); + state->bvd1 = !!(status & ConXS_CFSR_BVD1); + state->bvd2 = !!(status & ConXS_CFSR_BVD2); + state->vs_3v = !(status & ConXS_CFSR_VS1); + state->vs_Xv = !(status & ConXS_CFSR_VS2); state->wrprot = 0; /* not available */ break; - -#ifndef CONFIG_MACH_TRIZEPS_CONXS /* on ConXS we only have one slot. Second is inactive */ case 1: state->detect = 0; @@ -137,8 +123,6 @@ static void trizeps_pcmcia_socket_state(struct soc_pcmcia_socket *skt, state->vs_Xv = 0; state->wrprot = 0; break; - -#endif } } @@ -150,8 +134,12 @@ static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, /* we do nothing here just check a bit */ switch (state->Vcc) { - case 0: power &= 0xfc; break; - case 33: power |= ConXS_BCR_S0_VCC_3V3; break; + case 0: + power &= 0xfc; + break; + case 33: + power |= ConXS_BCR_S0_VCC_3V3; + break; case 50: pr_err("%s(): Vcc 5V not supported in socket\n", __func__); break; @@ -161,8 +149,12 @@ static int trizeps_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, } switch (state->Vpp) { - case 0: power &= 0xf3; break; - case 33: power |= ConXS_BCR_S0_VPP_3V3; break; + case 0: + power &= 0xf3; + break; + case 33: + power |= ConXS_BCR_S0_VPP_3V3; + break; case 120: pr_err("%s(): Vpp 12V not supported in socket\n", __func__); break; @@ -232,12 +224,17 @@ static int __init trizeps_pcmcia_init(void) ret = platform_device_add_data(trizeps_pcmcia_device, &trizeps_pcmcia_ops, sizeof(trizeps_pcmcia_ops)); - if (ret == 0) - ret = platform_device_add(trizeps_pcmcia_device); + if (ret) + goto error_put_dev; + ret = platform_device_add(trizeps_pcmcia_device); if (ret) - platform_device_put(trizeps_pcmcia_device); + goto error_put_dev; + + return 0; +error_put_dev: + platform_device_put(trizeps_pcmcia_device); return ret; }