Skip to content

Commit 43e8019

Browse files
paulkocialkowskimchehab
authored andcommitted
media: sun6i-csi: Tidy up platform code
Various renames, variables lowering and other cosmetic changes in the platform-support code. No functional change intended. Signed-off-by: Paul Kocialkowski <[email protected]> Reviewed-by: Maxime Ripard <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 0b11253 commit 43e8019

File tree

2 files changed

+56
-46
lines changed

2 files changed

+56
-46
lines changed

drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -153,25 +153,25 @@ int sun6i_csi_set_power(struct sun6i_csi_device *csi_dev, bool enable)
153153
if (!enable) {
154154
regmap_update_bits(regmap, CSI_EN_REG, CSI_EN_CSI_EN, 0);
155155

156-
clk_disable_unprepare(csi_dev->clk_ram);
156+
clk_disable_unprepare(csi_dev->clock_ram);
157157
if (of_device_is_compatible(dev->of_node,
158158
"allwinner,sun50i-a64-csi"))
159-
clk_rate_exclusive_put(csi_dev->clk_mod);
160-
clk_disable_unprepare(csi_dev->clk_mod);
159+
clk_rate_exclusive_put(csi_dev->clock_mod);
160+
clk_disable_unprepare(csi_dev->clock_mod);
161161
reset_control_assert(csi_dev->reset);
162162
return 0;
163163
}
164164

165-
ret = clk_prepare_enable(csi_dev->clk_mod);
165+
ret = clk_prepare_enable(csi_dev->clock_mod);
166166
if (ret) {
167167
dev_err(csi_dev->dev, "Enable csi clk err %d\n", ret);
168168
return ret;
169169
}
170170

171171
if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi"))
172-
clk_set_rate_exclusive(csi_dev->clk_mod, 300000000);
172+
clk_set_rate_exclusive(csi_dev->clock_mod, 300000000);
173173

174-
ret = clk_prepare_enable(csi_dev->clk_ram);
174+
ret = clk_prepare_enable(csi_dev->clock_ram);
175175
if (ret) {
176176
dev_err(csi_dev->dev, "Enable clk_dram_csi clk err %d\n", ret);
177177
goto clk_mod_disable;
@@ -188,11 +188,11 @@ int sun6i_csi_set_power(struct sun6i_csi_device *csi_dev, bool enable)
188188
return 0;
189189

190190
clk_ram_disable:
191-
clk_disable_unprepare(csi_dev->clk_ram);
191+
clk_disable_unprepare(csi_dev->clock_ram);
192192
clk_mod_disable:
193193
if (of_device_is_compatible(dev->of_node, "allwinner,sun50i-a64-csi"))
194-
clk_rate_exclusive_put(csi_dev->clk_mod);
195-
clk_disable_unprepare(csi_dev->clk_mod);
194+
clk_rate_exclusive_put(csi_dev->clock_mod);
195+
clk_disable_unprepare(csi_dev->clock_mod);
196196
return ret;
197197
}
198198

@@ -773,12 +773,11 @@ static int sun6i_csi_v4l2_init(struct sun6i_csi_device *csi_dev)
773773
return ret;
774774
}
775775

