From patchwork Thu Jan 26 16:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 48791 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp365264wrn; Thu, 26 Jan 2023 08:33:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIsR6XYCOaPvYzKNkWHxZRKuawS1j5SwjR8LbIP0RPSNT5ZGhlyMwT3dPN8swYv1DI/GfX X-Received: by 2002:a05:6a20:4407:b0:b8:b89a:a905 with SMTP id ce7-20020a056a20440700b000b8b89aa905mr53346737pzb.45.1674750821798; Thu, 26 Jan 2023 08:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674750821; cv=none; d=google.com; s=arc-20160816; b=RpxNXVETaRVbvPXdwUIryWzRagE/wKl66fqAAdW5r6z0dsyMsVehfzOQhfREdw5rGy X+aV+qCIoXdyJ95g60FcGDeeLeYchv1JEB/Mqv+4DS14kl7uewHoiRcY9HA1rSeIos0k af7IG4Z9+25T/JFF3sZ3AEC3BD0OpmgJqGHKq1bCXoSBT/g0hMAi8s/ufflbfnH3bKFS 6igIe/shMq6J4YN5ggYMrB9hTVIrga7h3geuLlyANGKqtpelImG6R6dBHzA7ARHK89no JIAxUqJByhLTWEf0l+IWalE7WQ1hfjh0REV2nzb+sugKVbSPVGdAS7GwgioLiWgBFjvt Mo1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=I3KX9a+ElGyI4B7GADYfcNa0IVV2etV4l280Rusj6zw=; b=ipfgsrXk2nXxD2TgmK7Ma9qo3br4a33u2uUZqmcxHkoY1L1OgdH0LDplblx50I+crE wiBAJeBiU1133EpfaE1PqltDnfySko/0dv4rnsUjrr6qb8Iz4Pto4CPrHC8BncPIZPcw KtJKPJkBSCu2YXtYD1mp1CXEhZ9KXr3HjUXFaI/eX9BEPlr1JAuvIAaP5P78eVrhUFoF jpatnuOMYLwKvmiErgzley5AihODgLvLCD6+Nihl02EQP44wWq0BbataELCRTCfB4X1f Z3siuG7kGTvw75y9mA41eRqoI7H+oWDtleCIjMp+48Cc0Jt08WHN3bGllnBSZfcK3HgT w7eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PUkmHPZM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a63bf08000000b004da45c40f7esi1383882pgf.810.2023.01.26.08.33.29; Thu, 26 Jan 2023 08:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PUkmHPZM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbjAZQXv (ORCPT + 99 others); Thu, 26 Jan 2023 11:23:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjAZQXt (ORCPT ); Thu, 26 Jan 2023 11:23:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEC917171; Thu, 26 Jan 2023 08:23:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 89D016189B; Thu, 26 Jan 2023 16:23:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B78AC433D2; Thu, 26 Jan 2023 16:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674750210; bh=9x5Et+qBpE9iPODiuRYcyCiwO+b0CTtsum3j1rtN6ng=; h=From:To:Cc:Subject:Date:From; b=PUkmHPZMBCVT1g73E67mK37M1raigs8lH6TgYhfsT6Y4VJ3zzRaLozrrZzdov8P8V ps7j5o3E1XG+/gZcCyzG6q1uFQ3cSPg6vrSrn3wA/D7XY4NnOPIVG0EmQ8VUOwJzI4 MIBKfiWvffezRr7q6bR3Gvec7lM+ZXsGaB21nllxCXzCUGdPqAzzHk7/mUSrWX56FN SXGY6V1s6m0DXbIu2WdbCNlsjFybIBUn6mIGMV1WG1XdC5RI4SqHPyerItVRg0UCCZ EA2+WwKk9oCD4ix1wyyGRbQfGLOxpyFDPPMFiicfMrp2DMbIUFEX2rwpY7IukdL/LU iiQS+pjDsuBJg== From: Arnd Bergmann To: Alexander Aring , Stefan Schmidt Cc: Arnd Bergmann , Miquel Raynal , Andy Shevchenko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] [v2] at86rf230: convert to gpio descriptors Date: Thu, 26 Jan 2023 17:22:59 +0100 Message-Id: <20230126162323.2986682-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756103517441709549?= X-GMAIL-MSGID: =?utf-8?q?1756103517441709549?= From: Arnd Bergmann There are no remaining in-tree users of the platform_data, so this driver can be converted to using the simpler gpiod interfaces. Any out-of-tree users that rely on the platform data can provide the data using the device_property and gpio_lookup interfaces instead. Reviewed-by: Miquel Raynal Reviewed-by: Andy Shevchenko Signed-off-by: Arnd Bergmann --- drivers/net/ieee802154/at86rf230.c | 82 +++++++++--------------------- include/linux/spi/at86rf230.h | 20 -------- 2 files changed, 25 insertions(+), 77 deletions(-) delete mode 100644 include/linux/spi/at86rf230.h diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c index 15f283b26721..a4a6b7490fdc 100644 --- a/drivers/net/ieee802154/at86rf230.c +++ b/drivers/net/ieee802154/at86rf230.c @@ -15,13 +15,12 @@ #include #include #include -#include #include +#include #include -#include +#include #include #include -#include #include #include @@ -82,7 +81,7 @@ struct at86rf230_local { struct ieee802154_hw *hw; struct at86rf2xx_chip_data *data; struct regmap *regmap; - int slp_tr; + struct gpio_desc *slp_tr; bool sleep; struct completion state_complete; @@ -107,8 +106,8 @@ at86rf230_async_state_change(struct at86rf230_local *lp, static inline void at86rf230_sleep(struct at86rf230_local *lp) { - if (gpio_is_valid(lp->slp_tr)) { - gpio_set_value(lp->slp_tr, 1); + if (lp->slp_tr) { + gpiod_set_value(lp->slp_tr, 1); usleep_range(lp->data->t_off_to_sleep, lp->data->t_off_to_sleep + 10); lp->sleep = true; @@ -118,8 +117,8 @@ at86rf230_sleep(struct at86rf230_local *lp) static inline void at86rf230_awake(struct at86rf230_local *lp) { - if (gpio_is_valid(lp->slp_tr)) { - gpio_set_value(lp->slp_tr, 0); + if (lp->slp_tr) { + gpiod_set_value(lp->slp_tr, 0); usleep_range(lp->data->t_sleep_to_off, lp->data->t_sleep_to_off + 100); lp->sleep = false; @@ -204,9 +203,9 @@ at86rf230_write_subreg(struct at86rf230_local *lp, static inline void at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp) { - gpio_set_value(lp->slp_tr, 1); + gpiod_set_value(lp->slp_tr, 1); udelay(1); - gpio_set_value(lp->slp_tr, 0); + gpiod_set_value(lp->slp_tr, 0); } static bool @@ -819,7 +818,7 @@ at86rf230_write_frame_complete(void *context) ctx->trx.len = 2; - if (gpio_is_valid(lp->slp_tr)) + if (lp->slp_tr) at86rf230_slp_tr_rising_edge(lp); else at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx, @@ -1415,32 +1414,6 @@ static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim) return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0); } -static int -at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr, - u8 *xtal_trim) -{ - struct at86rf230_platform_data *pdata = spi->dev.platform_data; - int ret; - - if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) { - if (!pdata) - return -ENOENT; - - *rstn = pdata->rstn; - *slp_tr = pdata->slp_tr; - *xtal_trim = pdata->xtal_trim; - return 0; - } - - *rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0); - *slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0); - ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim); - if (ret < 0 && ret != -EINVAL) - return ret; - - return 0; -} - static int at86rf230_detect_device(struct at86rf230_local *lp) { @@ -1547,7 +1520,8 @@ static int at86rf230_probe(struct spi_device *spi) struct ieee802154_hw *hw; struct at86rf230_local *lp; unsigned int status; - int rc, irq_type, rstn, slp_tr; + int rc, irq_type; + struct gpio_desc *rstn, *slp_tr; u8 xtal_trim = 0; if (!spi->irq) { @@ -1555,32 +1529,26 @@ static int at86rf230_probe(struct spi_device *spi) return -EINVAL; } - rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim); - if (rc < 0) { - dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc); + rc = device_property_read_u8(&spi->dev, "xtal-trim", &xtal_trim); + if (rc < 0 && rc != -EINVAL) { + dev_err(&spi->dev, "failed to parse xtal-trim: %d\n", rc); return rc; } - if (gpio_is_valid(rstn)) { - rc = devm_gpio_request_one(&spi->dev, rstn, - GPIOF_OUT_INIT_HIGH, "rstn"); - if (rc) - return rc; - } + rstn = devm_gpiod_get_optional(&spi->dev, "rstn", GPIOD_OUT_HIGH); + if (IS_ERR(rstn)) + return PTR_ERR(rstn); - if (gpio_is_valid(slp_tr)) { - rc = devm_gpio_request_one(&spi->dev, slp_tr, - GPIOF_OUT_INIT_LOW, "slp_tr"); - if (rc) - return rc; - } + slp_tr = devm_gpiod_get_optional(&spi->dev, "slp_tr", GPIOD_OUT_LOW); + if (IS_ERR(slp_tr)) + return PTR_ERR(slp_tr); /* Reset */ - if (gpio_is_valid(rstn)) { + if (rstn) { udelay(1); - gpio_set_value_cansleep(rstn, 0); + gpiod_set_value_cansleep(rstn, 0); udelay(1); - gpio_set_value_cansleep(rstn, 1); + gpiod_set_value_cansleep(rstn, 1); usleep_range(120, 240); } @@ -1682,7 +1650,7 @@ MODULE_DEVICE_TABLE(spi, at86rf230_device_id); static struct spi_driver at86rf230_driver = { .id_table = at86rf230_device_id, .driver = { - .of_match_table = of_match_ptr(at86rf230_of_match), + .of_match_table = at86rf230_of_match, .name = "at86rf230", }, .probe = at86rf230_probe, diff --git a/include/linux/spi/at86rf230.h b/include/linux/spi/at86rf230.h deleted file mode 100644 index d278576ab692..000000000000 --- a/include/linux/spi/at86rf230.h +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * AT86RF230/RF231 driver - * - * Copyright (C) 2009-2012 Siemens AG - * - * Written by: - * Dmitry Eremin-Solenikov - */ -#ifndef AT86RF230_H -#define AT86RF230_H - -struct at86rf230_platform_data { - int rstn; - int slp_tr; - int dig2; - u8 xtal_trim; -}; - -#endif