From patchwork Fri Aug 31 21:46:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xue Liu X-Patchwork-Id: 10584491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D33A317DB for ; Fri, 31 Aug 2018 21:46:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF3272C44D for ; Fri, 31 Aug 2018 21:46:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B38622C512; Fri, 31 Aug 2018 21:46:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50DDE2C44D for ; Fri, 31 Aug 2018 21:46:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727212AbeIAB4O (ORCPT ); Fri, 31 Aug 2018 21:56:14 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43625 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726915AbeIAB4O (ORCPT ); Fri, 31 Aug 2018 21:56:14 -0400 Received: by mail-wr1-f67.google.com with SMTP id k5-v6so12410171wre.10 for ; Fri, 31 Aug 2018 14:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=HNIfeSPtxMQ4d3O4TLY1qmSN10NIlDYlNBYnFTws3TI=; b=hKc8KcyAQzKgQqZBYYrUyVXEtfZoblo5ylRAVWaMnAR9JnEFcmvINpaK1zJLVZdIZe qqrW7rebR63p33rhJ2FKpngEkHG6H15/IOkbjAe4SPB9CrMC282TA+OO6GaPH4byc794 uPI0SViMWcUPOe9uuQz/h4Iy9zKzcVS6hODO5O8BpiXOA4GcelwSEvdd5AFechxR6VKI MJnCQnkbFwPdVHlHkWunAi52GBtPyEab+QObUKnQGpN1FWnTlSMW5dCEgYiy1+0u0o2n rDlxOuSS/u0sTxeU53aXHI/qETI8AAMhO2o6kfzYau0yig/RKkyGCTrQ472QaZ4lIBd1 +ZvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HNIfeSPtxMQ4d3O4TLY1qmSN10NIlDYlNBYnFTws3TI=; b=bjhf6J380uVQQhfOu8cm05bO9KYEYXnRuaA++5aoMtLyCn5exgu1kbBVsO6G1bGIH5 dRKTujb2xE/z8z26YyFocevxL4TrwLdWR//4pn5yjXN76C1aPp22A13tCwahxl3j0Taw 9/nGb9LnIPalrYC7CLpQRas2Wxl+cZ6sdPd9m+9czjIWS1EiyrM+Au8bmRzxVvcZsWwy rxKzgrbrziDzWBaVVgJdtrBVgws6ZePZpU5pA92HSzjscD++/xvSS3ie3NbVua/qWmG7 S5TQMk4M5kZD/YUevsr/bbkaGEoIrLUD83vJc0upRLUVdDUZQUkfQ3J1CJZTGjZvq/Fi +TKQ== X-Gm-Message-State: APzg51Bf8RNyWKd48QzP4r79A3acrxlC+OM3uo33Ejw7QJSn6O+ZnVMf JmLvll4ilHbYgct2R7M8ZCOz/DZWrIw= X-Google-Smtp-Source: ANB0VdawoWnrwzyVoTcv4LTsVZUvYBrp+VIQ/HtKiDFIvqusigbEJWY+T6LLeKpH1PMBwfACoMToDQ== X-Received: by 2002:adf:8445:: with SMTP id 63-v6mr12274020wrf.41.1535752008042; Fri, 31 Aug 2018 14:46:48 -0700 (PDT) Received: from cc-PC.fritz.box (dslb-002-200-211-021.002.200.pools.vodafone-ip.de. [2.200.211.21]) by smtp.googlemail.com with ESMTPSA id j11-v6sm8342064wrr.37.2018.08.31.14.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Aug 2018 14:46:46 -0700 (PDT) From: Xue Liu To: linux-wpan@vger.kernel.org, stefan@datenfreihafen.org, alex.aring@gmail.com Subject: [PATCH 2/2] ieee802154: mcr20a: Remove struct mcr20a_platform_data Date: Fri, 31 Aug 2018 23:46:42 +0200 Message-Id: <20180831214642.30711-3-liuxuenetmail@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180831214642.30711-1-liuxuenetmail@gmail.com> References: <20180831214642.30711-1-liuxuenetmail@gmail.com> Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The struct mcr20a_platform_data is uesed only in probe function and it holds only one member. So it is not necessary to reserve it. Using gpiod family API to handle reset pin. Signed-off-by: Xue Liu --- drivers/net/ieee802154/mcr20a.c | 64 +++++++-------------------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c index 04891429a554..44de81e5f140 100644 --- a/drivers/net/ieee802154/mcr20a.c +++ b/drivers/net/ieee802154/mcr20a.c @@ -132,11 +132,6 @@ static const struct reg_sequence mar20a_iar_overwrites[] = { }; #define MCR20A_VALID_CHANNELS (0x07FFF800) - -struct mcr20a_platform_data { - int rst_gpio; -}; - #define MCR20A_MAX_BUF (127) #define printdev(X) (&X->spi->dev) @@ -412,7 +407,6 @@ struct mcr20a_local { struct spi_device *spi; struct ieee802154_hw *hw; - struct mcr20a_platform_data *pdata; struct regmap *regmap_dar; struct regmap *regmap_iar; @@ -976,20 +970,6 @@ static irqreturn_t mcr20a_irq_isr(int irq, void *data) return IRQ_HANDLED; } -static int mcr20a_get_platform_data(struct spi_device *spi, - struct mcr20a_platform_data *pdata) -{ - int ret = 0; - - if (!spi->dev.of_node) - return -EINVAL; - - pdata->rst_gpio = of_get_named_gpio(spi->dev.of_node, "rst_b-gpio", 0); - dev_dbg(&spi->dev, "rst_b-gpio: %d\n", pdata->rst_gpio); - - return ret; -} - static void mcr20a_hw_setup(struct mcr20a_local *lp) { u8 i; @@ -1249,7 +1229,7 @@ mcr20a_probe(struct spi_device *spi) { struct ieee802154_hw *hw; struct mcr20a_local *lp; - struct mcr20a_platform_data *pdata; + struct gpio_desc *rst_b; int irq_type; int ret = -ENOMEM; @@ -1260,48 +1240,32 @@ mcr20a_probe(struct spi_device *spi) return -EINVAL; } - pdata = kmalloc(sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - /* set mcr20a platform data */ - ret = mcr20a_get_platform_data(spi, pdata); - if (ret < 0) { - dev_crit(&spi->dev, "mcr20a_get_platform_data failed.\n"); - goto free_pdata; - } - - /* init reset gpio */ - if (gpio_is_valid(pdata->rst_gpio)) { - ret = devm_gpio_request_one(&spi->dev, pdata->rst_gpio, - GPIOF_OUT_INIT_HIGH, "reset"); - if (ret) - goto free_pdata; + rst_b = devm_gpiod_get(&spi->dev, "rst_b", GPIOD_OUT_HIGH); + if (IS_ERR(rst_b)) { + ret = PTR_ERR(rst_b); + if (ret != -EPROBE_DEFER) + dev_err(&spi->dev, "Failed to get 'rst_b' gpio: %d", ret); + return ret; } /* reset mcr20a */ - if (gpio_is_valid(pdata->rst_gpio)) { - usleep_range(10, 20); - gpio_set_value_cansleep(pdata->rst_gpio, 0); - usleep_range(10, 20); - gpio_set_value_cansleep(pdata->rst_gpio, 1); - usleep_range(120, 240); - } + usleep_range(10, 20); + gpiod_set_value_cansleep(rst_b, 1); + usleep_range(10, 20); + gpiod_set_value_cansleep(rst_b, 0); + usleep_range(120, 240); /* allocate ieee802154_hw and private data */ hw = ieee802154_alloc_hw(sizeof(*lp), &mcr20a_hw_ops); if (!hw) { dev_crit(&spi->dev, "ieee802154_alloc_hw failed\n"); - ret = -ENOMEM; - goto free_pdata; + return ret; } /* init mcr20a local data */ lp = hw->priv; lp->hw = hw; lp->spi = spi; - lp->spi->dev.platform_data = pdata; - lp->pdata = pdata; /* init ieee802154_hw */ hw->parent = &spi->dev; @@ -1370,8 +1334,6 @@ mcr20a_probe(struct spi_device *spi) free_dev: ieee802154_free_hw(lp->hw); -free_pdata: - kfree(pdata); return ret; }