From nobody Mon Feb 9 12:01:58 2026 Received: from mail-vk1-f171.google.com (mail-vk1-f171.google.com [209.85.221.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0BBF626A0 for ; Tue, 2 Apr 2024 11:14:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056468; cv=none; b=b2AYkucUwvnlqsLYI3L7ACPHFPBqg/DU3C8qW63ojxsC/0lU6z/lNZ7I4J2tWp3jsjDY9wucSOm4S8nY7RWra+w7HLJxoPlxlag+88g53T1touSnKY1SRn5xCVyRgIoxQ5RUnu4nKGqw/mUI4a4bn2/WapHTuv222ol8WiJqR4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056468; c=relaxed/simple; bh=g/WMOp/DBXdvY4p/J51T2DdQvuOBI7ftgCcNNdq/ZQg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Kh0XZrs+yRv1mgzpyhEmzZgEP9i5b+bJcpvVi+H1qf5yEUlEC/QU/6nOZ1cFQ88fSZwIUMoG0A0gWYGRrF5sNMaWyMIlQ3Prfg2+CNktUgLfPkgirDd4nNjHkD2IVyooBkuCa19lDrpzptCXhna0mnemz96NbP2FBPhqpKyOCK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Iph6/H3+; arc=none smtp.client-ip=209.85.221.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Iph6/H3+" Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-4d47000f875so2080102e0c.2 for ; Tue, 02 Apr 2024 04:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712056465; x=1712661265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AwPl8LYnfW65bMF9In5HJ2vXzRSbzAQqtlyK3TQNiLw=; b=Iph6/H3+8m9q7/eVHUTq8b/7ZXJ/2t+4k1RMSQQ3w4j3GQhSU+VtY1iSJ2BxzBDjCt vmpYOHAqBl48wRVeMNrAKzLX+OwTJ71HfpU9i0cXIOvUamtCJBN8bFOn5KNcjsmzdpZo hqc5Igfkkn8Cn5oNyc+j+6gWe9TPlz3ohM7MMJeHockVHbUPXjrcbV4CkXVecDb/o2y1 56Rg6JX/AiKh6CLHZxcA8ugED8FXGub+h+p2cY0B2ejBRwog1oUbt4WzuZkfmjjqrHh3 LFS8JHJjKDg6fTmW/xyrinaW4tmE3uyJYuXTNY7P/mh6o6JDcjURbjjZH5eFLqCVHcYR 7L5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712056465; x=1712661265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AwPl8LYnfW65bMF9In5HJ2vXzRSbzAQqtlyK3TQNiLw=; b=uxAguD06/jxosug0z7sVEaDhJalodgYlLUTm1ncitkapdPJ/a7MMijMtmpefnfv+pA +w+4aGx05eE44IdhxEn7ZTZOq2nZ11H/8d2Y7IE3pBuyzNMS3vUj16nQnX9ZnteaSnY4 MRD/Wa3FC/0C+Ws+iHw+Q9RCxETe8z9IKd2YLmZ8hqr+WGeOCf+RV56h7/TzzPQISfZY GyF+cb5pS/mvRX8bhdfISJphaQtoiGpw2IPXAFMLv4J9KHi/Fi8oiP5yDhMLU7kWSvn3 hWsoM2hZDIYWiSaAttpJlREZ2NUJpq8Xrr3wPh5cpuJScyRRMG4334yXqJnzBGvRjWcz O3RQ== X-Forwarded-Encrypted: i=1; AJvYcCXMQTV2kMTX3xIuqa85iuwmz+a1IC6Ew74U8zu3r994YIR93Hw8oEJn0+1Ec5+Wu/yOkCoeVoN66LPBuvHIZ7pcowc6SrGZMFWMs3To X-Gm-Message-State: AOJu0YyOS2PhjPPnFLCL6GlXWSnOqD7hDNIJ/piKRfN6xXVel1Gi2KtE lC63NF33bAZCnz9EtcgJTR7BJ2ZxTm3WKBu/i8Pbr0FERWTxpLtw X-Google-Smtp-Source: AGHT+IGQ+gz5kG9dTgq1zUZPBLECe9wqwN5K7d6gbfjwiXOgW0CKfm40k68E2evbnEs3WIhJ/0Q7UQ== X-Received: by 2002:a67:f2d0:0:b0:478:46db:6222 with SMTP id a16-20020a67f2d0000000b0047846db6222mr9938357vsn.24.1712056464764; Tue, 02 Apr 2024 04:14:24 -0700 (PDT) Received: from YOGA.local ([2a06:c701:737b:ef00:2c6f:6cdc:f641:6ecf]) by smtp.gmail.com with ESMTPSA id 11-20020a05621420cb00b006968a6fb010sm5428855qve.91.2024.04.02.04.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:14:24 -0700 (PDT) From: Shahar Avidar To: gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, andriy.shevchenko@linux.intel.com, robh@kernel.org, felixkimbu1@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] staging: pi433: Rename struct pi433_device buffer field to tx_buffer. Date: Tue, 2 Apr 2024 14:14:09 +0300 Message-Id: <20240402111414.871089-2-ikobh7@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402111414.871089-1-ikobh7@gmail.com> References: <20240402111414.871089-1-ikobh7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Driver holds buffers in different structs, as does the HW. Using explicit names for buffers increases readability. Signed-off-by: Shahar Avidar --- drivers/staging/pi433/pi433_if.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 8c513ac62156..13b464ab7db8 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -90,7 +90,7 @@ struct pi433_device { struct task_struct *tx_task_struct; wait_queue_head_t tx_wait_queue; u8 free_in_fifo; - char buffer[MAX_MSG_SIZE]; + char tx_buffer[MAX_MSG_SIZE]; =20 /* rx related values */ struct pi433_rx_cfg rx_cfg; @@ -613,8 +613,8 @@ static int pi433_tx_thread(void *data) if (tx_cfg.enable_address_byte =3D=3D OPTION_ON) size++; =20 - /* prime buffer */ - memset(device->buffer, 0, size); + /* prime tx_buffer */ + memset(device->tx_buffer, 0, size); position =3D 0; =20 /* add length byte, if requested */ @@ -623,15 +623,15 @@ static int pi433_tx_thread(void *data) * according to spec, length byte itself must be * excluded from the length calculation */ - device->buffer[position++] =3D size - 1; + device->tx_buffer[position++] =3D size - 1; =20 /* add adr byte, if requested */ if (tx_cfg.enable_address_byte =3D=3D OPTION_ON) - device->buffer[position++] =3D tx_cfg.address_byte; + device->tx_buffer[position++] =3D tx_cfg.address_byte; =20 /* finally get message data from fifo */ - retval =3D kfifo_out(&device->tx_fifo, &device->buffer[position], - sizeof(device->buffer) - position); + retval =3D kfifo_out(&device->tx_fifo, &device->tx_buffer[position], + sizeof(device->tx_buffer) - position); dev_dbg(device->dev, "read %d message byte(s) from fifo queue.\n", retval); =20 @@ -715,7 +715,7 @@ static int pi433_tx_thread(void *data) =20 device->free_in_fifo =3D 0; rf69_write_fifo(spi, - &device->buffer[position], + &device->tx_buffer[position], write_size); position +=3D write_size; } else { @@ -723,7 +723,7 @@ static int pi433_tx_thread(void *data) device->free_in_fifo -=3D size; repetitions--; rf69_write_fifo(spi, - &device->buffer[position], + &device->tx_buffer[position], (size - position)); position =3D 0; /* reset for next repetition */ } --=20 2.34.1 From nobody Mon Feb 9 12:01:58 2026 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CCCC634EA for ; Tue, 2 Apr 2024 11:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056471; cv=none; b=tYzmkKy//8K3Q1L2bibZG79uZq5KK5TWkofT0zW8tNOPfDtaMkX/yAomr3uEuZUyf06I3H4ITps9Lk9O0C190yEjBHG85RtwakFQRaQ1j/5yBVTsSfKG8PZYWClz6AxiYRzDvVGvkjwE45xRhmunswRvjr32qNTPa3AsSUqPGMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056471; c=relaxed/simple; bh=WfR3fzgOc+lYO6U7TgwGQD81mZqIEEtqO9tFKn6iuM4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d1xeU6BJPmeZK3vhguoAH1o58emg37VYB9tgFtqdvMYWzjLfcsLTp0trJYDVVkTeyRZa3V1e1e6GoTeGe+/fsqH9jPBsY71qJ5rr4wQPsI3lXYM9KnN2yeRD1NpssZlU5bxvx2E4JSH66LOUa9J9dtxvb/pHrlKTRuj+D2OWC28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Roym+Q8J; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Roym+Q8J" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6e89e48d2c0so1004532a34.1 for ; Tue, 02 Apr 2024 04:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712056467; x=1712661267; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9LP7LwhNxKs9alceF3MwlRSStgVkDK9Wscv2B2RIGfw=; b=Roym+Q8JyX0FXVlSYO7BvqAfTTg0alATGPNK5ngqbj0DSGAgUAUd0VL3UGJAtW7J1c mdVfWUQVPmBzZ37lVEuAwL2FHGg57LyJZqC3r3Dt6L8wNEqZiiorP4PSwKdiObxtND2D Hen4M2aqjRlIc1TLYfTc0ZuuUhZJlQsskf/yGWl9P2PWgcw2qXJN025sVro4fV3vJVgE ADPsfSqoLm96E6EpkqUQjxdfe6xnUfjMLnVGBgcTyat/108nu7dG/7MNNSZeerxVSAyv UrLRYR7L6NBysz0feG84dQ+BX1Fgeoi4Ykj0AqG3o+q5TI3ibhGSUu2NcMp6defAT2mn 0rSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712056467; x=1712661267; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9LP7LwhNxKs9alceF3MwlRSStgVkDK9Wscv2B2RIGfw=; b=bte/Fxfuh3mP29O2eXPXOE24Oxcmzk9p2HIypNeETjF4Myh9t+J76Otnd8ap8sZnAn 8l7XGef4mLKJFK7iX8QcZAm8RbOIzdDsVs6dOFvDtaLDHAGHoThuotkfOCxz6N8G8Q+C qxmLfs9a+CbHELePTWhwwaBCKbAmNsGE+8wqBdZSnqqAsZCEKuMfmB+bu9MqkNCkNP19 WKYX93GIBc8nJe7X4QSjP4YP0c1QW6dH1qBaDVh4UyBzcr1wWKTd8hQbXEQJwv7fY6Om ubIM5QN6vYEkrR0MrXBeGwKUTWJRCUDMGY7QAryaj+yIm1cVghVVDbHfU/eKmgNgJgSO tEFA== X-Forwarded-Encrypted: i=1; AJvYcCUIQNTZ02nOj+0WrlymkKxqZlyGRRcgU4OeijGhDN2eEvYsw09TW4gv0SGVMzLVPTjlniwq/AlSVMNN7DTvimpjU6wDn65iO75K6DOe X-Gm-Message-State: AOJu0Yy+8mJaP/FclzNWegkUz/LAAWauxThQMXcs443zQyutoqaLT+27 oodlX/pgaSHh/KqKUp5Wk69CopeGpS6TsaFDYjLKAX53u0FMj8tj X-Google-Smtp-Source: AGHT+IGScEmFAulgT9n2upeHCeGsLZx0mX0dn83We9EGOIfwbrJ7I54KtVqtNbtbXP4T+RlLg7jx0Q== X-Received: by 2002:a05:6830:39ea:b0:6e7:c80a:3b2c with SMTP id bt42-20020a05683039ea00b006e7c80a3b2cmr13291056otb.18.1712056467070; Tue, 02 Apr 2024 04:14:27 -0700 (PDT) Received: from YOGA.local ([2a06:c701:737b:ef00:2c6f:6cdc:f641:6ecf]) by smtp.gmail.com with ESMTPSA id 11-20020a05621420cb00b006968a6fb010sm5428855qve.91.2024.04.02.04.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:14:26 -0700 (PDT) From: Shahar Avidar To: gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, andriy.shevchenko@linux.intel.com, robh@kernel.org, felixkimbu1@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] staging: pi433: Rename struct pi433_device instances to pi433. Date: Tue, 2 Apr 2024 14:14:10 +0300 Message-Id: <20240402111414.871089-3-ikobh7@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402111414.871089-1-ikobh7@gmail.com> References: <20240402111414.871089-1-ikobh7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Just as other devices use specific names for instantiation, struct_pi433 should also have a distinct name. Moreover, some other structs use the "dev" or "device" in their naming conventions for members, which can be confusing. Signed-off-by: Shahar Avidar --- drivers/staging/pi433/pi433_if.c | 654 +++++++++++++++---------------- 1 file changed, 327 insertions(+), 327 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 13b464ab7db8..7efe6b8501e3 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -113,7 +113,7 @@ struct pi433_device { }; =20 struct pi433_instance { - struct pi433_device *device; + struct pi433_device *pi433; struct pi433_tx_cfg tx_cfg; =20 /* control flags */ @@ -125,19 +125,19 @@ struct pi433_instance { /* GPIO interrupt handlers */ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id) { - struct pi433_device *device =3D dev_id; - - if (device->irq_state[DIO0] =3D=3D DIO_PACKET_SENT) { - device->free_in_fifo =3D FIFO_SIZE; - dev_dbg(device->dev, "DIO0 irq: Packet sent\n"); - wake_up_interruptible(&device->fifo_wait_queue); - } else if (device->irq_state[DIO0] =3D=3D DIO_RSSI_DIO0) { - dev_dbg(device->dev, "DIO0 irq: RSSI level over threshold\n"); - wake_up_interruptible(&device->rx_wait_queue); - } else if (device->irq_state[DIO0] =3D=3D DIO_PAYLOAD_READY) { - dev_dbg(device->dev, "DIO0 irq: Payload ready\n"); - device->free_in_fifo =3D 0; - wake_up_interruptible(&device->fifo_wait_queue); + struct pi433_device *pi433 =3D dev_id; + + if (pi433->irq_state[DIO0] =3D=3D DIO_PACKET_SENT) { + pi433->free_in_fifo =3D FIFO_SIZE; + dev_dbg(pi433->dev, "DIO0 irq: Packet sent\n"); + wake_up_interruptible(&pi433->fifo_wait_queue); + } else if (pi433->irq_state[DIO0] =3D=3D DIO_RSSI_DIO0) { + dev_dbg(pi433->dev, "DIO0 irq: RSSI level over threshold\n"); + wake_up_interruptible(&pi433->rx_wait_queue); + } else if (pi433->irq_state[DIO0] =3D=3D DIO_PAYLOAD_READY) { + dev_dbg(pi433->dev, "DIO0 irq: Payload ready\n"); + pi433->free_in_fifo =3D 0; + wake_up_interruptible(&pi433->fifo_wait_queue); } =20 return IRQ_HANDLED; @@ -145,19 +145,19 @@ static irqreturn_t DIO0_irq_handler(int irq, void *de= v_id) =20 static irqreturn_t DIO1_irq_handler(int irq, void *dev_id) { - struct pi433_device *device =3D dev_id; + struct pi433_device *pi433 =3D dev_id; =20 - if (device->irq_state[DIO1] =3D=3D DIO_FIFO_NOT_EMPTY_DIO1) { - device->free_in_fifo =3D FIFO_SIZE; - } else if (device->irq_state[DIO1] =3D=3D DIO_FIFO_LEVEL) { - if (device->rx_active) - device->free_in_fifo =3D FIFO_THRESHOLD - 1; + if (pi433->irq_state[DIO1] =3D=3D DIO_FIFO_NOT_EMPTY_DIO1) { + pi433->free_in_fifo =3D FIFO_SIZE; + } else if (pi433->irq_state[DIO1] =3D=3D DIO_FIFO_LEVEL) { + if (pi433->rx_active) + pi433->free_in_fifo =3D FIFO_THRESHOLD - 1; else - device->free_in_fifo =3D FIFO_SIZE - FIFO_THRESHOLD - 1; + pi433->free_in_fifo =3D FIFO_SIZE - FIFO_THRESHOLD - 1; } - dev_dbg(device->dev, - "DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); - wake_up_interruptible(&device->fifo_wait_queue); + dev_dbg(pi433->dev, + "DIO1 irq: %d bytes free in fifo\n", pi433->free_in_fifo); + wake_up_interruptible(&pi433->fifo_wait_queue); =20 return IRQ_HANDLED; } @@ -165,94 +165,94 @@ static irqreturn_t DIO1_irq_handler(int irq, void *de= v_id) /*------------------------------------------------------------------------= -*/ =20 static int -rf69_set_rx_cfg(struct pi433_device *dev, struct pi433_rx_cfg *rx_cfg) +rf69_set_rx_cfg(struct pi433_device *pi433, struct pi433_rx_cfg *rx_cfg) { int ret; int payload_length; =20 /* receiver config */ - ret =3D rf69_set_frequency(dev->spi, rx_cfg->frequency); + ret =3D rf69_set_frequency(pi433->spi, rx_cfg->frequency); if (ret < 0) return ret; - ret =3D rf69_set_modulation(dev->spi, rx_cfg->modulation); + ret =3D rf69_set_modulation(pi433->spi, rx_cfg->modulation); if (ret < 0) return ret; - ret =3D rf69_set_bit_rate(dev->spi, rx_cfg->bit_rate); + ret =3D rf69_set_bit_rate(pi433->spi, rx_cfg->bit_rate); if (ret < 0) return ret; - ret =3D rf69_set_antenna_impedance(dev->spi, rx_cfg->antenna_impedance); + ret =3D rf69_set_antenna_impedance(pi433->spi, rx_cfg->antenna_impedance); if (ret < 0) return ret; - ret =3D rf69_set_rssi_threshold(dev->spi, rx_cfg->rssi_threshold); + ret =3D rf69_set_rssi_threshold(pi433->spi, rx_cfg->rssi_threshold); if (ret < 0) return ret; - ret =3D rf69_set_ook_threshold_dec(dev->spi, rx_cfg->threshold_decrement); + ret =3D rf69_set_ook_threshold_dec(pi433->spi, rx_cfg->threshold_decremen= t); if (ret < 0) return ret; - ret =3D rf69_set_bandwidth(dev->spi, rx_cfg->bw_mantisse, + ret =3D rf69_set_bandwidth(pi433->spi, rx_cfg->bw_mantisse, rx_cfg->bw_exponent); if (ret < 0) return ret; - ret =3D rf69_set_bandwidth_during_afc(dev->spi, rx_cfg->bw_mantisse, + ret =3D rf69_set_bandwidth_during_afc(pi433->spi, rx_cfg->bw_mantisse, rx_cfg->bw_exponent); if (ret < 0) return ret; - ret =3D rf69_set_dagc(dev->spi, rx_cfg->dagc); + ret =3D rf69_set_dagc(pi433->spi, rx_cfg->dagc); if (ret < 0) return ret; =20 - dev->rx_bytes_to_drop =3D rx_cfg->bytes_to_drop; + pi433->rx_bytes_to_drop =3D rx_cfg->bytes_to_drop; =20 /* packet config */ /* enable */ if (rx_cfg->enable_sync =3D=3D OPTION_ON) { - ret =3D rf69_enable_sync(dev->spi); + ret =3D rf69_enable_sync(pi433->spi); if (ret < 0) return ret; =20 - ret =3D rf69_set_fifo_fill_condition(dev->spi, + ret =3D rf69_set_fifo_fill_condition(pi433->spi, after_sync_interrupt); if (ret < 0) return ret; } else { - ret =3D rf69_disable_sync(dev->spi); + ret =3D rf69_disable_sync(pi433->spi); if (ret < 0) return ret; =20 - ret =3D rf69_set_fifo_fill_condition(dev->spi, always); + ret =3D rf69_set_fifo_fill_condition(pi433->spi, always); if (ret < 0) return ret; } if (rx_cfg->enable_length_byte =3D=3D OPTION_ON) { - ret =3D rf69_set_packet_format(dev->spi, packet_length_var); + ret =3D rf69_set_packet_format(pi433->spi, packet_length_var); if (ret < 0) return ret; } else { - ret =3D rf69_set_packet_format(dev->spi, packet_length_fix); + ret =3D rf69_set_packet_format(pi433->spi, packet_length_fix); if (ret < 0) return ret; } - ret =3D rf69_set_address_filtering(dev->spi, + ret =3D rf69_set_address_filtering(pi433->spi, rx_cfg->enable_address_filtering); if (ret < 0) return ret; =20 if (rx_cfg->enable_crc =3D=3D OPTION_ON) { - ret =3D rf69_enable_crc(dev->spi); + ret =3D rf69_enable_crc(pi433->spi); if (ret < 0) return ret; } else { - ret =3D rf69_disable_crc(dev->spi); + ret =3D rf69_disable_crc(pi433->spi); if (ret < 0) return ret; } =20 /* lengths */ - ret =3D rf69_set_sync_size(dev->spi, rx_cfg->sync_length); + ret =3D rf69_set_sync_size(pi433->spi, rx_cfg->sync_length); if (ret < 0) return ret; if (rx_cfg->enable_length_byte =3D=3D OPTION_ON) { - ret =3D rf69_set_payload_length(dev->spi, 0xff); + ret =3D rf69_set_payload_length(pi433->spi, 0xff); if (ret < 0) return ret; } else if (rx_cfg->fixed_message_length !=3D 0) { @@ -261,26 +261,26 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi43= 3_rx_cfg *rx_cfg) payload_length++; if (rx_cfg->enable_address_filtering !=3D filtering_off) payload_length++; - ret =3D rf69_set_payload_length(dev->spi, payload_length); + ret =3D rf69_set_payload_length(pi433->spi, payload_length); if (ret < 0) return ret; } else { - ret =3D rf69_set_payload_length(dev->spi, 0); + ret =3D rf69_set_payload_length(pi433->spi, 0); if (ret < 0) return ret; } =20 /* values */ if (rx_cfg->enable_sync =3D=3D OPTION_ON) { - ret =3D rf69_set_sync_values(dev->spi, rx_cfg->sync_pattern); + ret =3D rf69_set_sync_values(pi433->spi, rx_cfg->sync_pattern); if (ret < 0) return ret; } if (rx_cfg->enable_address_filtering !=3D filtering_off) { - ret =3D rf69_set_node_address(dev->spi, rx_cfg->node_address); + ret =3D rf69_set_node_address(pi433->spi, rx_cfg->node_address); if (ret < 0) return ret; - ret =3D rf69_set_broadcast_address(dev->spi, + ret =3D rf69_set_broadcast_address(pi433->spi, rx_cfg->broadcast_address); if (ret < 0) return ret; @@ -290,76 +290,76 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct pi43= 3_rx_cfg *rx_cfg) } =20 static int -rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) +rf69_set_tx_cfg(struct pi433_device *pi433, struct pi433_tx_cfg *tx_cfg) { int ret; =20 - ret =3D rf69_set_frequency(dev->spi, tx_cfg->frequency); + ret =3D rf69_set_frequency(pi433->spi, tx_cfg->frequency); if (ret < 0) return ret; - ret =3D rf69_set_modulation(dev->spi, tx_cfg->modulation); + ret =3D rf69_set_modulation(pi433->spi, tx_cfg->modulation); if (ret < 0) return ret; - ret =3D rf69_set_bit_rate(dev->spi, tx_cfg->bit_rate); + ret =3D rf69_set_bit_rate(pi433->spi, tx_cfg->bit_rate); if (ret < 0) return ret; - ret =3D rf69_set_deviation(dev->spi, tx_cfg->dev_frequency); + ret =3D rf69_set_deviation(pi433->spi, tx_cfg->dev_frequency); if (ret < 0) return ret; - ret =3D rf69_set_pa_ramp(dev->spi, tx_cfg->pa_ramp); + ret =3D rf69_set_pa_ramp(pi433->spi, tx_cfg->pa_ramp); if (ret < 0) return ret; - ret =3D rf69_set_modulation_shaping(dev->spi, tx_cfg->mod_shaping); + ret =3D rf69_set_modulation_shaping(pi433->spi, tx_cfg->mod_shaping); if (ret < 0) return ret; - ret =3D rf69_set_tx_start_condition(dev->spi, tx_cfg->tx_start_condition); + ret =3D rf69_set_tx_start_condition(pi433->spi, tx_cfg->tx_start_conditio= n); if (ret < 0) return ret; =20 /* packet format enable */ if (tx_cfg->enable_preamble =3D=3D OPTION_ON) { - ret =3D rf69_set_preamble_length(dev->spi, + ret =3D rf69_set_preamble_length(pi433->spi, tx_cfg->preamble_length); if (ret < 0) return ret; } else { - ret =3D rf69_set_preamble_length(dev->spi, 0); + ret =3D rf69_set_preamble_length(pi433->spi, 0); if (ret < 0) return ret; } =20 if (tx_cfg->enable_sync =3D=3D OPTION_ON) { - ret =3D rf69_set_sync_size(dev->spi, tx_cfg->sync_length); + ret =3D rf69_set_sync_size(pi433->spi, tx_cfg->sync_length); if (ret < 0) return ret; - ret =3D rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern); + ret =3D rf69_set_sync_values(pi433->spi, tx_cfg->sync_pattern); if (ret < 0) return ret; - ret =3D rf69_enable_sync(dev->spi); + ret =3D rf69_enable_sync(pi433->spi); if (ret < 0) return ret; } else { - ret =3D rf69_disable_sync(dev->spi); + ret =3D rf69_disable_sync(pi433->spi); if (ret < 0) return ret; } =20 if (tx_cfg->enable_length_byte =3D=3D OPTION_ON) { - ret =3D rf69_set_packet_format(dev->spi, packet_length_var); + ret =3D rf69_set_packet_format(pi433->spi, packet_length_var); if (ret < 0) return ret; } else { - ret =3D rf69_set_packet_format(dev->spi, packet_length_fix); + ret =3D rf69_set_packet_format(pi433->spi, packet_length_fix); if (ret < 0) return ret; } =20 if (tx_cfg->enable_crc =3D=3D OPTION_ON) { - ret =3D rf69_enable_crc(dev->spi); + ret =3D rf69_enable_crc(pi433->spi); if (ret < 0) return ret; } else { - ret =3D rf69_disable_crc(dev->spi); + ret =3D rf69_disable_crc(pi433->spi); if (ret < 0) return ret; } @@ -369,38 +369,38 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi43= 3_tx_cfg *tx_cfg) =20 /*------------------------------------------------------------------------= -*/ =20 -static int pi433_start_rx(struct pi433_device *dev) +static int pi433_start_rx(struct pi433_device *pi433) { int retval; =20 /* return without action, if no pending read request */ - if (!dev->rx_active) + if (!pi433->rx_active) return 0; =20 /* setup for receiving */ - retval =3D rf69_set_rx_cfg(dev, &dev->rx_cfg); + retval =3D rf69_set_rx_cfg(pi433, &pi433->rx_cfg); if (retval) return retval; =20 /* setup rssi irq */ - retval =3D rf69_set_dio_mapping(dev->spi, DIO0, DIO_RSSI_DIO0); + retval =3D rf69_set_dio_mapping(pi433->spi, DIO0, DIO_RSSI_DIO0); if (retval < 0) return retval; - dev->irq_state[DIO0] =3D DIO_RSSI_DIO0; - irq_set_irq_type(dev->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); + pi433->irq_state[DIO0] =3D DIO_RSSI_DIO0; + irq_set_irq_type(pi433->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); =20 /* setup fifo level interrupt */ - retval =3D rf69_set_fifo_threshold(dev->spi, FIFO_SIZE - FIFO_THRESHOLD); + retval =3D rf69_set_fifo_threshold(pi433->spi, FIFO_SIZE - FIFO_THRESHOLD= ); if (retval < 0) return retval; - retval =3D rf69_set_dio_mapping(dev->spi, DIO1, DIO_FIFO_LEVEL); + retval =3D rf69_set_dio_mapping(pi433->spi, DIO1, DIO_FIFO_LEVEL); if (retval < 0) return retval; - dev->irq_state[DIO1] =3D DIO_FIFO_LEVEL; - irq_set_irq_type(dev->irq_num[DIO1], IRQ_TYPE_EDGE_RISING); + pi433->irq_state[DIO1] =3D DIO_FIFO_LEVEL; + irq_set_irq_type(pi433->irq_num[DIO1], IRQ_TYPE_EDGE_RISING); =20 /* set module to receiving mode */ - retval =3D rf69_set_mode(dev->spi, receive); + retval =3D rf69_set_mode(pi433->spi, receive); if (retval < 0) return retval; =20 @@ -411,50 +411,50 @@ static int pi433_start_rx(struct pi433_device *dev) =20 static int pi433_receive(void *data) { - struct pi433_device *dev =3D data; - struct spi_device *spi =3D dev->spi; + struct pi433_device *pi433 =3D data; + struct spi_device *spi =3D pi433->spi; int bytes_to_read, bytes_total; int retval; =20 - dev->interrupt_rx_allowed =3D false; + pi433->interrupt_rx_allowed =3D false; =20 /* wait for any tx to finish */ - dev_dbg(dev->dev, "rx: going to wait for any tx to finish\n"); - retval =3D wait_event_interruptible(dev->rx_wait_queue, !dev->tx_active); + dev_dbg(pi433->dev, "rx: going to wait for any tx to finish\n"); + retval =3D wait_event_interruptible(pi433->rx_wait_queue, !pi433->tx_acti= ve); if (retval) { /* wait was interrupted */ - dev->interrupt_rx_allowed =3D true; - wake_up_interruptible(&dev->tx_wait_queue); + pi433->interrupt_rx_allowed =3D true; + wake_up_interruptible(&pi433->tx_wait_queue); return retval; } =20 /* prepare status vars */ - dev->free_in_fifo =3D FIFO_SIZE; - dev->rx_position =3D 0; - dev->rx_bytes_dropped =3D 0; + pi433->free_in_fifo =3D FIFO_SIZE; + pi433->rx_position =3D 0; + pi433->rx_bytes_dropped =3D 0; =20 /* setup radio module to listen for something "in the air" */ - retval =3D pi433_start_rx(dev); + retval =3D pi433_start_rx(pi433); if (retval) return retval; =20 /* now check RSSI, if low wait for getting high (RSSI interrupt) */ while (!(rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RSSI)) { /* allow tx to interrupt us while waiting for high RSSI */ - dev->interrupt_rx_allowed =3D true; - wake_up_interruptible(&dev->tx_wait_queue); + pi433->interrupt_rx_allowed =3D true; + wake_up_interruptible(&pi433->tx_wait_queue); =20 /* wait for RSSI level to become high */ - dev_dbg(dev->dev, "rx: going to wait for high RSSI level\n"); - retval =3D wait_event_interruptible(dev->rx_wait_queue, + dev_dbg(pi433->dev, "rx: going to wait for high RSSI level\n"); + retval =3D wait_event_interruptible(pi433->rx_wait_queue, rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RSSI); if (retval) /* wait was interrupted */ goto abort; - dev->interrupt_rx_allowed =3D false; + pi433->interrupt_rx_allowed =3D false; =20 /* cross check for ongoing tx */ - if (!dev->tx_active) + if (!pi433->tx_active) break; } =20 @@ -462,97 +462,97 @@ static int pi433_receive(void *data) retval =3D rf69_set_dio_mapping(spi, DIO0, DIO_PAYLOAD_READY); if (retval < 0) goto abort; - dev->irq_state[DIO0] =3D DIO_PAYLOAD_READY; - irq_set_irq_type(dev->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); + pi433->irq_state[DIO0] =3D DIO_PAYLOAD_READY; + irq_set_irq_type(pi433->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); =20 /* fixed or unlimited length? */ - if (dev->rx_cfg.fixed_message_length !=3D 0) { - if (dev->rx_cfg.fixed_message_length > dev->rx_buffer_size) { + if (pi433->rx_cfg.fixed_message_length !=3D 0) { + if (pi433->rx_cfg.fixed_message_length > pi433->rx_buffer_size) { retval =3D -1; goto abort; } - bytes_total =3D dev->rx_cfg.fixed_message_length; - dev_dbg(dev->dev, "rx: msg len set to %d by fixed length\n", + bytes_total =3D pi433->rx_cfg.fixed_message_length; + dev_dbg(pi433->dev, "rx: msg len set to %d by fixed length\n", bytes_total); } else { - bytes_total =3D dev->rx_buffer_size; - dev_dbg(dev->dev, "rx: msg len set to %d as requested by read\n", + bytes_total =3D pi433->rx_buffer_size; + dev_dbg(pi433->dev, "rx: msg len set to %d as requested by read\n", bytes_total); } =20 /* length byte enabled? */ - if (dev->rx_cfg.enable_length_byte =3D=3D OPTION_ON) { - retval =3D wait_event_interruptible(dev->fifo_wait_queue, - dev->free_in_fifo < FIFO_SIZE); + if (pi433->rx_cfg.enable_length_byte =3D=3D OPTION_ON) { + retval =3D wait_event_interruptible(pi433->fifo_wait_queue, + pi433->free_in_fifo < FIFO_SIZE); if (retval) /* wait was interrupted */ goto abort; =20 rf69_read_fifo(spi, (u8 *)&bytes_total, 1); - if (bytes_total > dev->rx_buffer_size) { + if (bytes_total > pi433->rx_buffer_size) { retval =3D -1; goto abort; } - dev->free_in_fifo++; - dev_dbg(dev->dev, "rx: msg len reset to %d due to length byte\n", + pi433->free_in_fifo++; + dev_dbg(pi433->dev, "rx: msg len reset to %d due to length byte\n", bytes_total); } =20 /* address byte enabled? */ - if (dev->rx_cfg.enable_address_filtering !=3D filtering_off) { + if (pi433->rx_cfg.enable_address_filtering !=3D filtering_off) { u8 dummy; =20 bytes_total--; =20 - retval =3D wait_event_interruptible(dev->fifo_wait_queue, - dev->free_in_fifo < FIFO_SIZE); + retval =3D wait_event_interruptible(pi433->fifo_wait_queue, + pi433->free_in_fifo < FIFO_SIZE); if (retval) /* wait was interrupted */ goto abort; =20 rf69_read_fifo(spi, &dummy, 1); - dev->free_in_fifo++; - dev_dbg(dev->dev, "rx: address byte stripped off\n"); + pi433->free_in_fifo++; + dev_dbg(pi433->dev, "rx: address byte stripped off\n"); } =20 /* get payload */ - while (dev->rx_position < bytes_total) { + while (pi433->rx_position < bytes_total) { if (!(rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY))= { - retval =3D wait_event_interruptible(dev->fifo_wait_queue, - dev->free_in_fifo < FIFO_SIZE); + retval =3D wait_event_interruptible(pi433->fifo_wait_queue, + pi433->free_in_fifo < FIFO_SIZE); if (retval) /* wait was interrupted */ goto abort; } =20 /* need to drop bytes or acquire? */ - if (dev->rx_bytes_to_drop > dev->rx_bytes_dropped) - bytes_to_read =3D dev->rx_bytes_to_drop - - dev->rx_bytes_dropped; + if (pi433->rx_bytes_to_drop > pi433->rx_bytes_dropped) + bytes_to_read =3D pi433->rx_bytes_to_drop - + pi433->rx_bytes_dropped; else - bytes_to_read =3D bytes_total - dev->rx_position; + bytes_to_read =3D bytes_total - pi433->rx_position; =20 /* access the fifo */ - if (bytes_to_read > FIFO_SIZE - dev->free_in_fifo) - bytes_to_read =3D FIFO_SIZE - dev->free_in_fifo; + if (bytes_to_read > FIFO_SIZE - pi433->free_in_fifo) + bytes_to_read =3D FIFO_SIZE - pi433->free_in_fifo; retval =3D rf69_read_fifo(spi, - &dev->rx_buffer[dev->rx_position], + &pi433->rx_buffer[pi433->rx_position], bytes_to_read); if (retval) /* read failed */ goto abort; =20 - dev->free_in_fifo +=3D bytes_to_read; + pi433->free_in_fifo +=3D bytes_to_read; =20 /* adjust status vars */ - if (dev->rx_bytes_to_drop > dev->rx_bytes_dropped) - dev->rx_bytes_dropped +=3D bytes_to_read; + if (pi433->rx_bytes_to_drop > pi433->rx_bytes_dropped) + pi433->rx_bytes_dropped +=3D bytes_to_read; else - dev->rx_position +=3D bytes_to_read; + pi433->rx_position +=3D bytes_to_read; } =20 /* rx done, wait was interrupted or error occurred */ abort: - dev->interrupt_rx_allowed =3D true; - if (rf69_set_mode(dev->spi, standby)) + pi433->interrupt_rx_allowed =3D true; + if (rf69_set_mode(pi433->spi, standby)) pr_err("rf69_set_mode(): radio module failed to go standby\n"); - wake_up_interruptible(&dev->tx_wait_queue); + wake_up_interruptible(&pi433->tx_wait_queue); =20 if (retval) return retval; @@ -562,8 +562,8 @@ static int pi433_receive(void *data) =20 static int pi433_tx_thread(void *data) { - struct pi433_device *device =3D data; - struct spi_device *spi =3D device->spi; + struct pi433_device *pi433 =3D data; + struct spi_device *spi =3D pi433->spi; struct pi433_tx_cfg tx_cfg; size_t size; bool rx_interrupted =3D false; @@ -572,9 +572,9 @@ static int pi433_tx_thread(void *data) =20 while (1) { /* wait for fifo to be populated or for request to terminate*/ - dev_dbg(device->dev, "thread: going to wait for new messages\n"); - wait_event_interruptible(device->tx_wait_queue, - (!kfifo_is_empty(&device->tx_fifo) || + dev_dbg(pi433->dev, "thread: going to wait for new messages\n"); + wait_event_interruptible(pi433->tx_wait_queue, + (!kfifo_is_empty(&pi433->tx_fifo) || kthread_should_stop())); if (kthread_should_stop()) return 0; @@ -585,17 +585,17 @@ static int pi433_tx_thread(void *data) * - size of message * - message */ - retval =3D kfifo_out(&device->tx_fifo, &tx_cfg, sizeof(tx_cfg)); + retval =3D kfifo_out(&pi433->tx_fifo, &tx_cfg, sizeof(tx_cfg)); if (retval !=3D sizeof(tx_cfg)) { - dev_dbg(device->dev, + dev_dbg(pi433->dev, "reading tx_cfg from fifo failed: got %d byte(s), expected %d\n", retval, (unsigned int)sizeof(tx_cfg)); continue; } =20 - retval =3D kfifo_out(&device->tx_fifo, &size, sizeof(size_t)); + retval =3D kfifo_out(&pi433->tx_fifo, &size, sizeof(size_t)); if (retval !=3D sizeof(size_t)) { - dev_dbg(device->dev, + dev_dbg(pi433->dev, "reading msg size from fifo failed: got %d, expected %d\n", retval, (unsigned int)sizeof(size_t)); continue; @@ -614,7 +614,7 @@ static int pi433_tx_thread(void *data) size++; =20 /* prime tx_buffer */ - memset(device->tx_buffer, 0, size); + memset(pi433->tx_buffer, 0, size); position =3D 0; =20 /* add length byte, if requested */ @@ -623,16 +623,16 @@ static int pi433_tx_thread(void *data) * according to spec, length byte itself must be * excluded from the length calculation */ - device->tx_buffer[position++] =3D size - 1; + pi433->tx_buffer[position++] =3D size - 1; =20 /* add adr byte, if requested */ if (tx_cfg.enable_address_byte =3D=3D OPTION_ON) - device->tx_buffer[position++] =3D tx_cfg.address_byte; + pi433->tx_buffer[position++] =3D tx_cfg.address_byte; =20 /* finally get message data from fifo */ - retval =3D kfifo_out(&device->tx_fifo, &device->tx_buffer[position], - sizeof(device->tx_buffer) - position); - dev_dbg(device->dev, + retval =3D kfifo_out(&pi433->tx_fifo, &pi433->tx_buffer[position], + sizeof(pi433->tx_buffer) - position); + dev_dbg(pi433->dev, "read %d message byte(s) from fifo queue.\n", retval); =20 /* @@ -642,23 +642,23 @@ static int pi433_tx_thread(void *data) * place otherwise we need to wait for the incoming telegram * to finish */ - wait_event_interruptible(device->tx_wait_queue, - !device->rx_active || - device->interrupt_rx_allowed); + wait_event_interruptible(pi433->tx_wait_queue, + !pi433->rx_active || + pi433->interrupt_rx_allowed); =20 /* * prevent race conditions * irq will be re-enabled after tx config is set */ - disable_irq(device->irq_num[DIO0]); - device->tx_active =3D true; + disable_irq(pi433->irq_num[DIO0]); + pi433->tx_active =3D true; =20 /* clear fifo, set fifo threshold, set payload length */ retval =3D rf69_set_mode(spi, standby); /* this clears the fifo */ if (retval < 0) goto abort; =20 - if (device->rx_active && !rx_interrupted) { + if (pi433->rx_active && !rx_interrupted) { /* * rx is currently waiting for a telegram; * we need to set the radio module to standby @@ -680,7 +680,7 @@ static int pi433_tx_thread(void *data) } =20 /* configure the rf chip */ - retval =3D rf69_set_tx_cfg(device, &tx_cfg); + retval =3D rf69_set_tx_cfg(pi433, &tx_cfg); if (retval < 0) goto abort; =20 @@ -688,16 +688,16 @@ static int pi433_tx_thread(void *data) retval =3D rf69_set_dio_mapping(spi, DIO1, DIO_FIFO_LEVEL); if (retval < 0) goto abort; - device->irq_state[DIO1] =3D DIO_FIFO_LEVEL; - irq_set_irq_type(device->irq_num[DIO1], IRQ_TYPE_EDGE_FALLING); + pi433->irq_state[DIO1] =3D DIO_FIFO_LEVEL; + irq_set_irq_type(pi433->irq_num[DIO1], IRQ_TYPE_EDGE_FALLING); =20 /* enable packet sent interrupt */ retval =3D rf69_set_dio_mapping(spi, DIO0, DIO_PACKET_SENT); if (retval < 0) goto abort; - device->irq_state[DIO0] =3D DIO_PACKET_SENT; - irq_set_irq_type(device->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); - enable_irq(device->irq_num[DIO0]); /* was disabled by rx active check */ + pi433->irq_state[DIO0] =3D DIO_PACKET_SENT; + irq_set_irq_type(pi433->irq_num[DIO0], IRQ_TYPE_EDGE_RISING); + enable_irq(pi433->irq_num[DIO0]); /* was disabled by rx active check */ =20 /* enable transmission */ retval =3D rf69_set_mode(spi, transmit); @@ -705,61 +705,61 @@ static int pi433_tx_thread(void *data) goto abort; =20 /* transfer this msg (and repetitions) to chip fifo */ - device->free_in_fifo =3D FIFO_SIZE; + pi433->free_in_fifo =3D FIFO_SIZE; position =3D 0; repetitions =3D tx_cfg.repetitions; while ((repetitions > 0) && (size > position)) { - if ((size - position) > device->free_in_fifo) { + if ((size - position) > pi433->free_in_fifo) { /* msg to big for fifo - take a part */ - int write_size =3D device->free_in_fifo; + int write_size =3D pi433->free_in_fifo; =20 - device->free_in_fifo =3D 0; + pi433->free_in_fifo =3D 0; rf69_write_fifo(spi, - &device->tx_buffer[position], + &pi433->tx_buffer[position], write_size); position +=3D write_size; } else { /* msg fits into fifo - take all */ - device->free_in_fifo -=3D size; + pi433->free_in_fifo -=3D size; repetitions--; rf69_write_fifo(spi, - &device->tx_buffer[position], + &pi433->tx_buffer[position], (size - position)); position =3D 0; /* reset for next repetition */ } =20 - retval =3D wait_event_interruptible(device->fifo_wait_queue, - device->free_in_fifo > 0); + retval =3D wait_event_interruptible(pi433->fifo_wait_queue, + pi433->free_in_fifo > 0); if (retval) { - dev_dbg(device->dev, "ABORT\n"); + dev_dbg(pi433->dev, "ABORT\n"); goto abort; } } =20 /* we are done. Wait for packet to get sent */ - dev_dbg(device->dev, + dev_dbg(pi433->dev, "thread: wait for packet to get sent/fifo to be empty\n"); - wait_event_interruptible(device->fifo_wait_queue, - device->free_in_fifo =3D=3D FIFO_SIZE || + wait_event_interruptible(pi433->fifo_wait_queue, + pi433->free_in_fifo =3D=3D FIFO_SIZE || kthread_should_stop()); if (kthread_should_stop()) return 0; =20 /* STOP_TRANSMISSION */ - dev_dbg(device->dev, "thread: Packet sent. Set mode to stby.\n"); + dev_dbg(pi433->dev, "thread: Packet sent. Set mode to stby.\n"); retval =3D rf69_set_mode(spi, standby); if (retval < 0) goto abort; =20 /* everything sent? */ - if (kfifo_is_empty(&device->tx_fifo)) { + if (kfifo_is_empty(&pi433->tx_fifo)) { abort: if (rx_interrupted) { rx_interrupted =3D false; - pi433_start_rx(device); + pi433_start_rx(pi433); } - device->tx_active =3D false; - wake_up_interruptible(&device->rx_wait_queue); + pi433->tx_active =3D false; + wake_up_interruptible(&pi433->rx_wait_queue); } } } @@ -770,7 +770,7 @@ static ssize_t pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) { struct pi433_instance *instance; - struct pi433_device *device; + struct pi433_device *pi433; int bytes_received; ssize_t retval; =20 @@ -779,31 +779,31 @@ pi433_read(struct file *filp, char __user *buf, size_= t size, loff_t *f_pos) return -EMSGSIZE; =20 instance =3D filp->private_data; - device =3D instance->device; + pi433 =3D instance->pi433; =20 /* just one read request at a time */ - mutex_lock(&device->rx_lock); - if (device->rx_active) { - mutex_unlock(&device->rx_lock); + mutex_lock(&pi433->rx_lock); + if (pi433->rx_active) { + mutex_unlock(&pi433->rx_lock); return -EAGAIN; } =20 - device->rx_active =3D true; - mutex_unlock(&device->rx_lock); + pi433->rx_active =3D true; + mutex_unlock(&pi433->rx_lock); =20 /* start receiving */ /* will block until something was received*/ - device->rx_buffer_size =3D size; - bytes_received =3D pi433_receive(device); + pi433->rx_buffer_size =3D size; + bytes_received =3D pi433_receive(pi433); =20 /* release rx */ - mutex_lock(&device->rx_lock); - device->rx_active =3D false; - mutex_unlock(&device->rx_lock); + mutex_lock(&pi433->rx_lock); + pi433->rx_active =3D false; + mutex_unlock(&pi433->rx_lock); =20 /* if read was successful copy to user space*/ if (bytes_received > 0) { - retval =3D copy_to_user(buf, device->rx_buffer, bytes_received); + retval =3D copy_to_user(buf, pi433->rx_buffer, bytes_received); if (retval) return -EFAULT; } @@ -816,12 +816,12 @@ pi433_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { struct pi433_instance *instance; - struct pi433_device *device; + struct pi433_device *pi433; int retval; unsigned int required, available, copied; =20 instance =3D filp->private_data; - device =3D instance->device; + pi433 =3D instance->pi433; =20 /* * check, whether internal buffer (tx thread) is big enough @@ -835,7 +835,7 @@ pi433_write(struct file *filp, const char __user *buf, * config the RF trasmitter correctly due to invalid settings */ if (!instance->tx_cfg_initialized) { - dev_notice_once(device->dev, + dev_notice_once(pi433->dev, "write: failed due to unconfigured tx_cfg (see PI433_IOC_WR_TX_CFG)\n"= ); return -EINVAL; } @@ -846,49 +846,49 @@ pi433_write(struct file *filp, const char __user *buf, * - size of message * - message */ - mutex_lock(&device->tx_fifo_lock); + mutex_lock(&pi433->tx_fifo_lock); =20 required =3D sizeof(instance->tx_cfg) + sizeof(size_t) + count; - available =3D kfifo_avail(&device->tx_fifo); + available =3D kfifo_avail(&pi433->tx_fifo); if (required > available) { - dev_dbg(device->dev, "write to fifo failed: %d bytes required but %d ava= ilable\n", + dev_dbg(pi433->dev, "write to fifo failed: %d bytes required but %d avai= lable\n", required, available); - mutex_unlock(&device->tx_fifo_lock); + mutex_unlock(&pi433->tx_fifo_lock); return -EAGAIN; } =20 - retval =3D kfifo_in(&device->tx_fifo, &instance->tx_cfg, + retval =3D kfifo_in(&pi433->tx_fifo, &instance->tx_cfg, sizeof(instance->tx_cfg)); if (retval !=3D sizeof(instance->tx_cfg)) goto abort; =20 - retval =3D kfifo_in(&device->tx_fifo, &count, sizeof(size_t)); + retval =3D kfifo_in(&pi433->tx_fifo, &count, sizeof(size_t)); if (retval !=3D sizeof(size_t)) goto abort; =20 - retval =3D kfifo_from_user(&device->tx_fifo, buf, count, &copied); + retval =3D kfifo_from_user(&pi433->tx_fifo, buf, count, &copied); if (retval || copied !=3D count) goto abort; =20 - mutex_unlock(&device->tx_fifo_lock); + mutex_unlock(&pi433->tx_fifo_lock); =20 /* start transfer */ - wake_up_interruptible(&device->tx_wait_queue); - dev_dbg(device->dev, "write: generated new msg with %d bytes.\n", copied); + wake_up_interruptible(&pi433->tx_wait_queue); + dev_dbg(pi433->dev, "write: generated new msg with %d bytes.\n", copied); =20 return copied; =20 abort: - dev_warn(device->dev, + dev_warn(pi433->dev, "write to fifo failed, non recoverable: 0x%x\n", retval); - mutex_unlock(&device->tx_fifo_lock); + mutex_unlock(&pi433->tx_fifo_lock); return -EAGAIN; } =20 static long pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long= arg) { struct pi433_instance *instance; - struct pi433_device *device; + struct pi433_device *pi433; struct pi433_tx_cfg tx_cfg; void __user *argp =3D (void __user *)arg; =20 @@ -897,9 +897,9 @@ static long pi433_ioctl(struct file *filp, unsigned int= cmd, unsigned long arg) return -ENOTTY; =20 instance =3D filp->private_data; - device =3D instance->device; + pi433 =3D instance->pi433; =20 - if (!device) + if (!pi433) return -ESHUTDOWN; =20 switch (cmd) { @@ -911,32 +911,32 @@ static long pi433_ioctl(struct file *filp, unsigned i= nt cmd, unsigned long arg) case PI433_IOC_WR_TX_CFG: if (copy_from_user(&tx_cfg, argp, sizeof(struct pi433_tx_cfg))) return -EFAULT; - mutex_lock(&device->tx_fifo_lock); + mutex_lock(&pi433->tx_fifo_lock); memcpy(&instance->tx_cfg, &tx_cfg, sizeof(struct pi433_tx_cfg)); instance->tx_cfg_initialized =3D true; - mutex_unlock(&device->tx_fifo_lock); + mutex_unlock(&pi433->tx_fifo_lock); break; case PI433_IOC_RD_RX_CFG: - if (copy_to_user(argp, &device->rx_cfg, + if (copy_to_user(argp, &pi433->rx_cfg, sizeof(struct pi433_rx_cfg))) return -EFAULT; break; case PI433_IOC_WR_RX_CFG: - mutex_lock(&device->rx_lock); + mutex_lock(&pi433->rx_lock); =20 /* during pending read request, change of config not allowed */ - if (device->rx_active) { - mutex_unlock(&device->rx_lock); + if (pi433->rx_active) { + mutex_unlock(&pi433->rx_lock); return -EAGAIN; } =20 - if (copy_from_user(&device->rx_cfg, argp, + if (copy_from_user(&pi433->rx_cfg, argp, sizeof(struct pi433_rx_cfg))) { - mutex_unlock(&device->rx_lock); + mutex_unlock(&pi433->rx_lock); return -EFAULT; } =20 - mutex_unlock(&device->rx_lock); + mutex_unlock(&pi433->rx_lock); break; default: return -EINVAL; @@ -949,13 +949,13 @@ static long pi433_ioctl(struct file *filp, unsigned i= nt cmd, unsigned long arg) =20 static int pi433_open(struct inode *inode, struct file *filp) { - struct pi433_device *device; + struct pi433_device *pi433; struct pi433_instance *instance; =20 mutex_lock(&minor_lock); - device =3D idr_find(&pi433_idr, iminor(inode)); + pi433 =3D idr_find(&pi433_idr, iminor(inode)); mutex_unlock(&minor_lock); - if (!device) { + if (!pi433) { pr_debug("device: minor %d unknown.\n", iminor(inode)); return -ENODEV; } @@ -965,7 +965,7 @@ static int pi433_open(struct inode *inode, struct file = *filp) return -ENOMEM; =20 /* setup instance data*/ - instance->device =3D device; + instance->pi433 =3D pi433; =20 /* instance data as context */ filp->private_data =3D instance; @@ -987,7 +987,7 @@ static int pi433_release(struct inode *inode, struct fi= le *filp) =20 /*------------------------------------------------------------------------= -*/ =20 -static int setup_gpio(struct pi433_device *device) +static int setup_gpio(struct pi433_device *pi433) { char name[5]; int retval; @@ -1000,89 +1000,89 @@ static int setup_gpio(struct pi433_device *device) for (i =3D 0; i < NUM_DIO; i++) { /* "construct" name and get the gpio descriptor */ snprintf(name, sizeof(name), "DIO%d", i); - device->gpiod[i] =3D gpiod_get(&device->spi->dev, name, - 0 /*GPIOD_IN*/); + pi433->gpiod[i] =3D gpiod_get(&pi433->spi->dev, name, + 0 /*GPIOD_IN*/); =20 - if (device->gpiod[i] =3D=3D ERR_PTR(-ENOENT)) { - dev_dbg(&device->spi->dev, + if (pi433->gpiod[i] =3D=3D ERR_PTR(-ENOENT)) { + dev_dbg(&pi433->spi->dev, "Could not find entry for %s. Ignoring.\n", name); continue; } =20 - if (device->gpiod[i] =3D=3D ERR_PTR(-EBUSY)) - dev_dbg(&device->spi->dev, "%s is busy.\n", name); + if (pi433->gpiod[i] =3D=3D ERR_PTR(-EBUSY)) + dev_dbg(&pi433->spi->dev, "%s is busy.\n", name); =20 - if (IS_ERR(device->gpiod[i])) { - retval =3D PTR_ERR(device->gpiod[i]); + if (IS_ERR(pi433->gpiod[i])) { + retval =3D PTR_ERR(pi433->gpiod[i]); /* release already allocated gpios */ for (i--; i >=3D 0; i--) { - free_irq(device->irq_num[i], device); - gpiod_put(device->gpiod[i]); + free_irq(pi433->irq_num[i], pi433); + gpiod_put(pi433->gpiod[i]); } return retval; } =20 /* configure the pin */ - retval =3D gpiod_direction_input(device->gpiod[i]); + retval =3D gpiod_direction_input(pi433->gpiod[i]); if (retval) return retval; =20 /* configure irq */ - device->irq_num[i] =3D gpiod_to_irq(device->gpiod[i]); - if (device->irq_num[i] < 0) { - device->gpiod[i] =3D ERR_PTR(-EINVAL); - return device->irq_num[i]; + pi433->irq_num[i] =3D gpiod_to_irq(pi433->gpiod[i]); + if (pi433->irq_num[i] < 0) { + pi433->gpiod[i] =3D ERR_PTR(-EINVAL); + return pi433->irq_num[i]; } - retval =3D request_irq(device->irq_num[i], + retval =3D request_irq(pi433->irq_num[i], DIO_irq_handler[i], 0, /* flags */ name, - device); + pi433); =20 if (retval) return retval; =20 - dev_dbg(&device->spi->dev, "%s successfully configured\n", name); + dev_dbg(&pi433->spi->dev, "%s successfully configured\n", name); } =20 return 0; } =20 -static void free_gpio(struct pi433_device *device) +static void free_gpio(struct pi433_device *pi433) { int i; =20 for (i =3D 0; i < NUM_DIO; i++) { /* check if gpiod is valid */ - if (IS_ERR(device->gpiod[i])) + if (IS_ERR(pi433->gpiod[i])) continue; =20 - free_irq(device->irq_num[i], device); - gpiod_put(device->gpiod[i]); + free_irq(pi433->irq_num[i], pi433); + gpiod_put(pi433->gpiod[i]); } } =20 -static int pi433_get_minor(struct pi433_device *device) +static int pi433_get_minor(struct pi433_device *pi433) { int retval =3D -ENOMEM; =20 mutex_lock(&minor_lock); - retval =3D idr_alloc(&pi433_idr, device, 0, N_PI433_MINORS, GFP_KERNEL); + retval =3D idr_alloc(&pi433_idr, pi433, 0, N_PI433_MINORS, GFP_KERNEL); if (retval >=3D 0) { - device->minor =3D retval; + pi433->minor =3D retval; retval =3D 0; } else if (retval =3D=3D -ENOSPC) { - dev_err(&device->spi->dev, "too many pi433 devices\n"); + dev_err(&pi433->spi->dev, "too many pi433 devices\n"); retval =3D -EINVAL; } mutex_unlock(&minor_lock); return retval; } =20 -static void pi433_free_minor(struct pi433_device *dev) +static void pi433_free_minor(struct pi433_device *pi433) { mutex_lock(&minor_lock); - idr_remove(&pi433_idr, dev->minor); + idr_remove(&pi433_idr, pi433->minor); mutex_unlock(&minor_lock); } =20 @@ -1106,35 +1106,35 @@ static const struct file_operations pi433_fops =3D { =20 static int pi433_debugfs_regs_show(struct seq_file *m, void *p) { - struct pi433_device *dev; + struct pi433_device *pi433; u8 reg_data[114]; int i; char *fmt =3D "0x%02x, 0x%02x\n"; int ret; =20 - dev =3D m->private; + pi433 =3D m->private; =20 - mutex_lock(&dev->tx_fifo_lock); - mutex_lock(&dev->rx_lock); + mutex_lock(&pi433->tx_fifo_lock); + mutex_lock(&pi433->rx_lock); =20 // wait for on-going operations to finish - ret =3D wait_event_interruptible(dev->rx_wait_queue, !dev->tx_active); + ret =3D wait_event_interruptible(pi433->rx_wait_queue, !pi433->tx_active); if (ret) goto out_unlock; =20 - ret =3D wait_event_interruptible(dev->tx_wait_queue, !dev->rx_active); + ret =3D wait_event_interruptible(pi433->tx_wait_queue, !pi433->rx_active); if (ret) goto out_unlock; =20 // skip FIFO register (0x0) otherwise this can affect some of uC ops for (i =3D 1; i < 0x50; i++) - reg_data[i] =3D rf69_read_reg(dev->spi, i); + reg_data[i] =3D rf69_read_reg(pi433->spi, i); =20 - reg_data[REG_TESTLNA] =3D rf69_read_reg(dev->spi, REG_TESTLNA); - reg_data[REG_TESTPA1] =3D rf69_read_reg(dev->spi, REG_TESTPA1); - reg_data[REG_TESTPA2] =3D rf69_read_reg(dev->spi, REG_TESTPA2); - reg_data[REG_TESTDAGC] =3D rf69_read_reg(dev->spi, REG_TESTDAGC); - reg_data[REG_TESTAFC] =3D rf69_read_reg(dev->spi, REG_TESTAFC); + reg_data[REG_TESTLNA] =3D rf69_read_reg(pi433->spi, REG_TESTLNA); + reg_data[REG_TESTPA1] =3D rf69_read_reg(pi433->spi, REG_TESTPA1); + reg_data[REG_TESTPA2] =3D rf69_read_reg(pi433->spi, REG_TESTPA2); + reg_data[REG_TESTDAGC] =3D rf69_read_reg(pi433->spi, REG_TESTDAGC); + reg_data[REG_TESTAFC] =3D rf69_read_reg(pi433->spi, REG_TESTAFC); =20 seq_puts(m, "# reg, val\n"); =20 @@ -1148,8 +1148,8 @@ static int pi433_debugfs_regs_show(struct seq_file *m= , void *p) seq_printf(m, fmt, REG_TESTAFC, reg_data[REG_TESTAFC]); =20 out_unlock: - mutex_unlock(&dev->rx_lock); - mutex_unlock(&dev->tx_fifo_lock); + mutex_unlock(&pi433->rx_lock); + mutex_unlock(&pi433->tx_fifo_lock); =20 return ret; } @@ -1159,7 +1159,7 @@ DEFINE_SHOW_ATTRIBUTE(pi433_debugfs_regs); =20 static int pi433_probe(struct spi_device *spi) { - struct pi433_device *device; + struct pi433_device *pi433; int retval; struct dentry *entry; =20 @@ -1196,37 +1196,37 @@ static int pi433_probe(struct spi_device *spi) } =20 /* Allocate driver data */ - device =3D kzalloc(sizeof(*device), GFP_KERNEL); - if (!device) + pi433 =3D kzalloc(sizeof(*pi433), GFP_KERNEL); + if (!pi433) return -ENOMEM; =20 /* Initialize the driver data */ - device->spi =3D spi; - device->rx_active =3D false; - device->tx_active =3D false; - device->interrupt_rx_allowed =3D false; + pi433->spi =3D spi; + pi433->rx_active =3D false; + pi433->tx_active =3D false; + pi433->interrupt_rx_allowed =3D false; =20 /* init rx buffer */ - device->rx_buffer =3D kmalloc(MAX_MSG_SIZE, GFP_KERNEL); - if (!device->rx_buffer) { + pi433->rx_buffer =3D kmalloc(MAX_MSG_SIZE, GFP_KERNEL); + if (!pi433->rx_buffer) { retval =3D -ENOMEM; goto RX_failed; } =20 /* init wait queues */ - init_waitqueue_head(&device->tx_wait_queue); - init_waitqueue_head(&device->rx_wait_queue); - init_waitqueue_head(&device->fifo_wait_queue); + init_waitqueue_head(&pi433->tx_wait_queue); + init_waitqueue_head(&pi433->rx_wait_queue); + init_waitqueue_head(&pi433->fifo_wait_queue); =20 /* init fifo */ - INIT_KFIFO(device->tx_fifo); + INIT_KFIFO(pi433->tx_fifo); =20 /* init mutexes and locks */ - mutex_init(&device->tx_fifo_lock); - mutex_init(&device->rx_lock); + mutex_init(&pi433->tx_fifo_lock); + mutex_init(&pi433->rx_lock); =20 /* setup GPIO (including irq_handler) for the different DIOs */ - retval =3D setup_gpio(device); + retval =3D setup_gpio(pi433); if (retval) { dev_dbg(&spi->dev, "setup of GPIOs failed\n"); goto GPIO_failed; @@ -1256,105 +1256,105 @@ static int pi433_probe(struct spi_device *spi) goto minor_failed; =20 /* determ minor number */ - retval =3D pi433_get_minor(device); + retval =3D pi433_get_minor(pi433); if (retval) { dev_dbg(&spi->dev, "get of minor number failed\n"); goto minor_failed; } =20 /* create device */ - device->devt =3D MKDEV(MAJOR(pi433_dev), device->minor); - device->dev =3D device_create(&pi433_class, - &spi->dev, - device->devt, - device, - "pi433.%d", - device->minor); - if (IS_ERR(device->dev)) { + pi433->devt =3D MKDEV(MAJOR(pi433_dev), pi433->minor); + pi433->dev =3D device_create(&pi433_class, + &spi->dev, + pi433->devt, + pi433, + "pi433.%d", + pi433->minor); + if (IS_ERR(pi433->dev)) { pr_err("pi433: device register failed\n"); - retval =3D PTR_ERR(device->dev); + retval =3D PTR_ERR(pi433->dev); goto device_create_failed; } else { - dev_dbg(device->dev, + dev_dbg(pi433->dev, "created device for major %d, minor %d\n", MAJOR(pi433_dev), - device->minor); + pi433->minor); } =20 /* start tx thread */ - device->tx_task_struct =3D kthread_run(pi433_tx_thread, - device, - "pi433.%d_tx_task", - device->minor); - if (IS_ERR(device->tx_task_struct)) { - dev_dbg(device->dev, "start of send thread failed\n"); - retval =3D PTR_ERR(device->tx_task_struct); + pi433->tx_task_struct =3D kthread_run(pi433_tx_thread, + pi433, + "pi433.%d_tx_task", + pi433->minor); + if (IS_ERR(pi433->tx_task_struct)) { + dev_dbg(pi433->dev, "start of send thread failed\n"); + retval =3D PTR_ERR(pi433->tx_task_struct); goto send_thread_failed; } =20 /* create cdev */ - device->cdev =3D cdev_alloc(); - if (!device->cdev) { - dev_dbg(device->dev, "allocation of cdev failed\n"); + pi433->cdev =3D cdev_alloc(); + if (!pi433->cdev) { + dev_dbg(pi433->dev, "allocation of cdev failed\n"); retval =3D -ENOMEM; goto cdev_failed; } - device->cdev->owner =3D THIS_MODULE; - cdev_init(device->cdev, &pi433_fops); - retval =3D cdev_add(device->cdev, device->devt, 1); + pi433->cdev->owner =3D THIS_MODULE; + cdev_init(pi433->cdev, &pi433_fops); + retval =3D cdev_add(pi433->cdev, pi433->devt, 1); if (retval) { - dev_dbg(device->dev, "register of cdev failed\n"); + dev_dbg(pi433->dev, "register of cdev failed\n"); goto del_cdev; } =20 /* spi setup */ - spi_set_drvdata(spi, device); + spi_set_drvdata(spi, pi433); =20 - entry =3D debugfs_create_dir(dev_name(device->dev), root_dir); - debugfs_create_file("regs", 0400, entry, device, &pi433_debugfs_regs_fops= ); + entry =3D debugfs_create_dir(dev_name(pi433->dev), root_dir); + debugfs_create_file("regs", 0400, entry, pi433, &pi433_debugfs_regs_fops); =20 return 0; =20 del_cdev: - cdev_del(device->cdev); + cdev_del(pi433->cdev); cdev_failed: - kthread_stop(device->tx_task_struct); + kthread_stop(pi433->tx_task_struct); send_thread_failed: - device_destroy(&pi433_class, device->devt); + device_destroy(&pi433_class, pi433->devt); device_create_failed: - pi433_free_minor(device); + pi433_free_minor(pi433); minor_failed: - free_gpio(device); + free_gpio(pi433); GPIO_failed: - kfree(device->rx_buffer); + kfree(pi433->rx_buffer); RX_failed: - kfree(device); + kfree(pi433); =20 return retval; } =20 static void pi433_remove(struct spi_device *spi) { - struct pi433_device *device =3D spi_get_drvdata(spi); + struct pi433_device *pi433 =3D spi_get_drvdata(spi); =20 - debugfs_lookup_and_remove(dev_name(device->dev), root_dir); + debugfs_lookup_and_remove(dev_name(pi433->dev), root_dir); =20 /* free GPIOs */ - free_gpio(device); + free_gpio(pi433); =20 /* make sure ops on existing fds can abort cleanly */ - device->spi =3D NULL; + pi433->spi =3D NULL; =20 - kthread_stop(device->tx_task_struct); + kthread_stop(pi433->tx_task_struct); =20 - device_destroy(&pi433_class, device->devt); + device_destroy(&pi433_class, pi433->devt); =20 - cdev_del(device->cdev); + cdev_del(pi433->cdev); =20 - pi433_free_minor(device); + pi433_free_minor(pi433); =20 - kfree(device->rx_buffer); - kfree(device); + kfree(pi433->rx_buffer); + kfree(pi433); } =20 static const struct of_device_id pi433_dt_ids[] =3D { --=20 2.34.1 From nobody Mon Feb 9 12:01:58 2026 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 267BD65BD1 for ; Tue, 2 Apr 2024 11:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056471; cv=none; b=IkUUdCwKaGugtK5Iw0dc2ClIGevbEwo/LRdGFiJFLNoKBQoVgXCs1n2lw5waIXld0MZKN21q2TlwCIv2AJ1ADd9KD7MgogX4pw2jCxMVVa4qldtLRcJHjiSSeFdZYhHzIAUqZ7kP/wI0nzhthKkdumMtOWqVp7xrQsd53npeAvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056471; c=relaxed/simple; bh=jK+AFaPuB4QJkOlQSpapYzjziTfiCfCCfo7UWLC+ajY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P2YJLm12QC1LePG0kJn2za6UhCj5zBkDWBsrIO91rMcgYrUvPfLb3U50UBFSqa3nVWvoivbg+rakyc635pdXh/1lxPo056sQB3yG0A+JCcQBWPYKSRJ4jLPVYEU+mhFwaqvmjE5Kp2CpAFitQXfIeYxJtsJ5bofYvsl4OpMxiM0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XTatd7zE; arc=none smtp.client-ip=209.85.219.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XTatd7zE" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6962e6fbf60so44097786d6.1 for ; Tue, 02 Apr 2024 04:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712056469; x=1712661269; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bF9nmGQgrbBBKoEODSqmsdf3m34vi7We9f5KYGrq5eQ=; b=XTatd7zExMDOaI0CoJwn8flni40honijO/2m59N6mMmHyiAnC8HZK5wfXbao3WaUiF ddikk650/vphdp6UdS8O0ORrpaWs15dn1Q+kZ4AWENLNLaY2vNN4EUNIBLnOxqmaRYPZ n00eBZN1JuKBwIvBOPrl7ehL/qDVQW6MTpkUQyW7yaY4JNNc3GYwCww7MQ9rbN+Ojm8K aG2XC0JVaebM03kIZq1SaWD8DqLHmzNBZC9ZAyOxD/u3rss8HI18nw319O2k8TJeXhmw viHQ3ZSWNlUMxyIQfWd+sVorJnsEGxVzih1OjYv9vnNhVBqem+YfxrN7XH4jAGyq1OKl epDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712056469; x=1712661269; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bF9nmGQgrbBBKoEODSqmsdf3m34vi7We9f5KYGrq5eQ=; b=RfIm3bZMOu54oW4kMIv4LORxDK9eP2Sw29vEbASC+ER1WWyk16JTovNYpgZPcV2y5E mmSd6G0Whk9g3F2BhTUcvVQnPmbEO7Dvt4UNMkUyn5mfAT9tYNx68xQVPlpuG1nvqCSF 8LKXLLo1UIa8qQoPBV57z18RCRdZFQlw90Zvy+URA+NxZm6zgpYYjiOzK7axDDuNSuha 4l/eAydjtOPSh7a7GqzDqEidE53tZHjLjZ0oQr0jki+bxSA6yQL6ppl/MpegbxRtEF2a B2LwJF2ss/plGOVSjf173RY9FQhdgAj/oSJP/FpnZSTEI99jAEsV3MP/NRjzwv9DhVZ/ qSCQ== X-Forwarded-Encrypted: i=1; AJvYcCX8HZNEtnICa77KPOgFnqSMzYtv3L2uLJA7jHqFG3xLQ1FuRvWj64YD+R7tjYoCUTILd89fIoG6hMOHrzj2XbIly1QHNVhboS5zrhhM X-Gm-Message-State: AOJu0YxYDtaD60BMpoQ0YIfqQiid/dFF7drSGKiNuwhBY6h47fH0G58k cePeO5ViukHyyglQeT+MaxmTcbC9DxvWU0wjMm7ags9/tbJb1yHE X-Google-Smtp-Source: AGHT+IGS0uqiCKJa4dv9VNSkOwxSSex+kQ8m3oeOu7lY86dHg2spNQmL+dupDA7mrw1XNDRQdV8eTw== X-Received: by 2002:a0c:fecc:0:b0:699:af7:1fa6 with SMTP id z12-20020a0cfecc000000b006990af71fa6mr5206180qvs.47.1712056469197; Tue, 02 Apr 2024 04:14:29 -0700 (PDT) Received: from YOGA.local ([2a06:c701:737b:ef00:2c6f:6cdc:f641:6ecf]) by smtp.gmail.com with ESMTPSA id 11-20020a05621420cb00b006968a6fb010sm5428855qve.91.2024.04.02.04.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:14:28 -0700 (PDT) From: Shahar Avidar To: gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, andriy.shevchenko@linux.intel.com, robh@kernel.org, felixkimbu1@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] staging: pi433: Replace pi433_receive param void type to struct pi433_device. Date: Tue, 2 Apr 2024 14:14:11 +0300 Message-Id: <20240402111414.871089-4-ikobh7@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402111414.871089-1-ikobh7@gmail.com> References: <20240402111414.871089-1-ikobh7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pi433_receive is only called once. It immediately assigns the data param to a struct pi433_device. Rename param name to pi433. Signed-off-by: Shahar Avidar --- drivers/staging/pi433/pi433_if.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 7efe6b8501e3..208c0c6d3649 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -409,9 +409,8 @@ static int pi433_start_rx(struct pi433_device *pi433) =20 /*------------------------------------------------------------------------= -*/ =20 -static int pi433_receive(void *data) +static int pi433_receive(struct pi433_device *pi433) { - struct pi433_device *pi433 =3D data; struct spi_device *spi =3D pi433->spi; int bytes_to_read, bytes_total; int retval; --=20 2.34.1 From nobody Mon Feb 9 12:01:58 2026 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 687D36996A for ; Tue, 2 Apr 2024 11:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056473; cv=none; b=YFaS+wRVZyUCzpd0Km1O5gmySoL8zHySQp47p35Dm6y4y9h8+EAC0wqOwTs34QQIzKx6TsvcyVI3s1LQrvFsQ/Qbjhq6tn3WRUfsg59VV+smTJeW3y8feiMFADAUSbNAo/UvE29uI+xu2VpRwmS5vHz3wBTDYNzmbmSn9nmud+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056473; c=relaxed/simple; bh=HjRvMGXjDbwDSvM16WAhK4wPegt0yyIWO/1j4Z95mjo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NjhgJ98W0bqr3+XQuRzvT9eBaDu2QnJELoZpZF2efFjibKezvSkIYKTz6JiXhwvdADnoLMRMkl7G70TlEyFPqFAJ3UxFFs647Apq+JQ38ne/1fMCxF+8fjcsBgBajnHveHfzKysWWvHE4XM5cmI8KW2BAD3QeiKHaiBmZLdpYxw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JAT5AWe2; arc=none smtp.client-ip=209.85.219.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JAT5AWe2" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6991b50e2b3so2403636d6.3 for ; Tue, 02 Apr 2024 04:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712056471; x=1712661271; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YJrpsii5KxAd/+yN0rzfHDl19GAcoZcZzgV5GRtFABE=; b=JAT5AWe2nZxSvKyyo2YpAfq5ke30uGTWqXnQUMxXleDP0ZjJlLkP2f5gnuzZVng9ie Zm2CM6mSS7LX0R1cFKJ/3hbHGyOkbkml0qvObdt/Lbqf56DvuV8CsruV6Cm7CV5ptqo8 RkSIHjqIoJ841q8qOKPrqe9C0kJevzfTFdV7Q9z5u7gSeTozfyx9EF9ouLKY+N6150oa D2hwIv4s1m3CtvOTv0ThP2gxYJPbbu576hRs4TuIQ1lkl/yc1tAv3iWnwYraOQS5NrUl 7/u5WhHvrm9QsnwS1h2hBG2M9oTtg15jzKHGarrkkr9cS7LgSD0sVPgdFCJqgwJm+HGe 3Dxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712056471; x=1712661271; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YJrpsii5KxAd/+yN0rzfHDl19GAcoZcZzgV5GRtFABE=; b=jS8sj9XCc1j5O1y0A4+mepT+rh+3oR+C7sFx1YEbRbbOAAqkhUvmmul2G2WaaEZ/in R7YPr50XctP7L8mGEfEIEWCKZ8tXdl65an6VA+IsTF7x88zuDWOTZ1RtaVAasa4OqFAx Rqnrdw6IiQdasPPMhJaQEMPTRG4ZawDpzegiQz/rrMKq3xfkDuS8gloIlyBcjsKAoFLp tPg7thH/tbgp66CpePJxuQqv2bySVxBnS+mxhQUrnYyscDhbr/D5erd1mXeV614Se+9A J55ZgMikzJAKKEWwBBaMw9Iz3I+0/vzt1PMLuCqp/XFaAw21+NaKsFgcWMB0gmWbs+dw wcjw== X-Forwarded-Encrypted: i=1; AJvYcCXhvpCHqdwFsxfSVfFATjX6AFobMX2Ncm+A4lBM+G3CrrOSQSVK4xNZsfGC9PyikXAVQzNSjqlTWAjedps51+QM9DOWiTQwZADqF68n X-Gm-Message-State: AOJu0YyLbcYoDMc7GvxLY3Ks2r8tEkUkGqikqj/M9kQOFxyUwNIjYOuo 3OKSvvZ1klI/fO0K9ryVMjETnmLhfaReHmGgnCTm+aTQl468Qv0n X-Google-Smtp-Source: AGHT+IF+fzJLuXaGOfACwLIziHCh2KfismoKuF2DlR8MVTa2dSbqg37YPm3Lu8RyXS7XIz2TLdqRwA== X-Received: by 2002:a0c:ecc4:0:b0:699:21a9:8ecd with SMTP id o4-20020a0cecc4000000b0069921a98ecdmr196674qvq.5.1712056471307; Tue, 02 Apr 2024 04:14:31 -0700 (PDT) Received: from YOGA.local ([2a06:c701:737b:ef00:2c6f:6cdc:f641:6ecf]) by smtp.gmail.com with ESMTPSA id 11-20020a05621420cb00b006968a6fb010sm5428855qve.91.2024.04.02.04.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:14:30 -0700 (PDT) From: Shahar Avidar To: gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, andriy.shevchenko@linux.intel.com, robh@kernel.org, felixkimbu1@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] staging: pi433: Rename "pi433_dev" of type "dev_t" to "pi433_devt" Date: Tue, 2 Apr 2024 14:14:12 +0300 Message-Id: <20240402111414.871089-5-ikobh7@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402111414.871089-1-ikobh7@gmail.com> References: <20240402111414.871089-1-ikobh7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Distinguish struct device type instances from dev_t instances to enhance readability. Signed-off-by: Shahar Avidar --- drivers/staging/pi433/pi433_if.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 208c0c6d3649..62ce75b07bf0 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -53,7 +53,7 @@ #define FIFO_THRESHOLD 15 /* bytes */ #define NUM_DIO 2 =20 -static dev_t pi433_dev; +static dev_t pi433_devt; static DEFINE_IDR(pi433_idr); static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */ static struct dentry *root_dir; /* debugfs root directory for the driver */ @@ -1262,7 +1262,7 @@ static int pi433_probe(struct spi_device *spi) } =20 /* create device */ - pi433->devt =3D MKDEV(MAJOR(pi433_dev), pi433->minor); + pi433->devt =3D MKDEV(MAJOR(pi433_devt), pi433->minor); pi433->dev =3D device_create(&pi433_class, &spi->dev, pi433->devt, @@ -1276,7 +1276,7 @@ static int pi433_probe(struct spi_device *spi) } else { dev_dbg(pi433->dev, "created device for major %d, minor %d\n", - MAJOR(pi433_dev), + MAJOR(pi433_devt), pi433->minor); } =20 @@ -1398,13 +1398,13 @@ static int __init pi433_init(void) * that will key udev/mdev to add/remove /dev nodes. * Last, register the driver which manages those device numbers. */ - status =3D alloc_chrdev_region(&pi433_dev, 0, N_PI433_MINORS, "pi433"); + status =3D alloc_chrdev_region(&pi433_devt, 0, N_PI433_MINORS, "pi433"); if (status < 0) return status; =20 status =3D class_register(&pi433_class); if (status) { - unregister_chrdev(MAJOR(pi433_dev), + unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name); return status; } @@ -1414,7 +1414,7 @@ static int __init pi433_init(void) status =3D spi_register_driver(&pi433_spi_driver); if (status < 0) { class_unregister(&pi433_class); - unregister_chrdev(MAJOR(pi433_dev), + unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name); } =20 @@ -1427,7 +1427,7 @@ static void __exit pi433_exit(void) { spi_unregister_driver(&pi433_spi_driver); class_unregister(&pi433_class); - unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); + unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name); debugfs_remove(root_dir); } module_exit(pi433_exit); --=20 2.34.1 From nobody Mon Feb 9 12:01:58 2026 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CE7974262 for ; Tue, 2 Apr 2024 11:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056476; cv=none; b=IjGXd6kfATbqE6oxmHK9bpzZMF3gLhaOhEnhOGg2MplvumKcSe5h081H+hHk/YGYUcLTg4owLjyqJnREFWQknjNDJJiPXToOpgdAObqCmuELySB5z3sq2BYXnJ0jGp/XkZgCkoDcv+odoyIbMZpVLbtLYT/iY9J9MfmF8tqN+t0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056476; c=relaxed/simple; bh=gcpheDANWK19woUIfqj/fVqHsx2og6+K7UySgK3tvLo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FQcBlKf3DewthVQ0p8GlqJMsX2SYknr9berooGdd8EXM4zFGL14ehxKYn1vmEQiliJ61/B72pF7tFa205X9lejjBdAZsdyclG9TP2UH3YkhL9LwRE/iywPAEyo2GSV2FUrHfNL4M1zel0nCN/UDqOPQ4urPfv3EqmglB76OWwVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UWoqk8U/; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UWoqk8U/" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-698d68337a8so24905236d6.0 for ; Tue, 02 Apr 2024 04:14:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712056473; x=1712661273; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kVb/UGONQyBT+z/L6u7Z9rLkuNJQKGw42waV76KdoHg=; b=UWoqk8U/YTErv1PDWykdc4GQKVe99ETTFHRrWl41cJ4kN9MOtZX3DQUXIUhDeUGK1e 68Wq/A7AHYJ9Uy0SjJVYnPJvXqrFD8+kggpCBtmog+stWn8plZMkTM7fX2A6U0IWtk2P yBs2r0l/mL+sIKMd/KD7j/krTqJedACrV6SmSEmPAvgT8dfdONfh3raMPV1tKeV2ftO0 0DIz2MsTd6kw0dn6zSO7VVq+88uR/r4NWoNsOWDjiwoRiWghhk/7RWP3SLyrluE1f2Yg yVcesFjVSC4Uuyo3/62fthPv+8zy5/uAcKmoLoQ3az1LA7VU5cCqmiBrNCvxdB5z7IyR qG3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712056473; x=1712661273; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kVb/UGONQyBT+z/L6u7Z9rLkuNJQKGw42waV76KdoHg=; b=E983rk4KnCY79PUWK/LAMumz09LkTqR00Q9zY7FkEBk1Szk0y5S2H2m+Wbse0SPhce 4WACedDyaYCjtrr8GkJn4+2h0bXk0NkqDy319TnfGBTA2rb+fCE3vnLZrK2ojVzj+deG VqyXY3Xn4nv1QNqx5hvmusOcEzx0w6XY+7EPhdL53Dm/5h95io6EpPBhGTJxNgsQfYXc 3yUKoFs4N+0aRmYb4qUkltVARcAZGWmB9QbHoMLVdBMGOyTpDcVJb7lgfBrd78oJtweC /RPJTCDOgy6J/4f3149Kzf6D3mhjDKkXQByOpCxUUkWPCfP9e+OHGcJEmXN3kx1q5ww8 WqqA== X-Forwarded-Encrypted: i=1; AJvYcCVMH9rD4lz25B5qZtbVjfH1f97lIidP1Lyt6b+tei/BLYQ+VD16GadpkrUuHFmQQJzUV9+WqyW7wujRB37OY+hSn6AXEaRJVvT6sI22 X-Gm-Message-State: AOJu0YxOv8k6tujBbHjqli+bOk4jF2wh9xPV1B73cNjfrim9A209p5C0 IpUi9SXnYk7msFbQnLYU61pCFjYLolJBvGgtrzVFsOGpBg07snqO X-Google-Smtp-Source: AGHT+IERjMFu5RgQedji7m32aGiXlcLxDQOA+nmAxLDWEk0/x7zTg44X+OPQJBASf129EwgkdSYPFg== X-Received: by 2002:a0c:e647:0:b0:698:6f2e:623a with SMTP id c7-20020a0ce647000000b006986f2e623amr13315711qvn.56.1712056473439; Tue, 02 Apr 2024 04:14:33 -0700 (PDT) Received: from YOGA.local ([2a06:c701:737b:ef00:2c6f:6cdc:f641:6ecf]) by smtp.gmail.com with ESMTPSA id 11-20020a05621420cb00b006968a6fb010sm5428855qve.91.2024.04.02.04.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:14:33 -0700 (PDT) From: Shahar Avidar To: gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, andriy.shevchenko@linux.intel.com, robh@kernel.org, felixkimbu1@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] staging: pi433: Remove duplicated code using the "goto" error recovery scheme. Date: Tue, 2 Apr 2024 14:14:13 +0300 Message-Id: <20240402111414.871089-6-ikobh7@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402111414.871089-1-ikobh7@gmail.com> References: <20240402111414.871089-1-ikobh7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pi433_init had "unregister_chrdev" called twice. Remove it using goto statements. Signed-off-by: Shahar Avidar --- v2->v1: Followed by Dan Carpenter's comments: - Remove empty "fail" goto tag. - Reorder pi433 init & exit calls so they have reverse order. - Add "unreg_spi_drv" goto tag. - Check "debugfs_create_dir" return value. - Update "if" statments for consistency. drivers/staging/pi433/pi433_if.c | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 62ce75b07bf0..47e0c51ffe2e 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1399,25 +1399,32 @@ static int __init pi433_init(void) * Last, register the driver which manages those device numbers. */ status =3D alloc_chrdev_region(&pi433_devt, 0, N_PI433_MINORS, "pi433"); - if (status < 0) + if (status) return status; =20 status =3D class_register(&pi433_class); - if (status) { - unregister_chrdev(MAJOR(pi433_devt), - pi433_spi_driver.driver.name); - return status; - } - - root_dir =3D debugfs_create_dir(KBUILD_MODNAME, NULL); + if (status) + goto unreg_chrdev; =20 status =3D spi_register_driver(&pi433_spi_driver); - if (status < 0) { - class_unregister(&pi433_class); - unregister_chrdev(MAJOR(pi433_devt), - pi433_spi_driver.driver.name); + if (status) + goto unreg_class; + + root_dir =3D debugfs_create_dir(KBUILD_MODNAME, NULL); + if (IS_ERR(root_dir)) { + status =3D PTR_ERR(root_dir); + goto unreg_spi_drv; } =20 + return 0; + +unreg_spi_drv: + spi_unregister_driver(&pi433_spi_driver); +unreg_class: + class_unregister(&pi433_class); +unreg_chrdev: + unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name); + return status; } =20 @@ -1425,10 +1432,10 @@ module_init(pi433_init); =20 static void __exit pi433_exit(void) { + debugfs_remove(root_dir); spi_unregister_driver(&pi433_spi_driver); class_unregister(&pi433_class); unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name); - debugfs_remove(root_dir); } module_exit(pi433_exit); =20 --=20 2.34.1 From nobody Mon Feb 9 12:01:58 2026 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 847FD76C76 for ; Tue, 2 Apr 2024 11:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056478; cv=none; b=Tzx14Fry/faKOSMhbSy16AY/JzAP1qnkoJDYaQ8xIgkvOh7ryDXrmIPLFtDUWTuHjtlczpYoRwDGSqxeHm2MTu6HK880J9FhjiM6rgf9lZ2gKLYyeC/G/kSo3GclKnN0qsYI3fjbSFH0f8lG57Kx0dAWCJpeNSWZ71G8ng9L+iY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712056478; c=relaxed/simple; bh=fcVbgCCXoK3w9FQOBuxNovy1ixOVJR9WHZpVbqKlyWk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MD5vAX6gopgWdDPX12oclwlNm1cUtlvFD3W0SF+7+kHBTL/ftQMrxGulJHSpD1D3hFt8wfTFzKMayglRVFkDAErlgHcSERt5/Aj1qOwoGq4/IwSPJ2uIck6uSt6xvRqCRFcybLHNfug92+puCLf84PBTcmvr0iiqJgu/ugXKDh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MjQXOnc/; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MjQXOnc/" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-69107859bedso28281626d6.2 for ; Tue, 02 Apr 2024 04:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712056475; x=1712661275; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FG+XcPSEX9Mh6tQPFknGS3juRQhjzxHPLPnw/bWfBs8=; b=MjQXOnc/POBhqVNmqo8AfKGi4GGG6SXc9gE+5YHWPXfIJj05Qbl0x1DD7U4uTwccUe 8eHdgt8tDOz91fAndlh/RpmujfZhTsDkKGITEoamHzaISyUJNoBSmjgZw5GOqkgowNrR WfW3Uxlt8XY38waJoOrAlvy5nD6eLiS9RUCNWmvC814REC1dfKZJ4Ig/Aj0cvLl8LIUw fP9FIwPN+ADhtzS7A/yc3bEsBe+gDYlI9fPwRsZme7XhCtd7V0cCjOhu9YeBHmGvXw/M oBMlL/HVhXoD3MvAxDEmIBL7laR1YFAYIKavV3Nl8Y1CwkiUxFN2pl/Lz9yczhSRJu9u QSNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712056475; x=1712661275; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FG+XcPSEX9Mh6tQPFknGS3juRQhjzxHPLPnw/bWfBs8=; b=KFWTl5SDCwVFDHVUZIov6+EqzFNLQjOr3vD3QTfpmDAYmrnVzdAFX6xYkLwClXOB1j yEhd737JqlNWe8Aa0S/okygEpAEcF5n8vk/JY3OuR0Tpd2KsOHWH9U8WzS13B4qDO923 JKU0lHDc5wD/EsxeIHeSpuBTEUnM+cJpQbM8JB+lO59p4GuQLhXZUC3w23QWIPcq6oxx GKmZe0vYKF1VT4oP6wby432RhhVA/4hibESqDV3b/gbEiaT1Mb4f7Oue0sLMPGN0d1Oa aGY5kBI3DrT97y8NIORxfimrhAckkPhDBaUxSDPA6hFwoT9CIDPkVxCqS6D1KmdS47d8 /rxw== X-Forwarded-Encrypted: i=1; AJvYcCWWgC8NQhDpskMQxR3vaj6WGGZH+BE39uGGzlNAxl6PbUppdgTQWtKN+sYSqVV0vjThn+N257XibzdOEPIcHe38kOEUuVj6h0CcuJHj X-Gm-Message-State: AOJu0YzltVM4Ok/gXIE1oou/rpkNi/GAkrcVgabAIG78FFvl3LEIwujw k3imxC6zVcZcbxpwKduThVk4XnxnfooRrasXT6S5ZfKb+EfSuKzh X-Google-Smtp-Source: AGHT+IF0PGkbBIJ7k97WVMkLHs2MM/H3Ee4F+sOqhIzOuyRuvbbet/78Nva9DA9ERL1udXnY8UjthQ== X-Received: by 2002:ad4:5d4b:0:b0:699:11a4:1aab with SMTP id jk11-20020ad45d4b000000b0069911a41aabmr3881782qvb.54.1712056475577; Tue, 02 Apr 2024 04:14:35 -0700 (PDT) Received: from YOGA.local ([2a06:c701:737b:ef00:2c6f:6cdc:f641:6ecf]) by smtp.gmail.com with ESMTPSA id 11-20020a05621420cb00b006968a6fb010sm5428855qve.91.2024.04.02.04.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:14:35 -0700 (PDT) From: Shahar Avidar To: gregkh@linuxfoundation.org, hverkuil-cisco@xs4all.nl, andriy.shevchenko@linux.intel.com, robh@kernel.org, felixkimbu1@gmail.com Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] staging: pi433: Rename return value from "status" to "ret". Date: Tue, 2 Apr 2024 14:14:14 +0300 Message-Id: <20240402111414.871089-7-ikobh7@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402111414.871089-1-ikobh7@gmail.com> References: <20240402111414.871089-1-ikobh7@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drivers init functions usually use either "ret" or "rc" naming their return variable. Signed-off-by: Shahar Avidar --- drivers/staging/pi433/pi433_if.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433= _if.c index 47e0c51ffe2e..b0407d5c6be8 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1384,7 +1384,7 @@ static struct spi_driver pi433_spi_driver =3D { =20 static int __init pi433_init(void) { - int status; + int ret; =20 /* * If MAX_MSG_SIZE is smaller then FIFO_SIZE, the driver won't @@ -1398,21 +1398,21 @@ static int __init pi433_init(void) * that will key udev/mdev to add/remove /dev nodes. * Last, register the driver which manages those device numbers. */ - status =3D alloc_chrdev_region(&pi433_devt, 0, N_PI433_MINORS, "pi433"); - if (status) - return status; + ret =3D alloc_chrdev_region(&pi433_devt, 0, N_PI433_MINORS, "pi433"); + if (ret) + return ret; =20 - status =3D class_register(&pi433_class); - if (status) + ret =3D class_register(&pi433_class); + if (ret) goto unreg_chrdev; =20 - status =3D spi_register_driver(&pi433_spi_driver); - if (status) + ret =3D spi_register_driver(&pi433_spi_driver); + if (ret) goto unreg_class; =20 root_dir =3D debugfs_create_dir(KBUILD_MODNAME, NULL); if (IS_ERR(root_dir)) { - status =3D PTR_ERR(root_dir); + ret =3D PTR_ERR(root_dir); goto unreg_spi_drv; } =20 @@ -1425,7 +1425,7 @@ static int __init pi433_init(void) unreg_chrdev: unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name); =20 - return status; + return ret; } =20 module_init(pi433_init); --=20 2.34.1