Received: by 2002:a05:7412:1492:b0:e2:908c:2ebd with SMTP id s18csp347372rdh; Wed, 23 Aug 2023 01:24:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPMl9zOq07pkwJdfmfqCE0uo8TTGU/ONaou9Bz3PeHKwjaoHzS3Dolp732qoJ7yeR9c/Ko X-Received: by 2002:a05:6830:8c:b0:6b9:37e2:76fc with SMTP id a12-20020a056830008c00b006b937e276fcmr14812103oto.30.1692779093229; Wed, 23 Aug 2023 01:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692779093; cv=none; d=google.com; s=arc-20160816; b=u40eURp8riE5GJRsBr/bqDrXkTlJ2algDlouubaGYLHczQPmDfdb9xHIfw7rGmuVqk aR0bo1r5t0jowkozLZhN1S8mh/F5YcgrZjvteNIXoo9ErPOYQ96dg4nqfMUAYKzKSley p3z663nTGsuV2KPh1ybSRHqQYoKpDLicaEeat9QOMvVfj3W/ac91xpReIGJqceeXx8Uo CILzGe2vqYkGOmbLpFxXI1wFcuPgSSMhGK4fjUIF4gN7aToP5Igo+teunmx4cLd4v9p2 XuytSVo8CrVwKFtL5xYq0+TxwXQIuSOsJtTw7i7zM482HYibOk0PG3MaE72xPmVhKHE4 VZbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=lFcGbS1fsSCvU1EyK2WgCeBGK2I/Ga6+Qpj6vUcxMAs=; fh=tkV9Z0tFNySDMr3N6j2XoI5WZOjdiroZmTUTBrlHpQE=; b=pS77rYLifaRaIopz4DStdmxAHBhL4g3SJMchJNnI/s073kwVKL/5QvyqOcu57LnwXL SguFo35VVos8SM4wme+LdUuyMndAELIIkoRplEahczqTTiR3Q8pnz4XLkFUAIVABvmeJ 6S8ZsC4a9sDQhKetIa1ivpkVH8EsETU/PsG/9WIgkKeLpEdadB2c3cWiEjjH1+EqVxXh nSEaja/rXo5pkDAnS53U4kauUyq7QYmZfO9gewvQUPH+tj09mTvJcNoj44ynxAXOa8Gs ypWF1E5eRtdhQOiZ1NaiZ9AEevaIaPfeY3vYpeVT8AC/O4oGUD1x8jxHxBYH09oiYHoK xHYw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a63f503000000b00565f6741e60si11096468pgh.695.2023.08.23.01.24.40; Wed, 23 Aug 2023 01:24:53 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbjHWHhA (ORCPT + 99 others); Wed, 23 Aug 2023 03:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231226AbjHWHg7 (ORCPT ); Wed, 23 Aug 2023 03:36:59 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D1CE4E61; Wed, 23 Aug 2023 00:36:36 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.201]) by gateway (Coremail) with SMTP id _____8BxY_ADt+Vk_SMbAA--.55458S3; Wed, 23 Aug 2023 15:36:35 +0800 (CST) Received: from [10.20.42.201] (unknown [10.20.42.201]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxX88At+VkqyBhAA--.39583S3; Wed, 23 Aug 2023 15:36:33 +0800 (CST) Subject: Re: [PATCH v3 2/2] gpio: loongson: add firmware offset parse support To: andy.shevchenko@gmail.com Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jianmin Lv , wanghongliang@loongson.cn, loongson-kernel@lists.loongnix.cn, zhuyinbo@loongson.cn References: <20230807074043.31288-1-zhuyinbo@loongson.cn> <20230807074043.31288-3-zhuyinbo@loongson.cn> From: Yinbo Zhu Message-ID: <04c72d20-6f4d-b957-ee77-6bcbe279f8b2@loongson.cn> Date: Wed, 23 Aug 2023 15:36:32 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxX88At+VkqyBhAA--.39583S3 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 Hi andy, Sorry, I lost this email due to issues with my company's email server. I will adopt your suggestion in v5 version. ?? 2023/8/15 ????5:48, andy.shevchenko@gmail.com ะด??: > Mon, Aug 07, 2023 at 03:40:43PM +0800, Yinbo Zhu kirjoitti: >> Loongson GPIO controllers come in multiple variants that are compatible >> except for certain register offset values. Add support for device >> properties allowing to specify them in ACPI or DT. > >> + if (device_property_read_u32(dev, "ngpios", &ngpios) || !ngpios) >> + return -EINVAL; >> + >> + ret = DIV_ROUND_UP(ngpios, 8); >> + switch (ret) { >> + case 1 ... 2: >> + io_width = ret; >> + break; >> + case 3 ... 4: >> + io_width = 0x4; >> + break; >> + case 5 ... 8: >> + io_width = 0x8; >> + break; >> + default: >> + dev_err(dev, "unsupported io width\n"); >> + return -EINVAL; >> + } > > Why? We have bgpio_init() handle this. > https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git/commit/?h=gpio/for-next&id=55b2395e4e92adc492c6b30ac109eb78250dcd9d okay, I got it. > > ... > >> + lgpio->chip.can_sleep = 0; > > It's boolean, use boolean initializer. okay, I got it. > > ... > >> + if (lgpio->chip_data->label) >> + lgpio->chip.label = lgpio->chip_data->label; >> + else >> + lgpio->chip.label = kstrdup(to_platform_device(dev)->name, GFP_KERNEL); > > No error check? Not a devm_*() variant, so leaking memory? This code had been removed in v4. > > ... > >> + { >> + .id = "LOON0007", >> + }, > > How does DSDT excerpt for this device look like? LOON0007 and LOON000A are similar, LOON000A is for 2k2000 gpio0. Device (GPO0) { Name (_HID, "LOON000A") // _HID: Hardware ID Name (_ADR, Zero) // _ADR: Address Name (_UID, One) // _UID: Unique ID Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { QWordMemory (ResourceConsumer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite, 0x0000000000000000, // Granularity 0x000000001FE00500, // Range Minimum 0x000000001FE00520, // Range Maximum 0x0000000000000000, // Translation Offset 0x0000000000000021, // Length ,, , AddressRangeMemory, TypeStatic) }) Name (_DSD, Package (0x02) // _DSD: Device-Specific Data { ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties for _DSD */, Package (0x01) { Package (0x02) { "ngpios", 0x20 } } }) } Thanks, Yinbo