From patchwork Thu Mar 26 20:47:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 6102101 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F3D519F2A9 for ; Thu, 26 Mar 2015 20:48:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2046520412 for ; Thu, 26 Mar 2015 20:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D254A203F7 for ; Thu, 26 Mar 2015 20:48:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752175AbbCZUsK (ORCPT ); Thu, 26 Mar 2015 16:48:10 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:45230 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752144AbbCZUsJ (ORCPT ); Thu, 26 Mar 2015 16:48:09 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1YbEhD-0007vT-F2; Thu, 26 Mar 2015 21:48:07 +0100 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1YbEhB-0000Xz-7b; Thu, 26 Mar 2015 21:48:05 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Eduardo Valentin , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] media: radio-si4713: improve usage of gpiod API Date: Thu, 26 Mar 2015 21:47:53 +0100 Message-Id: <1427402873-2007-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for output. Simplify accordingly. Moreover use the _optional variant which has tighter error checking, but is simpler to use which allows further simplification. Signed-off-by: Uwe Kleine-König --- drivers/media/radio/si4713/si4713.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/media/radio/si4713/si4713.c b/drivers/media/radio/si4713/si4713.c index c90004dac170..e9d03ac69a27 100644 --- a/drivers/media/radio/si4713/si4713.c +++ b/drivers/media/radio/si4713/si4713.c @@ -383,7 +383,7 @@ static int si4713_powerup(struct si4713_device *sdev) } } - if (!IS_ERR(sdev->gpio_reset)) { + if (sdev->gpio_reset) { udelay(50); gpiod_set_value(sdev->gpio_reset, 1); } @@ -407,8 +407,7 @@ static int si4713_powerup(struct si4713_device *sdev) SI4713_STC_INT | SI4713_CTS); return err; } - if (!IS_ERR(sdev->gpio_reset)) - gpiod_set_value(sdev->gpio_reset, 0); + gpiod_set_value(sdev->gpio_reset, 0); if (sdev->vdd) { @@ -447,7 +446,7 @@ static int si4713_powerdown(struct si4713_device *sdev) v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", resp[0]); v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); - if (!IS_ERR(sdev->gpio_reset)) + if (sdev->gpio_reset) gpiod_set_value(sdev->gpio_reset, 0); if (sdev->vdd) { @@ -1460,14 +1459,9 @@ static int si4713_probe(struct i2c_client *client, goto exit; } - sdev->gpio_reset = devm_gpiod_get(&client->dev, "reset"); - if (!IS_ERR(sdev->gpio_reset)) { - gpiod_direction_output(sdev->gpio_reset, 0); - } else if (PTR_ERR(sdev->gpio_reset) == -ENOENT) { - dev_dbg(&client->dev, "No reset GPIO assigned\n"); - } else if (PTR_ERR(sdev->gpio_reset) == -ENOSYS) { - dev_dbg(&client->dev, "No reset GPIO support\n"); - } else { + sdev->gpio_reset = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(sdev->gpio_reset)) { rval = PTR_ERR(sdev->gpio_reset); dev_err(&client->dev, "Failed to request gpio: %d\n", rval); goto exit;