clk: max77686: Remove unnecessary NULL checking for container_of()
PATCH 1/1 clk: max77686: Remove unnecessary NULL checking for container_of()
container_of() never returns NULL, thus remove the NULL checking for it. Also rename get_max77686_clk() to to_max77686_clk() for better readability.
Signed-off-by Axel Lin <[email protected]>
--- drivers/clk/clk-max77686.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)
drivers/clk/clk-max77686.c +8 -22
@@ -44,48 +44,34 @@ struct max77686_clk {struct clk_lookup *lookup; }; -static struct max77686_clk *get_max77686_clk (struct clk_hw *hw) +static struct max77686_clk *to_max77686_clk (struct clk_hw *hw) { return container_of(hw, struct max77686_clk, hw); }static int max77686_clk_prepare (struct clk_hw *hw) { -struct max77686_clk *max77686; -int ret; - - max77686 =get_max77686_clk (hw); -if (!max77686) -return -ENOMEM ; - - ret =regmap_update_bits (max77686->iodev->regmap, -MAX77686_REG_32KHZ , max77686->mask, max77686->mask); +struct max77686_clk *max77686 =to_max77686_clk (hw); -return ret; +return regmap_update_bits (max77686->iodev->regmap, +MAX77686_REG_32KHZ , max77686->mask, + max77686->mask); }static void max77686_clk_unprepare (struct clk_hw *hw) { -struct max77686_clk *max77686; - - max77686 =get_max77686_clk (hw); -if (!max77686) -return ; +struct max77686_clk *max77686 =to_max77686_clk (hw);regmap_update_bits (max77686->iodev->regmap, -MAX77686_REG_32KHZ , max77686->mask, ~max77686->mask); +MAX77686_REG_32KHZ , max77686->mask,0 ); }static int max77686_clk_is_enabled (struct clk_hw *hw) { -struct max77686_clk *max77686; +struct max77686_clk *max77686 =to_max77686_clk (hw);int ret;u32 val; - max77686 =get_max77686_clk (hw); -if (!max77686) -return -ENOMEM ; - ret =regmap_read (max77686->iodev->regmap,MAX77686_REG_32KHZ , &val);
Signature · 1 line
1.7.9.5
PATCH 1/1 clk: max77686: Remove unnecessary NULL checking for container_of()
Quoting Axel Lin (2012-12-17 23:54:52)
Quoted 43 lines
container_of()never returns NULL, thus remove the NULL checking for it. Also renameget_max77686_clk()toto_max77686_clk()for better readability.Signed-off-by Axel Lin <[email protected]>--- drivers/clk/clk-max77686.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-)drivers/clk/clk-max77686.c +5
-11@@ -44,48 +44,34 @@ struct max77686_clk {struct clk_lookup *lookup; }; -static struct max77686_clk *get_max77686_clk (struct clk_hw *hw) +static struct max77686_clk *to_max77686_clk (struct clk_hw *hw) { return container_of(hw, struct max77686_clk, hw); }static int max77686_clk_prepare (struct clk_hw *hw) { -struct max77686_clk *max77686; -int ret; - - max77686 =get_max77686_clk (hw); -if (!max77686) -return -ENOMEM ; - - ret =regmap_update_bits (max77686->iodev->regmap, -MAX77686_REG_32KHZ , max77686->mask, max77686->mask); +struct max77686_clk *max77686 =to_max77686_clk (hw); -return ret; +return regmap_update_bits (max77686->iodev->regmap, +MAX77686_REG_32KHZ , max77686->mask, + max77686->mask); }static void max77686_clk_unprepare (struct clk_hw *hw) {
drivers/clk/clk-max77686.c struct max77686_clk { · line 66
Quoted 10 lines
drivers/clk/clk-max77686.c +2
-6-struct max77686_clk *max77686; - - max77686 =get_max77686_clk (hw); -if (!max77686) -return ; +struct max77686_clk *max77686 =to_max77686_clk (hw);regmap_update_bits (max77686->iodev->regmap, -MAX77686_REG_32KHZ , max77686->mask, ~max77686->mask); +MAX77686_REG_32KHZ , max77686->mask,0 );
Looks like the change to ~max77686->mask snuck in. It is not mentioned in the changelog. Care to respin the patch without the change?
Thanks,
Mike
Quoted 18 lines
drivers/clk/clk-max77686.c +1
-5}static int max77686_clk_is_enabled (struct clk_hw *hw) { -struct max77686_clk *max77686; +struct max77686_clk *max77686 =to_max77686_clk (hw);int ret;u32 val; - max77686 =get_max77686_clk (hw); -if (!max77686) -return -ENOMEM ; - ret =regmap_read (max77686->iodev->regmap,MAX77686_REG_32KHZ , &val);Signature · 1 line
1.7.9.5