776-
/* -----------------------------------------------------------------------------
777-
* Resources and IRQ
778-
*/
779-
static irqreturn_t sun6i_csi_isr(int irq, void *dev_id)
776+
/* Platform */
777+
778+
static irqreturn_t sun6i_csi_interrupt(int irq, void *private)
780779
{
781-
struct sun6i_csi_device *csi_dev = (struct sun6i_csi_device *)dev_id;
780+
struct sun6i_csi_device *csi_dev = private;
782781
struct regmap *regmap = csi_dev->regmap;
783782
u32 status;
784783

@@ -813,73 +812,82 @@ static const struct regmap_config sun6i_csi_regmap_config = {
813812
.max_register = 0x9c,
814813
};
815814

816-
static int sun6i_csi_resource_request(struct sun6i_csi_device *csi_dev,
817-
struct platform_device *pdev)
815+
static int sun6i_csi_resources_setup(struct sun6i_csi_device *csi_dev,
816+
struct platform_device *platform_dev)
818817
{
818+
struct device *dev = csi_dev->dev;
819819
void __iomem *io_base;
820820
int ret;
821821
int irq;
822822

823-
io_base = devm_platform_ioremap_resource(pdev, 0);
823+
/* Registers */
824+
825+
io_base = devm_platform_ioremap_resource(platform_dev, 0);
824826
if (IS_ERR(io_base))
825827
return PTR_ERR(io_base);
826828

827-
csi_dev->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", io_base,
829+
csi_dev->regmap = devm_regmap_init_mmio_clk(dev, "bus", io_base,
828830
&sun6i_csi_regmap_config);
829831
if (IS_ERR(csi_dev->regmap)) {
830-
dev_err(&pdev->dev, "Failed to init register map\n");
832+
dev_err(dev, "failed to init register map\n");
831833
return PTR_ERR(csi_dev->regmap);
832834
}
833835

834-
csi_dev->clk_mod = devm_clk_get(&pdev->dev, "mod");
835-
if (IS_ERR(csi_dev->clk_mod)) {
836-
dev_err(&pdev->dev, "Unable to acquire csi clock\n");
837-
return PTR_ERR(csi_dev->clk_mod);
836+
/* Clocks */
837+
838+
csi_dev->clock_mod = devm_clk_get(dev, "mod");
839+
if (IS_ERR(csi_dev->clock_mod)) {
840+
dev_err(dev, "failed to acquire module clock\n");
841+
return PTR_ERR(csi_dev->clock_mod);
838842
}
839843

840-
csi_dev->clk_ram = devm_clk_get(&pdev->dev, "ram");
841-
if (IS_ERR(csi_dev->clk_ram)) {
842-
dev_err(&pdev->dev, "Unable to acquire dram-csi clock\n");
843-
return PTR_ERR(csi_dev->clk_ram);
844+
csi_dev->clock_ram = devm_clk_get(dev, "ram");
845+
if (IS_ERR(csi_dev->clock_ram)) {
846+
dev_err(dev, "failed to acquire ram clock\n");
847+
return PTR_ERR(csi_dev->clock_ram);
844848
}
845849

846-
csi_dev->reset = devm_reset_control_get_shared(&pdev->dev, NULL);
850+
/* Reset */
851+
852+
csi_dev->reset = devm_reset_control_get_shared(dev, NULL);
847853
if (IS_ERR(csi_dev->reset)) {
848-
dev_err(&pdev->dev, "Cannot get reset controller\n");
854+
dev_err(dev, "failed to acquire reset\n");
849855
return PTR_ERR(csi_dev->reset);
850856
}
851857

852-
irq = platform_get_irq(pdev, 0);
858+
/* Interrupt */
859+
860+
irq = platform_get_irq(platform_dev, 0);
853861
if (irq < 0)
854862
return -ENXIO;
855863

856-
ret = devm_request_irq(&pdev->dev, irq, sun6i_csi_isr, 0,
857-
SUN6I_CSI_NAME, csi_dev);
864+
ret = devm_request_irq(dev, irq, sun6i_csi_interrupt, 0, SUN6I_CSI_NAME,
865+
csi_dev);
858866
if (ret) {
859-
dev_err(&pdev->dev, "Cannot request csi IRQ\n");
867+
dev_err(dev, "failed to request interrupt\n");
860868
return ret;
861869
}
862870

863871
return 0;
864872
}
865873

866-
static int sun6i_csi_probe(struct platform_device *pdev)
874+
static int sun6i_csi_probe(struct platform_device *platform_dev)
867875
{
868876
struct sun6i_csi_device *csi_dev;
877+
struct device *dev = &platform_dev->dev;
869878
int ret;
870879

871-
csi_dev = devm_kzalloc(&pdev->dev, sizeof(*csi_dev), GFP_KERNEL);
880+
csi_dev = devm_kzalloc(dev, sizeof(*csi_dev), GFP_KERNEL);
872881
if (!csi_dev)
873882
return -ENOMEM;
874883

875-
csi_dev->dev = &pdev->dev;
884+
csi_dev->dev = &platform_dev->dev;
885+
platform_set_drvdata(platform_dev, csi_dev);
876886

877-
ret = sun6i_csi_resource_request(csi_dev, pdev);
887+
ret = sun6i_csi_resources_setup(csi_dev, platform_dev);
878888
if (ret)
879889
return ret;
880890

881-
platform_set_drvdata(pdev, csi_dev);
882-
883891
return sun6i_csi_v4l2_init(csi_dev);
884892
}
885893

@@ -900,16 +908,18 @@ static const struct of_device_id sun6i_csi_of_match[] = {
900908
{ .compatible = "allwinner,sun50i-a64-csi", },
901909
{},
902910
};
911+
903912
MODULE_DEVICE_TABLE(of, sun6i_csi_of_match);
904913

905914
static struct platform_driver sun6i_csi_platform_driver = {
906-
.probe = sun6i_csi_probe,
907-
.remove = sun6i_csi_remove,
908-
.driver = {
909-
.name = SUN6I_CSI_NAME,
910-
.of_match_table = of_match_ptr(sun6i_csi_of_match),
915+
.probe = sun6i_csi_probe,
916+
.remove = sun6i_csi_remove,
917+
.driver = {
918+
.name = SUN6I_CSI_NAME,
919+
.of_match_table = of_match_ptr(sun6i_csi_of_match),
911920
},
912921
};
922+
913923
module_platform_driver(sun6i_csi_platform_driver);
914924

915925
MODULE_DESCRIPTION("Allwinner A31 Camera Sensor Interface driver");

drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ struct sun6i_csi_device {
5151
struct sun6i_video video;
5252

5353
struct regmap *regmap;
54-
struct clk *clk_mod;
55-
struct clk *clk_ram;
54+
struct clk *clock_mod;
55+
struct clk *clock_ram;
5656
struct reset_control *reset;
5757

5858
int planar_offset[3];

0 commit comments

Comments
 (0)