From patchwork Mon Mar 3 16:49:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13999212 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D233253F22; Mon, 3 Mar 2025 16:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020577; cv=none; b=t0rrKwbsye8aOCX1+RjMDZLN2MGMgf7Regz1XJfT2p9qWwYunOlwVZ0uVFx1R+DTQsUIeQ94vGfZfurwxOzKy4FohmSJrJMVo5yCRuVxHpQ07Dtev192tMoblJNVueIhc9ZgfogEwG9DThVb6VShqrIy5yDoD/dHdXJPdugTiQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020577; c=relaxed/simple; bh=66qhaQBgr0QtdaPsd5LfhInRqDNLNDX1iLGRWakulAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EUgNwcdTYA2t5cVmRfUBopFgc5+Bcack1CXgmWsdEYRlxskeTO6YKFOx1Uy1Hii9ANKBkXlnam5hHt4mZyMDCxZyIx82gcXM7bU6zQAdK1en+b1AH2OC0MmbIZ3umwxRwcPZSKWth7QjJcns2QYQRQd2E97Nrr/gby9gttU2PGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FWwRahVT; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FWwRahVT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741020576; x=1772556576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=66qhaQBgr0QtdaPsd5LfhInRqDNLNDX1iLGRWakulAo=; b=FWwRahVTj/gula0qmotim9hoBXRG9MsxQgjknZqHndIfYhhtsZcS1TCZ ay+WQ8fiIEIdEr6FQdAhA4NBSjakgcOh1W0lalg4mQEvmlpjk307xpmjP 8xjfLWDH+Rllb2HDCeKwOgYaA33Xe8WaUFCIylIK4IHpoLrFUrVcMpEG3 KLlHz2dSoH5Gk06cvAA1H2DpU7uME41TavVS4BoCF3//bl+cPiJhIixFA /ZFXVCQbmOIQEM97g/PTsZwE37owAIaF/bBG57ZqPMea3MhjWQKjBXoBI q7wjHWnt9kuJjttL17jG974lXtUfwiSR/gbA4LsOzw2Xohsv7jEaHvvGO w==; X-CSE-ConnectionGUID: Dye6RS+pQ7yG2FsxC6HyrQ== X-CSE-MsgGUID: H1yCQRdPSe6gW6dEyeo+gA== X-IronPort-AV: E=McAfee;i="6700,10204,11362"; a="52883759" X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="52883759" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2025 08:49:35 -0800 X-CSE-ConnectionGUID: zI2mBBkDRXSd5pA79K5hOQ== X-CSE-MsgGUID: RaCdYLjzQfmur4btK2HR6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="123324425" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa005.jf.intel.com with ESMTP; 03 Mar 2025 08:49:31 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8D5BCDC; Mon, 03 Mar 2025 18:49:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , Miquel Raynal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , Bartosz Golaszewski Subject: [PATCH net-next v2 1/3] ieee802154: ca8210: Use proper setter and getters for bitwise types Date: Mon, 3 Mar 2025 18:49:08 +0200 Message-ID: <20250303164928.1466246-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> References: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Sparse complains that the driver doesn't respect the bitwise types: drivers/net/ieee802154/ca8210.c:1796:27: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1796:27: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1796:27: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1801:25: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1801:25: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1801:25: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1928:28: warning: incorrect type in argument 3 (different base types) drivers/net/ieee802154/ca8210.c:1928:28: expected unsigned short [usertype] dst_pan_id drivers/net/ieee802154/ca8210.c:1928:28: got restricted __le16 [addressable] [usertype] pan_id Use proper setter and getters for bitwise types. Note, in accordance with [1] the protocol is little endian. Link: https://www.cascoda.com/wp-content/uploads/2018/11/CA-8210_datasheet_0418.pdf [1] Reviewed-by: Miquel Raynal Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/net/ieee802154/ca8210.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 753215ebc67c..a036910f6082 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -1446,8 +1446,7 @@ static u8 mcps_data_request( command.pdata.data_req.src_addr_mode = src_addr_mode; command.pdata.data_req.dst.mode = dst_address_mode; if (dst_address_mode != MAC_MODE_NO_ADDR) { - command.pdata.data_req.dst.pan_id[0] = LS_BYTE(dst_pan_id); - command.pdata.data_req.dst.pan_id[1] = MS_BYTE(dst_pan_id); + put_unaligned_le16(dst_pan_id, command.pdata.data_req.dst.pan_id); if (dst_address_mode == MAC_MODE_SHORT_ADDR) { command.pdata.data_req.dst.address[0] = LS_BYTE( dst_addr->short_address @@ -1795,12 +1794,12 @@ static int ca8210_skb_rx( } hdr.source.mode = data_ind[0]; dev_dbg(&priv->spi->dev, "srcAddrMode: %#03x\n", hdr.source.mode); - hdr.source.pan_id = *(u16 *)&data_ind[1]; + hdr.source.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[1])); dev_dbg(&priv->spi->dev, "srcPanId: %#06x\n", hdr.source.pan_id); memcpy(&hdr.source.extended_addr, &data_ind[3], 8); hdr.dest.mode = data_ind[11]; dev_dbg(&priv->spi->dev, "dstAddrMode: %#03x\n", hdr.dest.mode); - hdr.dest.pan_id = *(u16 *)&data_ind[12]; + hdr.dest.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[12])); dev_dbg(&priv->spi->dev, "dstPanId: %#06x\n", hdr.dest.pan_id); memcpy(&hdr.dest.extended_addr, &data_ind[14], 8); @@ -1927,7 +1926,7 @@ static int ca8210_skb_tx( status = mcps_data_request( header.source.mode, header.dest.mode, - header.dest.pan_id, + le16_to_cpu(header.dest.pan_id), (union macaddr *)&header.dest.extended_addr, skb->len - mac_len, &skb->data[mac_len], From patchwork Mon Mar 3 16:49:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13999211 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B969253F24; Mon, 3 Mar 2025 16:49:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020576; cv=none; b=Fl6Q4O9nmv6qP2sObo5LAS1aZfuBiOMZA1WwrBZubLHnNhbtO/UgXfvWvAZ2JuoaAFSQx6sxzE/YnVpB1weutSGbQw0PjTbA7DBlEo8WIc1AFF4FPUAtdxC6rBh+qkpeim4wF3nQEGaBeFmDVPgs0NK8V8YjLFmgKm79+3dETMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020576; c=relaxed/simple; bh=PgymxrapIwEkqIJnDFsAgZKjAOuBSrz6G8oyvNtMtgE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q7vgM6JpQ7bDgTwQNCIM+iOj9H14UiAqTGy7bbyCUMuGqkbYGxcx2PN7bzeQTcBNJQ/ZtQrUK2FTs0Hak1c14bKOyWaFCN7N3QcHbcrvqtq8cmWzcWiTR43kZb2ox0VHnGruHvu0k0gBMHJOy3ANEYC92uQIIS1vMhxxWwB7XdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Xy0QtwKE; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Xy0QtwKE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741020575; x=1772556575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PgymxrapIwEkqIJnDFsAgZKjAOuBSrz6G8oyvNtMtgE=; b=Xy0QtwKErWR86mLuXz237W1dv1xLaoDTSdgbw0IYqSQQMEhom+EbArQx p/1jGazZ5YMJEmLOHTv14kfVeU4DEcAU++n2VGhv8ON9F2wFOR4T5sHZc TD9DjwR2x0HsGOGrX8S08qyxwP4G7V8tGk4lSSh8IIR42u1WkUrwFoPxf s6ssbNpHsZ9Z7NZLRLwPuHAwTaFHoJK0UgNsSbGdgnfbO2YaS+HMGE+mv zZGmFY/IVjuh/kp99M+smU3WZdvmb5DwcPOQ6tbiOXGApT2LDVqHkbBRG B8k/92L0q1PPCRijhxbdzygK83xrVtT4+UxsUPWJv84EzH4OEJRNG/HjV A==; X-CSE-ConnectionGUID: FwRlmoF4Q1empaeOKODJ6A== X-CSE-MsgGUID: xAiP2uKNQSKLADbw0zmbUA== X-IronPort-AV: E=McAfee;i="6700,10204,11362"; a="41761391" X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="41761391" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2025 08:49:34 -0800 X-CSE-ConnectionGUID: rGlG1Fp1SLiLANdqv5KXaQ== X-CSE-MsgGUID: XzTS+SNlQoe7unm3L7cOUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="123212197" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 03 Mar 2025 08:49:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id A7309224; Mon, 03 Mar 2025 18:49:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , Miquel Raynal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , Bartosz Golaszewski Subject: [PATCH net-next v2 2/3] ieee802154: ca8210: Get platform data via dev_get_platdata() Date: Mon, 3 Mar 2025 18:49:09 +0200 Message-ID: <20250303164928.1466246-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> References: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Access to platform data via dev_get_platdata() getter to make code cleaner. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/net/ieee802154/ca8210.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index a036910f6082..65f042c8734b 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -627,7 +627,8 @@ static int ca8210_spi_transfer( */ static void ca8210_reset_send(struct spi_device *spi, unsigned int ms) { - struct ca8210_platform_data *pdata = spi->dev.platform_data; + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); struct ca8210_priv *priv = spi_get_drvdata(spi); long status; @@ -2736,9 +2737,10 @@ static int ca8210_config_extern_clk( */ static int ca8210_register_ext_clock(struct spi_device *spi) { + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); struct device_node *np = spi->dev.of_node; struct ca8210_priv *priv = spi_get_drvdata(spi); - struct ca8210_platform_data *pdata = spi->dev.platform_data; if (!np) return -EFAULT; @@ -2784,8 +2786,9 @@ static void ca8210_unregister_ext_clock(struct spi_device *spi) */ static int ca8210_reset_init(struct spi_device *spi) { + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); int ret; - struct ca8210_platform_data *pdata = spi->dev.platform_data; pdata->gpio_reset = of_get_named_gpio( spi->dev.of_node, @@ -2813,8 +2816,9 @@ static int ca8210_reset_init(struct spi_device *spi) */ static int ca8210_interrupt_init(struct spi_device *spi) { + struct device *dev = &spi->dev; + struct ca8210_platform_data *pdata = dev_get_platdata(dev); int ret; - struct ca8210_platform_data *pdata = spi->dev.platform_data; pdata->gpio_irq = of_get_named_gpio( spi->dev.of_node, From patchwork Mon Mar 3 16:49:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13999213 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C58E2253F38; Mon, 3 Mar 2025 16:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020578; cv=none; b=tNBN08suWEMg8msEJKWw1LtC8y6lOCUbx6I9gpbBVkm+u/AjHOnD1R3uQFyuBcv791dzZ4ejOyeAcZw+79J0WRf6TXWDUY4UIs+FdjWiieKW/lvFZ9lLjPhw2W2xNxhlPHRZ0bHdWCVUhfnG/CR1UMGt0aC0WbH8Z0zIrrxnKKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020578; c=relaxed/simple; bh=QxMI96pUH6DNsqjiw2kEM8KCz4+ZICG+5dYAmxd/380=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fb+tl1eehUd4iKx+dxd0Mr/vAEDPhgc44aHoU2jP0/6FWo7oBRHcZPnWDH4cFpG+vZg0yZh17qjyvmLRYa+rjc30myyyFpiWZGytnIGzHS12I+BH8Tp8NF1Ql6h3VTBNZZBc/lOzxQsh91CA/7NhjafG3rSFsY4SqUgRN+qGPL4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=eAGyMiWx; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="eAGyMiWx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741020577; x=1772556577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QxMI96pUH6DNsqjiw2kEM8KCz4+ZICG+5dYAmxd/380=; b=eAGyMiWxRk2fuRd1dnfGlkrvFlvQ/lDPiEq4LAfeya4QrVKH9Zh4sDS5 bUsKpf3vSQkeyq568F1DREl3F8Gj7pb5Nf3aARgX3nkt6Z1PeKWHQRK4P J4pCRUyLFScd9zE9aUgePowiDLv4Cp6FZjkqN6LhOy0H9RIwxOtbChfZb FB6J6iGvzSTZaok0ZKVgWJlCVtDEUDU9n/COz2kG6hlY+V2bJb3Q5EKHk cPJRcDdd6i3BLlgkie5EteXYE3dEtbYEqtCLwxj8Iy/X5DGTXvnJ5p+46 M1yTpqkahQRwycxu9MAoDll3qTUY8vHGSnXTn4C3PWVV+HVgBKyJ4nrZS g==; X-CSE-ConnectionGUID: CpEFYVGGQoG0Xslk7rnq1Q== X-CSE-MsgGUID: Vh/r83EmQhmIOlb9oePvPw== X-IronPort-AV: E=McAfee;i="6700,10204,11362"; a="41761409" X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="41761409" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2025 08:49:34 -0800 X-CSE-ConnectionGUID: kYMzaWX1S2++c4ZMe1Brmw== X-CSE-MsgGUID: /PwV6x5QQmCoUuLOgySURw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="123212198" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 03 Mar 2025 08:49:30 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BC5BE1FF; Mon, 03 Mar 2025 18:49:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , Miquel Raynal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , Bartosz Golaszewski Subject: [PATCH net-next v2 3/3] ieee802154: ca8210: Switch to using gpiod API Date: Mon, 3 Mar 2025 18:49:10 +0200 Message-ID: <20250303164928.1466246-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> References: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This updates the driver to gpiod API, and removes yet another use of of_get_named_gpio(). Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij Reviewed-by: Linus Walleij --- drivers/net/ieee802154/ca8210.c | 57 +++++++++++---------------------- 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 65f042c8734b..d4c1f00d29fe 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -52,12 +52,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -350,8 +348,8 @@ struct work_priv_container { * @extclockenable: true if the external clock is to be enabled * @extclockfreq: frequency of the external clock * @extclockgpio: ca8210 output gpio of the external clock - * @gpio_reset: gpio number of ca8210 reset line - * @gpio_irq: gpio number of ca8210 interrupt line + * @reset_gpio: ca8210 reset GPIO descriptor + * @irq_gpio: ca8210 interrupt GPIO descriptor * @irq_id: identifier for the ca8210 irq * */ @@ -359,8 +357,8 @@ struct ca8210_platform_data { bool extclockenable; unsigned int extclockfreq; unsigned int extclockgpio; - int gpio_reset; - int gpio_irq; + struct gpio_desc *reset_gpio; + struct gpio_desc *irq_gpio; int irq_id; }; @@ -632,10 +630,10 @@ static void ca8210_reset_send(struct spi_device *spi, unsigned int ms) struct ca8210_priv *priv = spi_get_drvdata(spi); long status; - gpio_set_value(pdata->gpio_reset, 0); + gpiod_set_value(pdata->reset_gpio, 0); reinit_completion(&priv->ca8210_is_awake); msleep(ms); - gpio_set_value(pdata->gpio_reset, 1); + gpiod_set_value(pdata->reset_gpio, 1); priv->promiscuous = false; /* Wait until wakeup indication seen */ @@ -2788,24 +2786,14 @@ static int ca8210_reset_init(struct spi_device *spi) { struct device *dev = &spi->dev; struct ca8210_platform_data *pdata = dev_get_platdata(dev); - int ret; - pdata->gpio_reset = of_get_named_gpio( - spi->dev.of_node, - "reset-gpio", - 0 - ); - - ret = gpio_direction_output(pdata->gpio_reset, 1); - if (ret < 0) { - dev_crit( - &spi->dev, - "Reset GPIO %d did not set to output mode\n", - pdata->gpio_reset - ); + pdata->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(pdata->reset_gpio)) { + dev_crit(dev, "Reset GPIO did not set to output mode\n"); + return PTR_ERR(pdata->reset_gpio); } - return ret; + return 0; } /** @@ -2820,20 +2808,15 @@ static int ca8210_interrupt_init(struct spi_device *spi) struct ca8210_platform_data *pdata = dev_get_platdata(dev); int ret; - pdata->gpio_irq = of_get_named_gpio( - spi->dev.of_node, - "irq-gpio", - 0 - ); + pdata->irq_gpio = devm_gpiod_get(dev, "irq", GPIOD_IN); + if (IS_ERR(pdata->irq_gpio)) { + dev_crit(dev, "Could not retrieve IRQ GPIO\n"); + return PTR_ERR(pdata->irq_gpio); + } - pdata->irq_id = gpio_to_irq(pdata->gpio_irq); + pdata->irq_id = gpiod_to_irq(pdata->irq_gpio); if (pdata->irq_id < 0) { - dev_crit( - &spi->dev, - "Could not get irq for gpio pin %d\n", - pdata->gpio_irq - ); - gpio_free(pdata->gpio_irq); + dev_crit(dev, "Could not get irq for IRQ GPIO\n"); return pdata->irq_id; } @@ -2844,10 +2827,8 @@ static int ca8210_interrupt_init(struct spi_device *spi) "ca8210-irq", spi_get_drvdata(spi) ); - if (ret) { + if (ret) dev_crit(&spi->dev, "request_irq %d failed\n", pdata->irq_id); - gpio_free(pdata->gpio_irq); - } return ret; }