From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x224CCvuSOO3gmGkMUZqh4Nmf6lihcOXTEoxVCbqMnMJuUDPOGbTeNBw/N184GI9y8nI3P6Qc ARC-Seal: i=1; a=rsa-sha256; t=1516819107; cv=none; d=google.com; s=arc-20160816; b=iz0sLJpfl7gdJ/RTtV5wxNR/QoFbgWfuO3ombfY9LCT5Hs92IE52pO29O5z3iy54Ry tYPA1I7teoQ29QsfRRdJc3oLXCO2apZguLkgBDYL8x98LJBEBYqQIobOjCrMLnws51Y9 9DX/h8NJWkmm/zJzdCb9mtoNZYJCcnbqH/o8aYVBXBNkRWAL4mHwlW4p/gEELMRy2GYE kTEqhip8Nn+ulJ3ZXVOgenCTrzG/t7+PqXDewBEBiCX7tZhDQb4e/npy3aciyLgMs5ly QIzRU6yLwXlhr+E4Ooq67I2aU4D2dh6XLdx3Pny6etKTBSHTRgtsLkRrfAjfuG90zcei 3+JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=I1G3vN1W7A7kzaR66BrDWZkYs1jql3NMdTfHuDwQNQ0=; b=b1eKjRglkeCz1KngyN88Rnc19E7gVjoUZoNRbcVSgVQzosfmhbPC2NWuPi3hF7l6VN WFuduG37gyxbvkFaoIRuVVVlNAWhsdvxOtnCNcWbhFe3Gb9cftdByjTpmVcfcv5kxZTB 9C6aTHddJFaEJrSzAJR/xqHAHRYfAQA6VC05VZxQDDLhAhWAnZ0i6rCr2Qbkf4Ex9syg WBGjPGmcnWdWCoyvcV1wLIxGPxew2TtrNU9nBn4jvWt4Cjg5lTmdItdgQtwndNkptG6C YCKoxnJsGAjdzWaRtcTaTla1jPXQA6pfPhxPDsLfuqgcFlsiJYTejdM+FmBguJmWK52i GRKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vadimp@mellanox.com designates 193.47.165.129 as permitted sender) smtp.mailfrom=vadimp@mellanox.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of vadimp@mellanox.com designates 193.47.165.129 as permitted sender) smtp.mailfrom=vadimp@mellanox.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mellanox.com From: Vadim Pasternak To: dvhart@infradead.org, andy.shevchenko@gmail.com, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, jiri@resnulli.us, Vadim Pasternak Subject: [patch v11 09/12] platform/x86: mlx-platform: Simplify IO access to regmap context Date: Wed, 24 Jan 2018 20:34:55 +0000 Message-Id: <1516826098-125036-1-git-send-email-vadimp@mellanox.com> X-Mailer: git-send-email 2.1.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590500111879646764?= X-GMAIL-MSGID: =?utf-8?q?1590500111879646764?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Get rid of struct mlxplat_mlxcpld_regmap_context, which contains only the field with base address. Instead obtain base memory address by devm_ioport_map to local variable and pass it to devm_regmap_init. Modify mlxplat_mlxcpld_reg_read/write to directly use pointer to context for IO operations. Add missed description of pdev_hotplug for struct mlxplat_priv. Signed-off-by: Vadim Pasternak --- drivers/platform/x86/mlx-platform.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c index 03c9e7a..81a7306 100644 --- a/drivers/platform/x86/mlx-platform.c +++ b/drivers/platform/x86/mlx-platform.c @@ -83,6 +83,7 @@ /* mlxplat_priv - platform private data * @pdev_i2c - i2c controller platform device * @pdev_mux - array of mux platform devices + * @pdev_hotplug - hotplug platform devices */ struct mlxplat_priv { struct platform_device *pdev_i2c; @@ -298,27 +299,17 @@ struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, }; -struct mlxplat_mlxcpld_regmap_context { - void __iomem *base; -}; - -static struct mlxplat_mlxcpld_regmap_context mlxplat_mlxcpld_regmap_ctx; - static int mlxplat_mlxcpld_reg_read(void *context, unsigned int reg, unsigned int *val) { - struct mlxplat_mlxcpld_regmap_context *ctx = context; - - *val = ioread8(ctx->base + reg); + *val = ioread8(context + reg); return 0; } static int mlxplat_mlxcpld_reg_write(void *context, unsigned int reg, unsigned int val) { - struct mlxplat_mlxcpld_regmap_context *ctx = context; - - iowrite8(val, ctx->base + reg); + iowrite8(val, context + reg); return 0; } @@ -407,6 +398,7 @@ static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { static int __init mlxplat_init(void) { struct mlxplat_priv *priv; + void __iomem *base; int i, err; if (!dmi_check_system(mlxplat_dmi_table)) @@ -446,16 +438,15 @@ static int __init mlxplat_init(void) } } - mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev, + base = devm_ioport_map(&mlxplat_dev->dev, mlxplat_lpc_resources[1].start, 1); - if (IS_ERR(mlxplat_mlxcpld_regmap_ctx.base)) { - err = PTR_ERR(mlxplat_mlxcpld_regmap_ctx.base); + if (IS_ERR(base)) { + err = PTR_ERR(base); goto fail_platform_mux_register; } mlxplat_hotplug->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL, - &mlxplat_mlxcpld_regmap_ctx, - &mlxplat_mlxcpld_regmap_config); + base, &mlxplat_mlxcpld_regmap_config); if (IS_ERR(mlxplat_hotplug->regmap)) { err = PTR_ERR(mlxplat_hotplug->regmap); goto fail_platform_mux_register; -- 2.1.4