Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8068395imu; Tue, 4 Dec 2018 02:20:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQq7UuXxwnlQ0ysRp2qhKHMZiiMRG8BQD+APvcDAZ3uXEXBM1/8XpzYpitpSkLs021qyuD X-Received: by 2002:a17:902:42e4:: with SMTP id h91mr19854437pld.18.1543918807094; Tue, 04 Dec 2018 02:20:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543918807; cv=none; d=google.com; s=arc-20160816; b=AtgNqQAKeNOt0EamZiEhlGsOsfkZ/S46sIgq6rB3iF/cnEyOqijy5EV4iwVkROV6Ks Kwk5RUndwfv2fsuwsuE4TfFwHaNKglcaGg3ySjN+yg16IQ791O9TXcssmdDtvVlfcopu QECdzEvuxxJe/ZUDuXBP8jhagfF+sbNNL2vc2EnC49h4w6UAU88CQrysMsmCr8LT0ut9 sU54BKXbeIBRB3dSAX0yZNw+Yyikr0d8QUgsiNYHHXc4SwYNwKxQvrAfZ8MzaJYdLbL8 Q1SZSVqZbllfoYp2kn9DWqkgsvW1F8kGiyKEcTG58lFeFcFo9L1emjQI2rxYipq5Wh3Z gx9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=X5VskQPOAp5kwu+RzP8fhniJUSS7yyYwmKUkld91StE=; b=gOfBnoGiy3m3iO3fEb08lORH+csrUSQMemOH+ZX0U5oEwhSdJONgz7r7Ka6yferE+A QVeDiEEJATR4S1BRFHUoygkTM+dswkwQ7eu5x9UKNl0DiEI88DP0y12wOb+pi0OreFxE lYxeckxrJ9x7+mKc3PiEzmt5rI2AU5f/oKMgOzYLlfJ6scRdNmL2PDlmIMoYz4DEutki 2kREfmDwIBdMpUbveKOTyI+aejY4bRKAuUn3vG0NEkL21G9ZfPeQ3PKVJ81tCrFhny+S hxaBMwbm+G5B+IYBYuv7wSzB/6wtI+LoVNQqqVLsG4HO20ube41RAAXs7bT4ADZqGq9a HQ3g== 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 h9si15611475pgb.319.2018.12.04.02.19.51; Tue, 04 Dec 2018 02:20:07 -0800 (PST) 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 S1726132AbeLDKRk (ORCPT + 99 others); Tue, 4 Dec 2018 05:17:40 -0500 Received: from ms.tdt.de ([195.243.126.94]:45837 "EHLO mail.dev.tdt.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbeLDKRk (ORCPT ); Tue, 4 Dec 2018 05:17:40 -0500 Received: from mail.dev.tdt.de (localhost [IPv6:::1]) by mail.dev.tdt.de (Postfix) with ESMTP id 62FD721920; Tue, 4 Dec 2018 10:17:37 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 04 Dec 2018 11:17:37 +0100 From: Florian Eckert To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , Darren Hart , Andy Shevchenko , Eckert.Florian@googlemail.com, Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Platform Driver Subject: Re: [PATCH v5 1/2] gpio: Add driver for PC Engines APU boards In-Reply-To: References: <20181127132508.5501-1-fe@dev.tdt.de> <20181127132508.5501-2-fe@dev.tdt.de> Message-ID: <9102ea20a4f7fec9021ea4e11570865a@dev.tdt.de> X-Sender: fe@dev.tdt.de User-Agent: Roundcube Webmail/1.1.5 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > /* > * Multi-line comments > * have this style > */ fixed >> +#include > > kbuild bot complains for absence of > > #include > > here. > fixed >> +static int gpio_apu_get_dir(struct gpio_chip *chip, unsigned int >> offset) >> +{ >> + u32 val; >> + struct apu_gpio_pdata *apu_gpio = gpiochip_get_data(chip); >> + >> + spin_lock(&apu_gpio->lock); >> + > >> + val = ~ioread32(apu_gpio->addr[offset]); > > There is no need to do ~ under spin lock. > fixed >> + >> + spin_unlock(&apu_gpio->lock); >> + >> + return !!(val & BIT(APU_GPIO_BIT_DIR)); >> +} > >> + if (dmi_check_system(apu3_gpio_dmi_table)) { > > (1) > >> + apu_gpio->addr = devm_kzalloc(&pdev->dev, >> + sizeof(apu3_gpio_offset), >> + GFP_KERNEL); > >> + > > No need to have this blank line. Same for the other cases. > fixed >> + if (!apu_gpio->addr) >> + return -ENOMEM; > >> + } else if (dmi_check_system(apu2_gpio_dmi_table)) { > > (2) > > I think I have already told about (1) and (2). You may create two > callbacks and utilize .callback member in DMI table. > Done but I do not seen any advantage. I used the following driver as basis. https://github.com/torvalds/linux/blob/master/drivers/leds/leds-clevo-mail.c >> + } > >> +static int __init apu_gpio_init(void) >> +{ > >> + if (!(dmi_check_system(apu2_gpio_dmi_table)) && >> + !(dmi_check_system(apu3_gpio_dmi_table))) { >> + pr_err("No PC Engines board detected\n"); >> + return -ENODEV; >> + } > > I don't think we need this. > see below >> +} >> + >> +module_init(apu_gpio_init); >> +module_exit(apu_gpio_exit); > > After removing unneeded checks why not to simple use > module_platform_driver() > ? I have fixed all the above hints from you now but using "module_platform_driver" is no option. I played around with them but the driver does not find any device. So I need the init function to add a platform device. Only if I do this way driver and device will find and match. And I see the gpios under /sys/class/gpio. So I think I need this? I have not find any driver who has the same problems I used the following drivers as my basis: https://github.com/torvalds/linux/blob/master/drivers/leds/leds-apu.c https://github.com/torvalds/linux/blob/master/drivers/leds/leds-clevo-mail.c They all use dmi and need init/exit for platform device register and unregister