From patchwork Sat Aug 7 21:45:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 1514721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Sw+PsqBW; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mess.org header.i=@mess.org header.a=rsa-sha256 header.s=2020 header.b=rspCPUmG; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GhwtJ5329z9sWX for ; Sun, 8 Aug 2021 07:47:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=L2BCGw3NzbY0DQLPeufgnWBQzTwnViVgseboRM6NMnE=; b=Sw+PsqBWejkL+D ipya98jk3hH759owDtdwVIE7z2+hmFY6MrbhyjZVtGS06V4UxpRiuqV4TzTHdy3tCfgJK3H6dIpcO QdWLKcleqEt8QeEo2BTyu2jlpUAJrYZskG8Y3aKfz3MH3f+IF0ue+qS6G4Dy05okyFdoR32TKAwqG ueMvcVuuQmm96iK5VGBbrGaecxCFC5Tbn3rX95qhBZ9IjfXTUQqb/vhCFIqudC1m7XZyjwtgplBwU zAqhalrz+B5Al+UpHmU9x9U/t5IOlNL93wuW2h3nWcNB2YFCzNWFsSBlW+JHs8ifqKiVswnd23BPt GpSPakQLuF+IakAEgXZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mCU9X-00FBc1-3q; Sat, 07 Aug 2021 21:46:47 +0000 Received: from gofer.mess.org ([2a02:8011:d000:212::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mCU8V-00FBLb-3N for linux-mtd@lists.infradead.org; Sat, 07 Aug 2021 21:45:45 +0000 Received: by gofer.mess.org (Postfix, from userid 1000) id 98E63C6AA3; Sat, 7 Aug 2021 22:45:39 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1628372739; bh=FaECp3RehvPziDHXKwo3DyfoUxDIlQS/YT4M2ULwY2o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rspCPUmGPNEt3iD5OtDi4G0u7JGq/2Stfck+PJ4fXpzb2+psox1lAeYLUVgcRjxlo GngTziiwua9F58eYSfEq3Gx0xFW9IzBif+Pr1SAYhbslHneuMjQNcQPvcRTLkmIn+n QUVn5gU2w+r3LcYrlhH9DhUGO8+NGG47Tb33YVHfSVHLrim7DJneyLItJUTFIymPyO IDQGF0ileuAGeZ3ydDMrJ2zh2DBLp4KLI5kcPqXNxRQcM1JgTZZEIPbqlvHH6whL/U 3ESDOxKtDGYJDYV813A4RosVdP87n/E7DgPzDvylYmMGnnrrVzjHQOTWDTALPXJAlR M153sUBVfObqA== From: Sean Young To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org Subject: [PATCH v2 5/5] mtd: rfd_ftl: use container_of() rather than cast Date: Sat, 7 Aug 2021 22:45:38 +0100 Message-Id: <20210807214538.14484-6-sean@mess.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210807214538.14484-1-sean@mess.org> References: <20210807214538.14484-1-sean@mess.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210807_144543_319772_D73951D7 X-CRM114-Status: GOOD ( 10.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The container_of() is much more readable and also safer. Signed-off-by: Sean Young --- drivers/mtd/rfd_ftl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index 52be9f1fa9a2..af20a0a71108 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c @@ -239,7 +239,7 @@ static int scan_header(st [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The container_of() is much more readable and also safer. Signed-off-by: Sean Young --- drivers/mtd/rfd_ftl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index 52be9f1fa9a2..af20a0a71108 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c @@ -239,7 +239,7 @@ static int scan_header(struct partition *part) static int rfd_ftl_readsect(struct mtd_blktrans_dev *dev, u_long sector, char *buf) { - struct partition *part = (struct partition*)dev; + struct partition *part = container_of(dev, struct partition, mbd); u_long addr; size_t retlen; int rc; @@ -600,7 +600,7 @@ static int find_free_sector(const struct partition *part, const struct block *bl static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, ulong *old_addr) { - struct partition *part = (struct partition*)dev; + struct partition *part = container_of(dev, struct partition, mbd); struct block *block; u_long addr; int i; @@ -666,7 +666,7 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, static int rfd_ftl_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf) { - struct partition *part = (struct partition*)dev; + struct partition *part = container_of(dev, struct partition, mbd); u_long old_addr; int i; int rc = 0; @@ -708,7 +708,7 @@ static int rfd_ftl_writesect(struct mtd_blktrans_dev *dev, u_long sector, char * static int rfd_ftl_discardsect(struct mtd_blktrans_dev *dev, unsigned long sector, unsigned int nr_sects) { - struct partition *part = (struct partition *)dev; + struct partition *part = container_of(dev, struct partition, mbd); u_long addr; int rc; @@ -735,7 +735,7 @@ static int rfd_ftl_discardsect(struct mtd_blktrans_dev *dev, static int rfd_ftl_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo) { - struct partition *part = (struct partition*)dev; + struct partition *part = container_of(dev, struct partition, mbd); geo->heads = 1; geo->sectors = SECTORS_PER_TRACK; @@ -792,7 +792,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) static void rfd_ftl_remove_dev(struct mtd_blktrans_dev *dev) { - struct partition *part = (struct partition*)dev; + struct partition *part = container_of(dev, struct partition, mbd); int i; for (i=0; itotal_blocks; i++) { @@ -803,7 +803,7 @@ static void rfd_ftl_remove_dev(struct mtd_blktrans_dev *dev) vfree(part->sector_map); kfree(part->header_cache); kfree(part->blocks); - del_mtd_blktrans_dev(dev); + del_mtd_blktrans_dev(&part->mbd); } static struct mtd_blktrans_ops rfd_ftl_tr = {