Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753211AbdHBLk0 convert rfc822-to-8bit (ORCPT ); Wed, 2 Aug 2017 07:40:26 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:43996 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753084AbdHBLkY (ORCPT ); Wed, 2 Aug 2017 07:40:24 -0400 Date: Wed, 2 Aug 2017 13:40:11 +0200 From: Boris Brezillon To: "David.Wu" Cc: thierry.reding@gmail.com, heiko@sntech.de, robh+dt@kernel.org, catalin.marinas@arm.com, briannorris@chromium.org, dianders@chromium.org, mark.rutland@arm.com, huangtao@rock-chips.com, linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/7] pwm: rockchip: Remove the dumplicate rockchip_pwm_ops ops Message-ID: <20170802134011.1124f1dd@bbrezillon> In-Reply-To: References: <1499486629-9659-1-git-send-email-david.wu@rock-chips.com> <1499486629-9659-4-git-send-email-david.wu@rock-chips.com> <20170802105902.2d137072@bbrezillon> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1759 Lines: 50 On Wed, 2 Aug 2017 19:31:57 +0800 "David.Wu" wrote: > Hi Boris, > > 在 2017/8/2 16:59, Boris Brezillon 写道: > > Actually, when I suggested to just implement ->apply_state() and be > > done with all other fields I was thinking that you could get rid of > > this rockchip_pwm_data struct entirely and just have 3 different > > pwm_ops. You seem to take the other direction here: you're removing > > rockchip_pwm_ops_v1 and renaming rockchip_pwm_ops_v2 into > > rockchip_pwm_ops. > > Yes, i really didn't understand exactly what you mean. > Your mean is that remove the set_enable, get_state and other hooks, > then use the pwm_ops instead of them, which has 3 different version, and > implement the pwm_ops's functions like apply(), enable(), get_state() > and others...? > Yep, just define 3 different pwm_ops (one for each IP), each of them implementing ->apply() and ->get_state() and that's all. Something like: static const struct pwm_ops rockchip_pwm_ops_v1 = { .get_state = rockchip_pwm_v1_get_state, .apply = rockchip_pwm_v1_apply, .owner = THIS_MODULE, }; static const struct pwm_ops rockchip_pwm_ops_v2 = { .get_state = rockchip_pwm_v2_get_state, .apply = rockchip_pwm_v2_apply, .owner = THIS_MODULE, }; static const struct pwm_ops rockchip_pwm_ops_vop = { .get_state = rockchip_pwm_vop_get_state, .apply = rockchip_pwm_vop_apply, .owner = THIS_MODULE, }; static const struct of_device_id rockchip_pwm_dt_ids[] = { { .compatible = "rockchip,rk2928-pwm", .data = &rockchip_pwm_ops_v1 }, { .compatible = "rockchip,rk3288-pwm", .data = &rockchip_pwm_ops_v2 }, { .compatible = "rockchip,vop-pwm", .data = &rockchip_pwm_ops_vop }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids);