From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA3ABC4332F for ; Thu, 10 Nov 2022 22:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cKaZkweK+4Cc5IhiRDJIwinDX/h2fJQnkx/GuDlHWwU=; b=KOMXu8bSiGWYoH rjbnD/tbt5rPIUd05xQgz77aquTzQkbR8zPpCCDUsRMpWDbv6yowaOIFmZis4/wjg1T4Rdmcs3MG6 qdgD9ZDP2N3MKBq5LW6Ah9aums4/TfsbMaPOs2gR1surr9lFfz9VcCQ3Vy8d7sZYyN/RektbQ5eIS EkdFH6rVPVB3N+mHjQRuD9ky3AZq/QTCQEruBRRSrxF7mb2dLtqn+cZt19xJdHtB/ICObdOg/9eDE soeLoVlLXZDLNPPG4N3by9omm78LuzZNAOfvId9P2swAQvG54QGSGGX2ZuE0Rg+a5mWw+ku3UeYt4 KhStbF+3sRgyDBUvADFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1otGFD-00Am2l-4u; Thu, 10 Nov 2022 22:41:59 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1otGFA-00Am2A-KM for linux-arm-kernel@lists.infradead.org; Thu, 10 Nov 2022 22:41:58 +0000 Received: by mail-pl1-x62a.google.com with SMTP id v17so2783883plo.1 for ; Thu, 10 Nov 2022 14:41:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=e4Qs9bEMZ3gDq4us7OrdRRiLVNWHDOmZfbfm48tPnck=; b=qbRnu/4LZoqDMzfN1T1kE9YREn4aOucC9lhaWV9gbrwXT7sX/dmca+ETwg9QN60uej p8/Lw/7Tfa456Y3swGCmPC7MqQ9wuo3x4IukSs7pmsB4ZnVsmSs6tCcwu9jjzAnodbID 5z6W2WyndMTL55lQSd6SEjmbeOvJ014Xw6UZzuJqQT+N0mn2hlEUwKTU3depJF9O3/yy dxi0S3JnQZrzAGrA6eUWxlA+OBuyUHzpwHeNquZ6sfczJiRhHbx2YxTizx5S/KCtX6y3 o6jTHlJzo9M4Vm8OAmn/VAOTw2r0tZWDzXdgIMx8zflLzC5EOviXDk7Wu/i/68YDy2Ch f8Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=e4Qs9bEMZ3gDq4us7OrdRRiLVNWHDOmZfbfm48tPnck=; b=2MLTkvTArbc3xQN+M//fCj8aNHG69Wi9fQlpuJM4a+cEJGlQTsSnYspin4dHWEtg7/ GkOsUQWVXLStJajwEq1uOUvKgTFUojPBFx7BTbXAwGoWHJ0raAKoG1qOue+xRCwRGow9 pOlYS62SHZZxYlvbzBapUTTBBvTmrDD+kp9yj1FzzzkubYpG7GPgtVfZIPlc2Ea20QsX Yr/hLXQ/fcmt+G7aR602Hb+LROdVTa5kf7U7XYld0u2Ucx+7RnWjZH9eIwxVHQditYlM 3ZSc1s7+Xed++9u8o0lhlMOnqGuSGx81NTMobO6lUYHlED+2B1B/LNLA3vDHpS0DgWYj zvyA== X-Gm-Message-State: ACrzQf3UzPgtyZCa4lKkWbXknFPa2FsvAFo+DF7Tci4pDDdH3QT/gv5z T3MpvJ5LuP17sq3rY+8BNOA= X-Google-Smtp-Source: AMsMyM4nyW6+yaR60JXHJABSjQGw+eHKUCsaYHz+iJNpbD3jbsh6paIIOlj4vz9grbTk8YBdFHZ+aw== X-Received: by 2002:a17:902:8211:b0:183:7f67:25d7 with SMTP id x17-20020a170902821100b001837f6725d7mr2346968pln.164.1668120115608; Thu, 10 Nov 2022 14:41:55 -0800 (PST) Received: from google.com ([2620:15c:9d:2:2eb5:1c59:61e8:a36d]) by smtp.gmail.com with ESMTPSA id d17-20020a170902ced100b001868ed86a95sm188133plg.174.2022.11.10.14.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 14:41:54 -0800 (PST) Date: Thu, 10 Nov 2022 14:41:51 -0800 From: Dmitry Torokhov To: Balamanikandan Gunasundar Subject: Re: [PATCH] mmc: atmel-mci: Convert to gpio descriptors Message-ID: References: <20221109043845.16617-1-balamanikandan.gunasundar@microchip.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221109043845.16617-1-balamanikandan.gunasundar@microchip.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221110_144156_706751_842D0047 X-CRM114-Status: GOOD ( 24.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, linux-kernel@vger.kernel.org, linux-atm-general@lists.sourceforge.net, linux-mmc@vger.kernel.org, alexandre.belloni@bootlin.com, ludovic.desroches@microchip.com, 3chas3@gmail.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Balamanikandan, On Wed, Nov 09, 2022 at 10:08:45AM +0530, Balamanikandan Gunasundar wrote: > Replace the legacy GPIO APIs with gpio descriptor consumer interface. > > To maintain backward compatibility, we rely on the "cd-inverted" > property to manage the invertion flag instead of GPIO property. > > Signed-off-by: Balamanikandan Gunasundar > --- > drivers/mmc/host/atmel-mci.c | 79 ++++++++++++++++++------------------ > include/linux/atmel-mci.h | 4 +- > 2 files changed, 41 insertions(+), 42 deletions(-) > > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c > index 67b2cd166e56..1df90966e104 100644 > --- a/drivers/mmc/host/atmel-mci.c > +++ b/drivers/mmc/host/atmel-mci.c > @@ -19,7 +19,8 @@ > #include > #include > #include > -#include > +#include > +#include > #include > #include > #include > @@ -389,8 +390,8 @@ struct atmel_mci_slot { > #define ATMCI_CARD_NEED_INIT 1 > #define ATMCI_SHUTDOWN 2 > > - int detect_pin; > - int wp_pin; > + struct gpio_desc *detect_pin; > + struct gpio_desc *wp_pin; > bool detect_is_active_high; > > struct timer_list detect_timer; > @@ -638,7 +639,11 @@ atmci_of_init(struct platform_device *pdev) > pdata->slot[slot_id].bus_width = 1; > > pdata->slot[slot_id].detect_pin = > - of_get_named_gpio(cnp, "cd-gpios", 0); > + devm_gpiod_get_from_of_node(&pdev->dev, cnp, > + "cd-gpios", > + 0, GPIOD_IN, "cd-gpios"); As I mentioned in another email, please use devm_fwnode_gpiod_get() instead of devm_gpiod_get_from_of_node() which is going away. > + if (IS_ERR(pdata->slot[slot_id].detect_pin)) > + pdata->slot[slot_id].detect_pin = NULL; I think it would be much better if we had proper error handling and did something like: err = PTR_ERR_OR_ZERO(pdata->slot[slot_id].detect_pin); if (err) { if (err != -ENOENT) return ERR_PTR(err); pdata->slot[slot_id].detect_pin = NULL; } This will help with proper deferral handling. > > pdata->slot[slot_id].detect_is_active_high = > of_property_read_bool(cnp, "cd-inverted"); Instead of doing gpiod_set_value_raw() below I would recommend handling it here via gpiod_is_active_low() and gpiod_toggle_active_low() and removing the flag from atmel_mci_slot structure. > @@ -647,7 +652,11 @@ atmci_of_init(struct platform_device *pdev) > of_property_read_bool(cnp, "non-removable"); > > pdata->slot[slot_id].wp_pin = > - of_get_named_gpio(cnp, "wp-gpios", 0); > + devm_gpiod_get_from_of_node(&pdev->dev, cnp, > + "wp-gpios", > + 0, GPIOD_IN, "wp-gpios"); > + if (IS_ERR(pdata->slot[slot_id].wp_pin)) > + pdata->slot[slot_id].wp_pin = NULL; > } > > return pdata; > @@ -1511,8 +1520,8 @@ static int atmci_get_ro(struct mmc_host *mmc) > int read_only = -ENOSYS; > struct atmel_mci_slot *slot = mmc_priv(mmc); > > - if (gpio_is_valid(slot->wp_pin)) { > - read_only = gpio_get_value(slot->wp_pin); > + if (slot->wp_pin) { > + read_only = gpiod_get_value(slot->wp_pin); Consider using "cansleep" variants. Thanks. -- Dmitry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel