From patchwork Mon Mar 2 07:00:44 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: 5910321 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 E21E99F36A for ; Mon, 2 Mar 2015 07:01:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F749201FB for ; Mon, 2 Mar 2015 07:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF365201F2 for ; Mon, 2 Mar 2015 07:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751891AbbCBHBL (ORCPT ); Mon, 2 Mar 2015 02:01:11 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:48169 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751696AbbCBHBK (ORCPT ); Mon, 2 Mar 2015 02:01:10 -0500 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 1YSKLd-0003sf-Kl; Mon, 02 Mar 2015 08:01:01 +0100 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1YSKLZ-0008FL-Hj; Mon, 02 Mar 2015 08:00:57 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Hans Verkuil , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, kernel@pengutronix.de, Alexandre Courbot , Linus Walleij Subject: [PATCH] media: adv7604: improve usage of gpiod API Date: Mon, 2 Mar 2015 08:00:44 +0100 Message-Id: <1425279644-25873-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 devm_gpiod_get_index_optional instead of devm_gpiod_get_index with ignoring all errors. Signed-off-by: Uwe Kleine-König --- BTW, sparse fails to check this file with many errors like: drivers/media/i2c/adv7604.c:311:11: error: unknown field name in initializer Didn't look into that. --- drivers/media/i2c/adv7604.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 5a7c9389a605..ddeeb6695a4b 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -537,12 +537,8 @@ static void adv7604_set_hpd(struct adv7604_state *state, unsigned int hpd) { unsigned int i; - for (i = 0; i < state->info->num_dv_ports; ++i) { - if (IS_ERR(state->hpd_gpio[i])) - continue; - + for (i = 0; i < state->info->num_dv_ports; ++i) gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i)); - } v4l2_subdev_notify(&state->sd, ADV7604_HOTPLUG, &hpd); } @@ -2720,13 +2716,13 @@ static int adv7604_probe(struct i2c_client *client, /* Request GPIOs. */ for (i = 0; i < state->info->num_dv_ports; ++i) { state->hpd_gpio[i] = - devm_gpiod_get_index(&client->dev, "hpd", i); + devm_gpiod_get_index_optional(&client->dev, "hpd", i, + GPIOD_OUT_LOW); if (IS_ERR(state->hpd_gpio[i])) - continue; - - gpiod_direction_output(state->hpd_gpio[i], 0); + return PTR_ERR(state->hpd_gpio[i]); - v4l_info(client, "Handling HPD %u GPIO\n", i); + if (state->hpd_gpio[i]) + v4l_info(client, "Handling HPD %u GPIO\n", i); } state->timings = cea640x480;