Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752565AbdHHPlo (ORCPT ); Tue, 8 Aug 2017 11:41:44 -0400 Received: from lucky1.263xmail.com ([211.157.147.130]:56988 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752249AbdHHPll (ORCPT ); Tue, 8 Aug 2017 11:41:41 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: david.wu@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: david.wu@rock-chips.com X-UNIQUE-TAG: <4af830bada3bb225da5f7cd5d9a8cafd> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Subject: Re: [PATCH v2 3/7] pwm: rockchip: Remove the dumplicate rockchip_pwm_ops ops To: Boris Brezillon 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 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> <20170802134011.1124f1dd@bbrezillon> <6d1f60ee-2402-5ee0-54f6-9521c039c36c@rock-chips.com> <20170804090935.6aba3351@bbrezillon> From: "David.Wu" Message-ID: <78121683-137a-eb5c-c447-e763b18ccd12@rock-chips.com> Date: Tue, 8 Aug 2017 23:41:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170804090935.6aba3351@bbrezillon> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1926 Lines: 59 Hi Boris, 在 2017/8/4 15:09, Boris Brezillon 写道: > On Fri, 4 Aug 2017 10:38:26 +0800 > "David.Wu" wrote: > >> Hi Boris, >> >> 在 2017/8/2 19:40, Boris Brezillon 写道: >>> 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); >> >> I think we should keep the data members in the rockchip_pwm_data,like >> supports_polarity and regs... >> >> The supports_polarity is needed for of_pwm_n_cells when pwm registered. >> And the other data members is helpful for us to use common code. >> >> It's okay for just define 3 different pwm_ops (one for each IP), but >> they are with other data members in the struct of rockchip_pwm_data. >> > > I think we could even get rid of the other fields in rockchip_pwm_data, > but ok, let's do that. I use the same pwm ops for each IP at V3's patch, but defined 3 different rockchip_pwm_data for use. I think this might look more clean. > > >