Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp476486lqh; Fri, 31 May 2024 07:12:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDYANJ2BqV7PELt9kU68EUyeoYFE0fm2lpK3UQqdXclFJnzNz0ebfh+dZL97u8AzgO2XCZ52c/0iinGAf7Da4NQOk6S1anBMkjUdakZw== X-Google-Smtp-Source: AGHT+IF/2X0N9GPY+6oP12+R9R0YHZhivitzMrByx3vcxQlZroJ4ymlT+j9DeXnXVYrH7F9FMEgy X-Received: by 2002:a17:90b:612:b0:2c1:aa8e:3ca6 with SMTP id 98e67ed59e1d1-2c1dc588b81mr2260693a91.23.1717164774357; Fri, 31 May 2024 07:12:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717164774; cv=pass; d=google.com; s=arc-20160816; b=xEOff8YUOtKqO2YRih1Iv0tsdrYdYzlufeHzdlfc7JKcmqeaU9CQavgJVARfGiNkUq 808bM8wDWa5EZf1Uw0jkymQbjyfW31eR4BTzEzMk2r14potm/oNNFQwMMoBFMDX5q6dz byFMWi2S4fAvjDsLCUNYAaNoIUbaohrISMdU+4jU5Z1/+Cvz5V/eSCXec4CCPCPWpVSL DcBKjIKYueqOFVJF6HsTt9MMloXr0CmSh4JHYp62wbSmM+QhIw6WGTqGO8ZIKv/NPqAE UtfCUI1kS8kyr6KxvLvAx+UobaAnR/ahuMVIvu27hXs/CS9XirhbP1+RkXo4sCAv3Krm MsdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6wTHZBEFwXJhWoEDkPDRuoh0St8wlNAfA/2opNNZCGE=; fh=di0B4Hvta/uovX5wHR4OFbK2OD1hRWy0DYZ1ORh7oz4=; b=VqeaDirNPfC5UBYjF/NTIkIFy/MsSGeYfgDImai06p3VtkzkYz4b5sf3M1bfbL4iN/ 9fD6vRbGXzE1O7T+uOaXM1dxBrvY8hUxyVxcCvjnT052qB+QBbcTjv401hhLYuJGUdzl hSrQMO5FuPowfeAlKCQhTa/0qP7JhHqHwE9PYun6Uyyl00UKH1/H2h/jr3FaqrjA+cM0 VFf0LP0lOWQTLPdK/5sGKlZJFE9aIxmaslm/6Qz4zDM03JsyJGMPY4LzuACj/YpIcjmi kwyPfD6qpGlG6ltUqPhV1QlTc9b/c0LBnGx0eH5Bieb2SNkPY46TsnXHn0pD0+ETNSa5 qTTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kA8tJArf; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-196953-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196953-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a7766776si3545192a91.22.2024.05.31.07.12.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 07:12:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196953-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kA8tJArf; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-196953-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196953-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EDED1290640 for ; Fri, 31 May 2024 14:12:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E6D8172BA2; Fri, 31 May 2024 14:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kA8tJArf" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D07DF1F947; Fri, 31 May 2024 14:12:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717164743; cv=none; b=KCTjcF3WvZo6qRfclhpvUR1KYGAUIdOsK5GQnM14HZeQcEwsYK+MZQzdCQDs2SXjsL3J6Mo4qQW0KcOpdzQ+tSB/rqeqr9Oixl85CHPKjadbC6hXrWb46xcB243XS0/9OprteThVMaUrKRBe2vG8i2gKlTVyW24VpJqQMTrfe70= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717164743; c=relaxed/simple; bh=IHqJ+gtCt73wUC3F7SosO9077s2HWzZcUsKHQ3ldAsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MgW4dF4aLupvJaaxpZEKssnVd0GuzYhlGT883wt2G6AIVwD8vsosDYqnQa4oIEoFzICdkIHJAPCU8BO6c7oNKmuHW1EICY7cDo7ESV5OXHVe2S55BIawesxYGRAl1Enw/ljZBmfcAcyzVbmLPEl9BQxXlfv3Lp8N0Quq2Ti3v7k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kA8tJArf; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-7024426c75dso799329b3a.1; Fri, 31 May 2024 07:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717164741; x=1717769541; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6wTHZBEFwXJhWoEDkPDRuoh0St8wlNAfA/2opNNZCGE=; b=kA8tJArf6pTCdv4tGHQIcqADw5/saTskvru1o3PhGNTJ4kr9lxjOs7dc53TpHgmV4R QGpg+gd6PW0aSrXT4uce6HvHQO+X2AaSbNpJSoPB0CFN5PcMd7HFhVsyj6evGolc5GFf AJsOAHF2f+CJbxMNengKSdggjafHd6v/7xivRyQQaHSF6NiOAFE/4IKuuA9T1hobae3p BcBKBcXGTmcnLryIz4c5BLVzVpBhU4968g3E6K2E7D+r2fqCGZ3b1x7Wa8xcZVTA/MHk t7av1En62yRdf5vbedaU6sGSaqEwyBhfA/hPSfttZM6XuEuXsCIk8/OfdG2lVdXEm6RU i5nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717164741; x=1717769541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6wTHZBEFwXJhWoEDkPDRuoh0St8wlNAfA/2opNNZCGE=; b=qF1EUOXcBDrYRwtXmKtVsNMSw/qQLV0CFwiFQRXjj+S5Elduj0+oUeI3ExQt+ZebnB PUd7vTgjEBHfqUM/7XlP9YAyVvawWm9BVBml+xJXbtwJ1Pfts22alo3nNGZFFtlbbSbH /WYLAmEdmVZRjtsl7FzXzcfvBUNC4lMuhIarMAtFC2PyS7hU0Jf8oAqat17e3axOtEiJ CpYR0XfMy+a9RwH6dymv0218yggTAWlGkNvoRsfldal0Tfcto+0ndDwE1lulZ8cyTtGZ 2ooplrifiCjg3gDibP5M+keUFeepMGOKI+wHK+0u38DPftucNbohd3dGK3wKmy1FBmOd a30Q== X-Forwarded-Encrypted: i=1; AJvYcCXnBqpnwmKtWZO/nIfTTskWpHNbxUcxTYhUwysREHgHq6crDnqBlNtm285bY3tDuHevv6lObcdR6ZEjMFQNcfon6lfn7Tq9vfTuuhd8iFzGnUh8Gb7SOIfYWyE0YkAL5TIfugNEgA== X-Gm-Message-State: AOJu0Yy1vhdSvZVTVUA6biR/SVKmK4z1FEgKyQl77bginJeSGJkkFZES 2tCpHxNaeDjJVT3o8uNt57QhOGPZ5v4R4G1h9YbcHIK1V1zvoNubgYacaJgS6yQ= X-Received: by 2002:a05:6a20:6a25:b0:1ad:7e4d:2ea2 with SMTP id adf61e73a8af0-1b26f0ec300mr2694125637.4.1717164741148; Fri, 31 May 2024 07:12:21 -0700 (PDT) Received: from noel.flets-west.jp ([2405:6586:4480:a10:167:9818:d778:5c14]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70242b057besm1418103b3a.162.2024.05.31.07.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 07:12:20 -0700 (PDT) From: Hironori KIKUCHI To: linux-kernel@vger.kernel.org Cc: Hironori KIKUCHI , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Aleksandr Shubin , Cheo Fusi , linux-pwm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 1/5] pwm: sun20i: Use devm_pwmchip_alloc() helper Date: Fri, 31 May 2024 23:11:33 +0900 Message-ID: <20240531141152.327592-2-kikuchan98@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240531141152.327592-1-kikuchan98@gmail.com> References: <20240531141152.327592-1-kikuchan98@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch fixes a compile error by using the devm_pwmchip_alloc() helper function along the way. Signed-off-by: Hironori KIKUCHI --- drivers/pwm/pwm-sun20i.c | 45 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/pwm/pwm-sun20i.c b/drivers/pwm/pwm-sun20i.c index 3e3b5b138b3..93782023af6 100644 --- a/drivers/pwm/pwm-sun20i.c +++ b/drivers/pwm/pwm-sun20i.c @@ -102,7 +102,7 @@ struct sun20i_pwm_chip { static inline struct sun20i_pwm_chip *to_sun20i_pwm_chip(struct pwm_chip *chip) { - return container_of(chip, struct sun20i_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static inline u32 sun20i_pwm_readl(struct sun20i_pwm_chip *chip, @@ -308,12 +308,31 @@ static void sun20i_pwm_reset_ctrl_release(void *data) static int sun20i_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct sun20i_pwm_chip *sun20i_chip; + const struct sun20i_pwm_data *data; + u32 npwm; int ret; - sun20i_chip = devm_kzalloc(&pdev->dev, sizeof(*sun20i_chip), GFP_KERNEL); - if (!sun20i_chip) - return -ENOMEM; + data = of_device_get_match_data(&pdev->dev); + if (!data) + return -ENODEV; + + ret = of_property_read_u32(pdev->dev.of_node, "allwinner,pwm-channels", &npwm); + if (ret) + npwm = 8; + + if (npwm > 16) { + dev_info(&pdev->dev, "Limiting number of PWM lines from %u to 16", npwm); + npwm = 16; + } + + chip = devm_pwmchip_alloc(&pdev->dev, npwm, sizeof(*sun20i_chip)); + if (IS_ERR(chip)) + return PTR_ERR(chip); + sun20i_chip = to_sun20i_pwm_chip(chip); + + sun20i_chip->data = data; sun20i_chip->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(sun20i_chip->base)) @@ -339,17 +358,6 @@ static int sun20i_pwm_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(sun20i_chip->rst), "failed to get bus reset\n"); - ret = of_property_read_u32(pdev->dev.of_node, "allwinner,pwm-channels", - &sun20i_chip->chip.npwm); - if (ret) - sun20i_chip->chip.npwm = 8; - - if (sun20i_chip->chip.npwm > 16) { - dev_info(&pdev->dev, "Limiting number of PWM lines from %u to 16", - sun20i_chip->chip.npwm); - sun20i_chip->chip.npwm = 16; - } - /* Deassert reset */ ret = reset_control_deassert(sun20i_chip->rst); if (ret) @@ -359,17 +367,14 @@ static int sun20i_pwm_probe(struct platform_device *pdev) if (ret) return ret; - sun20i_chip->chip.dev = &pdev->dev; - sun20i_chip->chip.ops = &sun20i_pwm_ops; + chip->ops = &sun20i_pwm_ops; mutex_init(&sun20i_chip->mutex); - ret = devm_pwmchip_add(&pdev->dev, &sun20i_chip->chip); + ret = devm_pwmchip_add(&pdev->dev, chip); if (ret < 0) return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n"); - platform_set_drvdata(pdev, sun20i_chip); - return 0; } -- 2.45.1