Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3698476rwb; Tue, 16 Aug 2022 07:25:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7rq1mB2ahIpMQJK8ru9v0ur9ntgc26ek1pwN87iQNKjrFWjb9NzJDnAIn5EJEViFbFKIpL X-Received: by 2002:a17:90a:6ba5:b0:1f5:3c80:6c0b with SMTP id w34-20020a17090a6ba500b001f53c806c0bmr24391382pjj.147.1660659907097; Tue, 16 Aug 2022 07:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660659907; cv=none; d=google.com; s=arc-20160816; b=Hk70tvWavMf+RzR1rUZN54gHv76ZQlW/O7it+tn1zWTothLhHvNitydP85FQWJVeTd 6DWy3kYCL7oy3daPjSiGje4t2YboGD9WhcpJrgUB9qpw+RPIgLCGJANaeqwcsjbV3G3i L9tnuWLkbqUdrqc+XKqXZ4J79CawREIsIHFX/lhemmJEHrWrwPZ8qLOb8ysEu9d+HfX/ ZpZN6tXa1Ed/QjvyIeYfd3q6Ya2db4R/TVNFKZRsHb5YpT6Zq5ak4f9hR7p8545j+BR9 Ih6nUTpQzC7+HF9VbGB1EBQ6Wz9kyzdxQm0HMgvR/oOmkv1ozXhtXAOQf2tSh0vxQ3zK yktA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Pjp8zJoD0CMYfvgpvjdOAip4+ZhC6HsTk53c/MNJh34=; b=atJm6uLZMXb7+VLiQnMAbtSeoeFsvgteeUWymkByZfXca4ABG99LO+epWuACdxFtl7 /rHpzF1maxJ7Lb7DvCi3r0IRNFSlCEIOlMg1NtyHDlyUsdX6BTAaSw8F+Fm1qeTMRviH +qEI1I43bxtNGBoEzOW9eB9Xzx2gCANF8LoIWCCGouvBBDSv9MVwwy5OO+Om3PmdipwH Vo4RyqQ4BxajlwzCjOqCxgD22gOh7vU+PBXzEE7K31SGgLr8d1EQpxgK5Zxnk3zWcKQm ASzcsDNTUnmgU5J75Q58dqeAIrkwTGTYkC6DGRNrtDpmZL0uFkCHQxvP76BQRcfSxoZq fjTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y129-20020a636487000000b0040d7ac04fafsi13605100pgb.36.2022.08.16.07.24.54; Tue, 16 Aug 2022 07:25:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233972AbiHPN7T (ORCPT + 99 others); Tue, 16 Aug 2022 09:59:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbiHPN7Q (ORCPT ); Tue, 16 Aug 2022 09:59:16 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79E774C610 for ; Tue, 16 Aug 2022 06:59:14 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4M6Xlm0JDgzGpW8; Tue, 16 Aug 2022 21:57:40 +0800 (CST) Received: from dggphis33418.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 16 Aug 2022 21:59:11 +0800 From: Gaosheng Cui To: , , , CC: , , Subject: [PATCH -next] mtd: ftl: use container_of() rather than cast Date: Tue, 16 Aug 2022 21:59:10 +0800 Message-ID: <20220816135910.268016-1-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The container_of() is much more readable and also safer. Signed-off-by: Gaosheng Cui --- drivers/mtd/ftl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index bec56070039d..7e56c77535e8 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -941,7 +941,7 @@ static int ftl_write(partition_t *part, caddr_t buffer, static int ftl_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo) { - partition_t *part = (void *)dev; + partition_t *part = container_of(dev, struct partition_t, mbd); u_long sect; /* Sort of arbitrary: round size down to 4KiB boundary */ @@ -969,7 +969,7 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev, static int ftl_discardsect(struct mtd_blktrans_dev *dev, unsigned long sector, unsigned nr_sects) { - partition_t *part = (void *)dev; + partition_t *part = container_of(dev, struct partition_t, mbd); uint32_t bsize = 1 << part->header.EraseUnitSize; pr_debug("FTL erase sector %ld for %d sectors\n", -- 2.25.1