Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp321088yba; Sat, 13 Apr 2019 01:42:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEFnTga6vJ0rxv3m922Sebai/RwIjCTUvGWniyeDULy66uQw0lvCMi+7qUYAluAS2PPUYE X-Received: by 2002:a62:474a:: with SMTP id u71mr61860557pfa.87.1555144927046; Sat, 13 Apr 2019 01:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555144927; cv=none; d=google.com; s=arc-20160816; b=Io+vMlWRLnf4vfVJD7IvviyAinGMda4/T/lsoYmcJuNYyTqpoANc/K7Z87rWwxDc64 ziKgnOEGef7eb54pb3PllDo0NzvxiJLWgKvzEvRcu3YghogXI6ceMucmaVRxiJcvRbYm DZbNmJ6mL0NLja6NhRtW7WPIdP5iTqrY3XfQvZLofXQp4tfL13fsPxk1yrSJbLgbo/JJ 32NehsNrFzsOnOcm8edX7XdCWR618LKFsE+2r3JAIiPiA737k0xUXPIBMsungUdg6PZh nl//Z985hHSXoK0vViCjU3PUihrQ2v2XylxwcQjBXrJrPBUwuz+a6VM/JK8gL5/s0yEC PtIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=miphC7Rh56CEqcZp37WgvY1BDc1+lvxek6irkT4jSCw=; b=syp/Hww22ysyaWlWIzHRgnRRLpTwR4jCE3cqL8nYJrdwjKRGejrGG7cvDvCtiH9+pb sdNa0xbdrW+FA/OE0ODBRlGgpIChzYhCHacQpI9x9tcFKTcnOLQDjR2sR7JQOypRntRM KaqpE3g4iqJH5ESZZeISIHsTmlIKbAGJ09Ez+Wo+vuyDOM7nS3CgAjSCnX4CpLpG6g83 4UjVVOF9oQnR6FjZO8rmm0Zycbi7Tnf8W1yueIqN//cm4q9+u7BOCH0wb/Xm8EI+VWTi FrBAuoqa8B2ZL9yTC/1v676tB8kPkNdVlL4wMZ/sNxuayVYEOKecqnN4WpJoFCjd3Bdm 7AIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r17si20142521pgh.311.2019.04.13.01.41.51; Sat, 13 Apr 2019 01:42:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbfDMIlO (ORCPT + 99 others); Sat, 13 Apr 2019 04:41:14 -0400 Received: from lilium.sigma-star.at ([109.75.188.150]:40744 "EHLO lilium.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbfDMIlO (ORCPT ); Sat, 13 Apr 2019 04:41:14 -0400 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 27BD11802199E; Sat, 13 Apr 2019 10:41:11 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Cc: linux-kernel@vger.kernel.org, bbrezillon@kernel.org, miquel.raynal@bootlin.com, dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, Richard Weinberger Subject: [PATCH 2/2] mtd: nandsim: switch to exec_op interface Date: Sat, 13 Apr 2019 10:40:52 +0200 Message-Id: <20190413084052.15416-2-richard@nod.at> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190413084052.15416-1-richard@nod.at> References: <20190413084052.15416-1-richard@nod.at> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stop using the legacy interface. Signed-off-by: Richard Weinberger --- drivers/mtd/nand/raw/nandsim.c | 78 ++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsi= m.c index 3d80e2d23b6e..33c369f9a607 100644 --- a/drivers/mtd/nand/raw/nandsim.c +++ b/drivers/mtd/nand/raw/nandsim.c @@ -299,6 +299,7 @@ union ns_mem { */ struct nandsim { struct nand_chip chip; + struct nand_controller base; struct mtd_partition partitions[CONFIG_NANDSIM_MAX_PARTS]; unsigned int nbparts; =20 @@ -645,9 +646,6 @@ static int __init init_nandsim(struct mtd_info *mtd) return -EIO; } =20 - /* Force mtd to not do delays */ - chip->legacy.chip_delay =3D 0; - /* Initialize the NAND flash parameters */ ns->busw =3D chip->options & NAND_BUSWIDTH_16 ? 16 : 8; ns->geom.totsz =3D mtd->size; @@ -2077,24 +2075,6 @@ static void ns_nand_write_byte(struct nand_chip *c= hip, u_char byte) return; } =20 -static void ns_hwcontrol(struct nand_chip *chip, int cmd, unsigned int b= itmask) -{ - struct nandsim *ns =3D nand_get_controller_data(chip); - - ns->lines.cle =3D bitmask & NAND_CLE ? 1 : 0; - ns->lines.ale =3D bitmask & NAND_ALE ? 1 : 0; - ns->lines.ce =3D bitmask & NAND_NCE ? 1 : 0; - - if (cmd !=3D NAND_CMD_NONE) - ns_nand_write_byte(chip, cmd); -} - -static int ns_device_ready(struct nand_chip *chip) -{ - NS_DBG("device_ready\n"); - return 1; -} - static void ns_nand_write_buf(struct nand_chip *chip, const u_char *buf, int len) { @@ -2146,7 +2126,7 @@ static void ns_nand_read_buf(struct nand_chip *chip= , u_char *buf, int len) int i; =20 for (i =3D 0; i < len; i++) - buf[i] =3D chip->legacy.read_byte(chip); + buf[i] =3D ns_nand_read_byte(chip); =20 return; } @@ -2169,6 +2149,46 @@ static void ns_nand_read_buf(struct nand_chip *chi= p, u_char *buf, int len) return; } =20 +static int ns_exec_op(struct nand_chip *chip, const struct nand_operatio= n *op, + bool check_only) +{ + int i; + unsigned int op_id; + const struct nand_op_instr *instr =3D NULL; + struct nandsim *ns =3D nand_get_controller_data(chip); + + ns->lines.ce =3D chip->cur_cs =3D=3D -1 ? 0 : 1; + + for (op_id =3D 0; op_id < op->ninstrs; op_id++) { + instr =3D &op->instrs[op_id]; + ns->lines.cle =3D 0; + ns->lines.ale =3D 0; + + switch (instr->type) { + case NAND_OP_CMD_INSTR: + ns->lines.cle =3D 1; + ns_nand_write_byte(chip, instr->ctx.cmd.opcode); + break; + case NAND_OP_ADDR_INSTR: + ns->lines.ale =3D 1; + for (i =3D 0; i < instr->ctx.addr.naddrs; i++) + ns_nand_write_byte(chip, instr->ctx.addr.addrs[i]); + break; + case NAND_OP_DATA_IN_INSTR: + ns_nand_read_buf(chip, instr->ctx.data.buf.in, instr->ctx.data.len); + break; + case NAND_OP_DATA_OUT_INSTR: + ns_nand_write_buf(chip, instr->ctx.data.buf.out, instr->ctx.data.len)= ; + break; + case NAND_OP_WAITRDY_INSTR: + /* we are always ready */ + break; + } + } + + return 0; +} + static int ns_attach_chip(struct nand_chip *chip) { unsigned int eccsteps, eccbytes; @@ -2209,6 +2229,7 @@ static int ns_attach_chip(struct nand_chip *chip) =20 static const struct nand_controller_ops ns_controller_ops =3D { .attach_chip =3D ns_attach_chip, + .exec_op =3D ns_exec_op, }; =20 /* @@ -2234,14 +2255,6 @@ static int __init ns_init_module(void) nsmtd =3D nand_to_mtd(chip); nand_set_controller_data(chip, (void *)ns); =20 - /* - * Register simulator's callbacks. - */ - chip->legacy.cmd_ctrl =3D ns_hwcontrol; - chip->legacy.read_byte =3D ns_nand_read_byte; - chip->legacy.dev_ready =3D ns_device_ready; - chip->legacy.write_buf =3D ns_nand_write_buf; - chip->legacy.read_buf =3D ns_nand_read_buf; chip->ecc.mode =3D NAND_ECC_SOFT; chip->ecc.algo =3D NAND_ECC_HAMMING; /* The NAND_SKIP_BBTSCAN option is necessary for 'overridesize' */ @@ -2292,7 +2305,10 @@ static int __init ns_init_module(void) if ((retval =3D parse_gravepages()) !=3D 0) goto error; =20 - chip->legacy.dummy_controller.ops =3D &ns_controller_ops; + nand_controller_init(&ns->base); + ns->base.ops =3D &ns_controller_ops; + chip->controller =3D &ns->base; + retval =3D nand_scan(chip, 1); if (retval) { NS_ERR("Could not scan NAND Simulator device\n"); --=20 2.21.0