Skip to content

Commit

Permalink
sh: Replace an explicit computation by the use of the container_of macro
Browse files Browse the repository at this point in the history
The macro container_of from kernel.h performs the same
pointer arithmetic operation.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
expression mptr;
expression member;
@@

- (void *)((char *)mptr - offsetof(T, member))
+ container_of(mptr, T, member)
// </smpl>

Signed-off-by: Nicolas Palix <npalix@diku.dk>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Nicolas Palix authored and Paul Mundt committed Dec 9, 2009
1 parent 87a705d commit f701b39
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arch/sh/kernel/cpu/irq/ipr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
* for more details.
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/interrupt.h>
#include <linux/topology.h>

static inline struct ipr_desc *get_ipr_desc(unsigned int irq)
{
struct irq_chip *chip = get_irq_chip(irq);
return (void *)((char *)chip - offsetof(struct ipr_desc, chip));
return container_of(chip, struct ipr_desc, chip);
}

static void disable_ipr_irq(unsigned int irq)
Expand Down

0 comments on commit f701b39

Please sign in to comment.