Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7770123rwb; Wed, 23 Nov 2022 10:28:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6g82/2NeqKKIpTQ3AlAoxhx1rml2CYpkn8MZXvMTFa4PYbS5c8uxT5hGvKit8WAw2eQ5h3 X-Received: by 2002:a17:902:ca04:b0:175:105a:3087 with SMTP id w4-20020a170902ca0400b00175105a3087mr10498884pld.65.1669228122070; Wed, 23 Nov 2022 10:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669228122; cv=none; d=google.com; s=arc-20160816; b=bUDhvzK7z9KZlvW1rnGnq9Iuvyr15vSAiM5pxLqKKGGaoNKo/2objgegO1Eiu3G9si gK1J0M5USImwZpKtZoa4c3WUBIVtmx1pjGpnrrgMEp1bzZ1poVg4g3+paeyAcXDFcgM/ ULzC4HjN/pP8T4c0pETC92L8tmS3NpJ88kAAXQgluzWDFhoLhRm2b9kLLcSJz/ZJsFYi UtH+5kbBhhXx4llRrBplFt3IXzSNq2QrD5t6s7xnzyq9n/Mba+PPkzdswfF2HE+iJ+cP 3utNiAwBN1V5oYGN/+Xkl6MnM8kVMMkupvsHbsleY2SGytcc5tdf/d1dbVT50UO9dK+t Tlyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qJB7KYQjuF379hppSkyq6DEdN4KzLb+30gP/Hi4lFOU=; b=JSuNxYvBWAwlV6u2mLAAp+Z7tHlRnlB726vg9GwX35q3c35bEODasiCHJe/3LILCAX tsJsWSI2qS2yX1KBMhG5Sb8MTZWqmaM5lojjVcNLQAZAiXYVJ0OZlDoKS44ATzlf8zk1 MZ0eTcUgthYgJSD6j3Q3oOeljxKTcNjS2OnYlewP8zjgVi2cMF9o9mFFhxV7aMP/eaGe Ckulp040g2Dkl/BDrP+8XfpARidfrYtWrBBNOOTAl5LjrlyLz2sB2OH8rLPVCuRB6CDV FJQnl2VL2uIjQPS7O+Kye8udxjfqNrwJKFqhlrAyB4x21jd4sDV3F037WORAVW9EpU2Y xjZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="SC/3kcpU"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x32-20020a056a0018a000b005737d1acd02si11495007pfh.125.2022.11.23.10.28.30; Wed, 23 Nov 2022 10:28:42 -0800 (PST) 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; dkim=pass header.i=@intel.com header.s=Intel header.b="SC/3kcpU"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237457AbiKWRoG (ORCPT + 89 others); Wed, 23 Nov 2022 12:44:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235568AbiKWRoF (ORCPT ); Wed, 23 Nov 2022 12:44:05 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 271998CB8D; Wed, 23 Nov 2022 09:44:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669225444; x=1700761444; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=sQO+k9nuBFGZkzf+UuTqUqVli514lLoA06x9Xr2TrPk=; b=SC/3kcpUITjsa0IlXpVAuFxMfBD1+Y4Mcsmq6qUF7kYmukiBHi5ZA4kl 8DBM1xRdHjjH/Lw7JEXrk32q+PHa7lrlga93mBE/ARHBy7YN0kTaQTxvb GMnKMOw71nK54rAkpXnd2wLY+rXaROwf3x6kEUvbQKbZtU4YDoQoa7mEq 3IPXi17pQSC1lxxBpzxtsqgjfhs8pw2Fkd9INhJNlAL6uVrk98aSv5nMU VpGuuajO243Xs81RuREKQ5Ks1gMKDdiuDIYOzGZI2BdAS8lMSUw7bGyDg uQ/1viwYgi5d0Ikw5AI6tMiHfodLLcCZPCDOgxH+7clTYd1Fxsxqcs6MD Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="294511949" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="294511949" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 09:44:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="766805287" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="766805287" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga004.jf.intel.com with ESMTP; 23 Nov 2022 09:44:01 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oxtmx-00GOBT-1p; Wed, 23 Nov 2022 19:43:59 +0200 Date: Wed, 23 Nov 2022 19:43:59 +0200 From: Andy Shevchenko To: William Breathitt Gray Cc: linus.walleij@linaro.org, brgl@bgdev.pl, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, michael@walle.cc, broonie@kernel.org Subject: Re: [PATCH v3 7/9] gpio: 104-dio-48e: Migrate to regmap API Message-ID: References: <79705f8932321afd05df52156ef149dc1c9c632c.1669100542.git.william.gray@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <79705f8932321afd05df52156ef149dc1c9c632c.1669100542.git.william.gray@linaro.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 On Tue, Nov 22, 2022 at 02:11:04AM -0500, William Breathitt Gray wrote: > The regmap API supports IO port accessors so we can take advantage of > regmap abstractions rather than handling access to the device registers > directly in the driver. The 104-dio-48e module is migrated to the new > i8255 library interface leveraging the gpio-regmap API. Reviewed-by: Andy Shevchenko (see also below) > Suggested-by: Andy Shevchenko > Signed-off-by: William Breathitt Gray > --- > drivers/gpio/gpio-104-dio-48e.c | 147 ++------------------------------ > 1 file changed, 7 insertions(+), 140 deletions(-) > > diff --git a/drivers/gpio/gpio-104-dio-48e.c b/drivers/gpio/gpio-104-dio-48e.c > index fcee3dc81902..64f4044150b7 100644 > --- a/drivers/gpio/gpio-104-dio-48e.c > +++ b/drivers/gpio/gpio-104-dio-48e.c > @@ -9,7 +9,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -42,90 +41,6 @@ MODULE_PARM_DESC(irq, "ACCES 104-DIO-48E interrupt line numbers"); > > #define DIO48E_NUM_PPI 2 > > -/** > - * struct dio48e_reg - device register structure > - * @ppi: Programmable Peripheral Interface groups > - */ > -struct dio48e_reg { > - struct i8255 ppi[DIO48E_NUM_PPI]; > -}; > - > -/** > - * struct dio48e_gpio - GPIO device private data structure > - * @chip: instance of the gpio_chip > - * @ppi_state: PPI device states > - * @reg: I/O address offset for the device registers > - */ > -struct dio48e_gpio { > - struct gpio_chip chip; > - struct i8255_state ppi_state[DIO48E_NUM_PPI]; > - struct dio48e_reg __iomem *reg; > -}; > - > -static int dio48e_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - if (i8255_get_direction(dio48egpio->ppi_state, offset)) > - return GPIO_LINE_DIRECTION_IN; > - > - return GPIO_LINE_DIRECTION_OUT; > -} > - > -static int dio48e_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - i8255_direction_input(dio48egpio->reg->ppi, dio48egpio->ppi_state, > - offset); > - > - return 0; > -} > - > -static int dio48e_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, > - int value) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - i8255_direction_output(dio48egpio->reg->ppi, dio48egpio->ppi_state, > - offset, value); > - > - return 0; > -} > - > -static int dio48e_gpio_get(struct gpio_chip *chip, unsigned int offset) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - return i8255_get(dio48egpio->reg->ppi, offset); > -} > - > -static int dio48e_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, > - unsigned long *bits) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - i8255_get_multiple(dio48egpio->reg->ppi, mask, bits, chip->ngpio); > - > - return 0; > -} > - > -static void dio48e_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - i8255_set(dio48egpio->reg->ppi, dio48egpio->ppi_state, offset, value); > -} > - > -static void dio48e_gpio_set_multiple(struct gpio_chip *chip, > - unsigned long *mask, unsigned long *bits) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); > - > - i8255_set_multiple(dio48egpio->reg->ppi, dio48egpio->ppi_state, mask, > - bits, chip->ngpio); > -} > - > static const struct regmap_range dio48e_wr_ranges[] = { > regmap_reg_range(0x0, 0x9), regmap_reg_range(0xB, 0xB), > regmap_reg_range(0xD, 0xD), regmap_reg_range(0xF, 0xF), > @@ -237,35 +152,10 @@ static const char *dio48e_names[DIO48E_NGPIO] = { > "PPI Group 1 Port C 5", "PPI Group 1 Port C 6", "PPI Group 1 Port C 7" > }; > > -static int dio48e_irq_init_hw(struct gpio_chip *gc) > -{ > - struct dio48e_gpio *const dio48egpio = gpiochip_get_data(gc); > - > - /* Disable IRQ by default */ > - ioread8(&dio48egpio->reg->enable_interrupt); > - > - return 0; > -} > - > -static void dio48e_init_ppi(struct i8255 __iomem *const ppi, > - struct i8255_state *const ppi_state) > -{ > - const unsigned long ngpio = 24; > - const unsigned long mask = GENMASK(ngpio - 1, 0); > - const unsigned long bits = 0; > - unsigned long i; > - > - /* Initialize all GPIO to output 0 */ > - for (i = 0; i < DIO48E_NUM_PPI; i++) { > - i8255_mode0_output(&ppi[i]); > - i8255_set_multiple(&ppi[i], &ppi_state[i], &mask, &bits, ngpio); > - } > -} > - > static int dio48e_probe(struct device *dev, unsigned int id) > { > - struct dio48e_gpio *dio48egpio; > const char *const name = dev_name(dev); > + struct i8255_regmap_config config = {0}; {} will work okay. > void __iomem *regs; > struct regmap *map; > unsigned int val; > @@ -274,10 +164,6 @@ static int dio48e_probe(struct device *dev, unsigned int id) > unsigned int irq_mask; > struct regmap_irq_chip_data *chip_data; > > - dio48egpio = devm_kzalloc(dev, sizeof(*dio48egpio), GFP_KERNEL); > - if (!dio48egpio) > - return -ENOMEM; > - > if (!devm_request_region(dev, base[id], DIO48E_EXTENT, name)) { > dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", > base[id], base[id] + DIO48E_EXTENT); > @@ -287,7 +173,6 @@ static int dio48e_probe(struct device *dev, unsigned int id) > regs = devm_ioport_map(dev, base[id], DIO48E_EXTENT); > if (!regs) > return -ENOMEM; > - dio48egpio->reg = regs; > > map = devm_regmap_init_mmio(dev, regs, &dio48e_regmap_config); > if (IS_ERR(map)) > @@ -324,31 +209,13 @@ static int dio48e_probe(struct device *dev, unsigned int id) > return err; > } > > - dio48egpio->chip.label = name; > - dio48egpio->chip.parent = dev; > - dio48egpio->chip.owner = THIS_MODULE; > - dio48egpio->chip.base = -1; > - dio48egpio->chip.ngpio = DIO48E_NGPIO; > - dio48egpio->chip.names = dio48e_names; > - dio48egpio->chip.get_direction = dio48e_gpio_get_direction; > - dio48egpio->chip.direction_input = dio48e_gpio_direction_input; > - dio48egpio->chip.direction_output = dio48e_gpio_direction_output; > - dio48egpio->chip.get = dio48e_gpio_get; > - dio48egpio->chip.get_multiple = dio48e_gpio_get_multiple; > - dio48egpio->chip.set = dio48e_gpio_set; > - dio48egpio->chip.set_multiple = dio48e_gpio_set_multiple; > - > - i8255_state_init(dio48egpio->ppi_state, DIO48E_NUM_PPI); > - dio48e_init_ppi(dio48egpio->reg->ppi, dio48egpio->ppi_state); > - > - err = devm_gpiochip_add_data(dev, &dio48egpio->chip, dio48egpio); > - if (err) { > - dev_err(dev, "GPIO registering failed (%d)\n", err); > - return err; > - } > + config.parent = dev; > + config.map = map; > + config.num_ppi = DIO48E_NUM_PPI; > + config.names = dio48e_names; > + config.domain = regmap_irq_get_domain(chip_data); > > - return gpiochip_irqchip_add_domain(&dio48egpio->chip, > - regmap_irq_get_domain(chip_data)); > + return devm_i8255_regmap_register(dev, &config); > } > > static struct isa_driver dio48e_driver = { > -- > 2.38.1 > -- With Best Regards, Andy Shevchenko