diff for duplicates of <20100727123647.0a3b8832@wker> diff --git a/a/1.txt b/N1/1.txt index eb722cd..ea29978 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,50 +1,46 @@ Hi Grant, On Sun, 25 Jul 2010 01:42:23 -0600 -Grant Likely <grant.likely@secretlab.ca> wrote: +Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote: ... > Hi Anatolij, ->=20 -> Finally got some time tonight to properly dig into this patch. Comments = -below. +> +> Finally got some time tonight to properly dig into this patch. Comments below. Thanks for review and comments! My reply below. ... -> > + =A0 =A0 =A0 nfc@40000000 { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc5121-nfc"; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x40000000 0x100000>; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <0x6 0x8>; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&ipic>; ->=20 +> > + nfc@40000000 { +> > + compatible = "fsl,mpc5121-nfc"; +> > + reg = <0x40000000 0x100000>; +> > + interrupts = <0x6 0x8>; +> > + interrupt-parent = <&ipic>; +> > This device tree can be less verbose if you remove the > interrupt-parent property from all the nodes, and have a single -> interrupt-parent =3D <&ipic>; in the root node. Nodes inherit the +> interrupt-parent = <&ipic>; in the root node. Nodes inherit the > interrupt-parent from their (grand-)parents. Fixed in next patch version to use interrupt-parent in root node only. ... -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mdio@2800 { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc51= -21-fec-mdio"; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x2800 0x200>; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 phy: ethernet-phy@0 { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <= -0x1f>; ->=20 +> > + mdio@2800 { +> > + compatible = "fsl,mpc5121-fec-mdio"; +> > + reg = <0x2800 0x200>; +> > + #address-cells = <1>; +> > + #size-cells = <0>; +> > + phy: ethernet-phy@0 { +> > + reg = <0x1f>; +> > For completeness, phy should have a compatible property. Added in next patch version. ... -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spi@11900 { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D "fsl,mpc51= -21-psc-spi", "fsl,mpc5121-psc"; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <9>; ->=20 +> > + spi@11900 { +> > + compatible = "fsl,mpc5121-psc-spi", "fsl,mpc5121-psc"; +> > + cell-index = <9>; +> > Try to drop the cell-index properties. They are almost always misused. Removing cell-index would require changing the spi driver's probe. @@ -57,49 +53,45 @@ mode. This would work for all 12 PSC SPI controllers of mpc5121. ... > > +static int pdm360ng_get_pendown_state(void) > > +{ -> > + =A0 =A0 =A0 u32 reg; +> > + u32 reg; > > + -> > + =A0 =A0 =A0 reg =3D in_be32((u32 *)(pdm360ng_gpio_base + 0xc)); -> > + =A0 =A0 =A0 if (reg & 0x40) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 setbits32((u32 *)(pdm360ng_gpio_base + 0x= -c), 0x40); +> > + reg = in_be32((u32 *)(pdm360ng_gpio_base + 0xc)); +> > + if (reg & 0x40) +> > + setbits32((u32 *)(pdm360ng_gpio_base + 0xc), 0x40); > > + -> > + =A0 =A0 =A0 reg =3D in_be32((u32 *)(pdm360ng_gpio_base + 0x8)); ->=20 +> > + reg = in_be32((u32 *)(pdm360ng_gpio_base + 0x8)); +> > (u32*) casts are unnecessary and can be removed. Fixed. > > + -> > + =A0 =A0 =A0 /* return 1 if pen is down */ -> > + =A0 =A0 =A0 return reg & 0x40 ? 0 : 1; ->=20 -> return reg & 0x40 =3D=3D 0; +> > + /* return 1 if pen is down */ +> > + return reg & 0x40 ? 0 : 1; +> +> return reg & 0x40 == 0; Fixed. ... > > +static int __init pdm360ng_penirq_init(void) > > +{ -> > + =A0 =A0 =A0 struct device_node *np; -> > + =A0 =A0 =A0 struct resource r; +> > + struct device_node *np; +> > + struct resource r; > > + -> > + =A0 =A0 =A0 np =3D of_find_compatible_node(NULL, NULL, "fsl,mpc5121-g= -pio"); -> > + =A0 =A0 =A0 if (!np) { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_err("%s: Can't find 'mpc5121-gpio' nod= -e\n", __func__); -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1; -> > + =A0 =A0 =A0 } ->=20 +> > + np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-gpio"); +> > + if (!np) { +> > + pr_err("%s: Can't find 'mpc5121-gpio' node\n", __func__); +> > + return -1; +> > + } +> > return -ENODEV; Ok, fixed also. ... -> > + =A0 =A0 =A0 pdm360ng_gpio_base =3D ioremap(r.start, resource_size(&r)= -); ->=20 +> > + pdm360ng_gpio_base = ioremap(r.start, resource_size(&r)); +> > Or you could have simply used of_iomap() to eliminate some code. of_iomap() is used in next patch version. @@ -107,68 +99,64 @@ of_iomap() is used in next patch version. ... > > +static int __init pdm360ng_touchscreen_init(void) > > +{ -> > + =A0 =A0 =A0 struct device_node *np; -> > + =A0 =A0 =A0 struct of_device *of_dev; -> > + =A0 =A0 =A0 struct spi_board_info info; -> > + =A0 =A0 =A0 const u32 *prop; -> > + =A0 =A0 =A0 int bus_num =3D -1; -> > + =A0 =A0 =A0 int len; +> > + struct device_node *np; +> > + struct of_device *of_dev; +> > + struct spi_board_info info; +> > + const u32 *prop; +> > + int bus_num = -1; +> > + int len; > > + -> > + =A0 =A0 =A0 np =3D of_find_compatible_node(NULL, NULL, "ti,ads7845"); -> > + =A0 =A0 =A0 if (!np) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; +> > + np = of_find_compatible_node(NULL, NULL, "ti,ads7845"); +> > + if (!np) +> > + return -ENODEV; > > + -> > + =A0 =A0 =A0 memset(&info, 0, sizeof(info)); -> > + =A0 =A0 =A0 info.irq =3D irq_of_parse_and_map(np, 0); -> > + =A0 =A0 =A0 if (info.irq =3D=3D NO_IRQ) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; +> > + memset(&info, 0, sizeof(info)); +> > + info.irq = irq_of_parse_and_map(np, 0); +> > + if (info.irq == NO_IRQ) +> > + return -ENODEV; > > + -> > + =A0 =A0 =A0 info.platform_data =3D &pdm360ng_ads7846_pdata; -> > + =A0 =A0 =A0 if (strlcpy(info.modalias, "ads7846", -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SPI_NAME_SIZE) >=3D SPI_NAME_SIZE) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM; +> > + info.platform_data = &pdm360ng_ads7846_pdata; +> > + if (strlcpy(info.modalias, "ads7846", +> > + SPI_NAME_SIZE) >= SPI_NAME_SIZE) +> > + return -ENOMEM; > > + -> > + =A0 =A0 =A0 np =3D of_get_next_parent(np); -> > + =A0 =A0 =A0 if (!np) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; +> > + np = of_get_next_parent(np); +> > + if (!np) +> > + return -ENODEV; > > + -> > + =A0 =A0 =A0 prop =3D of_get_property(np, "cell-index", &len); -> > + =A0 =A0 =A0 if (prop && len =3D=3D 4) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 bus_num =3D *prop; ->=20 +> > + prop = of_get_property(np, "cell-index", &len); +> > + if (prop && len == 4) +> > + bus_num = *prop; +> > Blech. Don't use cell-index for bus enumeration. In fact, none of > this should be necessary at all (see below). I dropped this code entirely in the next patch version. > > + -> > + =A0 =A0 =A0 if (bus_num < 0 || bus_num > 11) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; +> > + if (bus_num < 0 || bus_num > 11) +> > + return -ENODEV; > > + -> > + =A0 =A0 =A0 info.bus_num =3D bus_num; +> > + info.bus_num = bus_num; > > + -> > + =A0 =A0 =A0 of_dev =3D of_find_device_by_node(np); -> > + =A0 =A0 =A0 of_node_put(np); -> > + =A0 =A0 =A0 if (of_dev) { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct fsl_spi_platform_data *pdata; +> > + of_dev = of_find_device_by_node(np); +> > + of_node_put(np); +> > + if (of_dev) { +> > + struct fsl_spi_platform_data *pdata; > > + -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata =3D kzalloc(sizeof(*pdata), GFP_KER= -NEL); -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pdata) { -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->bus_num =3D bus_nu= -m; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->max_chipselect =3D= - 1; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_dev->dev.platform_data= - =3D pdata; -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } -> > + =A0 =A0 =A0 } +> > + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); +> > + if (pdata) { +> > + pdata->bus_num = bus_num; +> > + pdata->max_chipselect = 1; +> > + of_dev->dev.platform_data = pdata; +> > + } +> > + } > > + -> > + =A0 =A0 =A0 if (pdm360ng_penirq_init()) -> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; +> > + if (pdm360ng_penirq_init()) +> > + return -ENODEV; > > + -> > + =A0 =A0 =A0 return spi_register_board_info(&info, 1); ->=20 +> > + return spi_register_board_info(&info, 1); +> > This ends up being a lot of code simply to attach a pdata structure to > an spi device. I've been thinking about this problem, and I think > there is a better way. Instead, use a bus notifier attached to the @@ -176,20 +164,20 @@ m; > gets bound to a driver. Then you can attach the pdata structure very > simply. Something like this I think (completely untested, or even > compiled. Details are left as an exercise to the developer): ->=20 +> > static int pdm360ng_touchscreen_notifier_call(struct notifier_block *nb, > unsigned long event, void *__dev) > { -> struct device *dev =3D __dev; ->=20 -> if ((event =3D=3D BUS_NOTIFIY_ADD_DEVICE) && (dev->of_node =3D=3D [FOO])) -> dev->platform_data =3D [BAR]; +> struct device *dev = __dev; +> +> if ((event == BUS_NOTIFIY_ADD_DEVICE) && (dev->of_node == [FOO])) +> dev->platform_data = [BAR]; > } ->=20 -> static struct notifier_block pdm360ng_touchscreen_nb =3D { -> notifier_call =3D pdm360ng_touchscreen_notifier_call; +> +> static struct notifier_block pdm360ng_touchscreen_nb = { +> notifier_call = pdm360ng_touchscreen_notifier_call; > }; ->=20 +> > static int __init pdm360ng_touchscreen_init(void) > { > bus_register_notifier(&spi_bus_type, pdm360ng_touchscreen_nb); @@ -205,7 +193,7 @@ core spi code in v2.6.36? ... > > +} > > +machine_device_initcall(pdm360ng, pdm360ng_touchscreen_init); ->=20 +> > This code is *in the same file* as the board setup file. Don't use an > initcall. Call it from the init callback instead. diff --git a/a/content_digest b/N1/content_digest index 3562113..51bacf6 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,65 +1,62 @@ "ref\01272882222-12253-1-git-send-email-agust@denx.de\0" "ref\01279892973-24110-1-git-send-email-agust@denx.de\0" "ref\0AANLkTi=Ee6HR+Ux0g4V1+81DXUmsO=UDhi6jWsDgGchv@mail.gmail.com\0" - "From\0Anatolij Gustschin <agust@denx.de>\0" + "ref\0AANLkTi=Ee6HR+Ux0g4V1+81DXUmsO=UDhi6jWsDgGchv-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org\0" + "From\0Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>\0" "Subject\0Re: [PATCH v3 2/2] powerpc/mpc5121: add initial support for PDM360NG board\0" "Date\0Tue, 27 Jul 2010 12:36:47 +0200\0" - "To\0Grant Likely <grant.likely@secretlab.ca>\0" - "Cc\0Detlev Zundel <dzu@denx.de>" - Markus Fischer <markus.fischer.ec@ifm.com> - devicetree-discuss@lists.ozlabs.org - Michael Weiss <michael.weiss@ifm.com> - linuxppc-dev@ozlabs.org - " Wolfgang Grandegger <wg@denx.de>\0" + "To\0Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>\0" + "Cc\0Detlev Zundel <dzu-ynQEQJNshbs@public.gmane.org>" + Markus Fischer <markus.fischer.ec-Jj5Fu8i2Z9Q@public.gmane.org> + devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org + Michael Weiss <michael.weiss-Jj5Fu8i2Z9Q@public.gmane.org> + linuxppc-dev-mnsaURCQ41sdnm+yROfE0A@public.gmane.org + " Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>\0" "\00:1\0" "b\0" "Hi Grant,\n" "\n" "On Sun, 25 Jul 2010 01:42:23 -0600\n" - "Grant Likely <grant.likely@secretlab.ca> wrote:\n" + "Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:\n" "...\n" "> Hi Anatolij,\n" - ">=20\n" - "> Finally got some time tonight to properly dig into this patch. Comments =\n" - "below.\n" + "> \n" + "> Finally got some time tonight to properly dig into this patch. Comments below.\n" "\n" "Thanks for review and comments! My reply below.\n" "\n" "...\n" - "> > + =A0 =A0 =A0 nfc@40000000 {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D \"fsl,mpc5121-nfc\";\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x40000000 0x100000>;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupts =3D <0x6 0x8>;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 interrupt-parent =3D <&ipic>;\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 nfc@40000000 {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 compatible = \"fsl,mpc5121-nfc\";\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 reg = <0x40000000 0x100000>;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 interrupts = <0x6 0x8>;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 interrupt-parent = <&ipic>;\n" + "> \n" "> This device tree can be less verbose if you remove the\n" "> interrupt-parent property from all the nodes, and have a single\n" - "> interrupt-parent =3D <&ipic>; in the root node. Nodes inherit the\n" + "> interrupt-parent = <&ipic>; in the root node. Nodes inherit the\n" "> interrupt-parent from their (grand-)parents.\n" "\n" "Fixed in next patch version to use interrupt-parent in root node only.\n" "\n" "...\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mdio@2800 {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D \"fsl,mpc51=\n" - "21-fec-mdio\";\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <0x2800 0x200>;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 #address-cells =3D <1>;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 #size-cells =3D <0>;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 phy: ethernet-phy@0 {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reg =3D <=\n" - "0x1f>;\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 mdio@2800 {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 compatible = \"fsl,mpc5121-fec-mdio\";\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 reg = <0x2800 0x200>;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 #address-cells = <1>;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 #size-cells = <0>;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 phy: ethernet-phy@0 {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 reg = <0x1f>;\n" + "> \n" "> For completeness, phy should have a compatible property.\n" "\n" "Added in next patch version.\n" "\n" "...\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 spi@11900 {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compatible =3D \"fsl,mpc51=\n" - "21-psc-spi\", \"fsl,mpc5121-psc\";\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cell-index =3D <9>;\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 spi@11900 {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 compatible = \"fsl,mpc5121-psc-spi\", \"fsl,mpc5121-psc\";\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 cell-index = <9>;\n" + "> \n" "> Try to drop the cell-index properties. They are almost always misused.\n" "\n" "Removing cell-index would require changing the spi driver's probe.\n" @@ -72,49 +69,45 @@ "...\n" "> > +static int pdm360ng_get_pendown_state(void)\n" "> > +{\n" - "> > + =A0 =A0 =A0 u32 reg;\n" + "> > + \302\240 \302\240 \302\240 u32 reg;\n" "> > +\n" - "> > + =A0 =A0 =A0 reg =3D in_be32((u32 *)(pdm360ng_gpio_base + 0xc));\n" - "> > + =A0 =A0 =A0 if (reg & 0x40)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 setbits32((u32 *)(pdm360ng_gpio_base + 0x=\n" - "c), 0x40);\n" + "> > + \302\240 \302\240 \302\240 reg = in_be32((u32 *)(pdm360ng_gpio_base + 0xc));\n" + "> > + \302\240 \302\240 \302\240 if (reg & 0x40)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 setbits32((u32 *)(pdm360ng_gpio_base + 0xc), 0x40);\n" "> > +\n" - "> > + =A0 =A0 =A0 reg =3D in_be32((u32 *)(pdm360ng_gpio_base + 0x8));\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 reg = in_be32((u32 *)(pdm360ng_gpio_base + 0x8));\n" + "> \n" "> (u32*) casts are unnecessary and can be removed.\n" "\n" "Fixed.\n" "\n" "> > +\n" - "> > + =A0 =A0 =A0 /* return 1 if pen is down */\n" - "> > + =A0 =A0 =A0 return reg & 0x40 ? 0 : 1;\n" - ">=20\n" - "> return reg & 0x40 =3D=3D 0;\n" + "> > + \302\240 \302\240 \302\240 /* return 1 if pen is down */\n" + "> > + \302\240 \302\240 \302\240 return reg & 0x40 ? 0 : 1;\n" + "> \n" + "> return reg & 0x40 == 0;\n" "\n" "Fixed.\n" "\n" "...\n" "> > +static int __init pdm360ng_penirq_init(void)\n" "> > +{\n" - "> > + =A0 =A0 =A0 struct device_node *np;\n" - "> > + =A0 =A0 =A0 struct resource r;\n" + "> > + \302\240 \302\240 \302\240 struct device_node *np;\n" + "> > + \302\240 \302\240 \302\240 struct resource r;\n" "> > +\n" - "> > + =A0 =A0 =A0 np =3D of_find_compatible_node(NULL, NULL, \"fsl,mpc5121-g=\n" - "pio\");\n" - "> > + =A0 =A0 =A0 if (!np) {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pr_err(\"%s: Can't find 'mpc5121-gpio' nod=\n" - "e\\n\", __func__);\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -1;\n" - "> > + =A0 =A0 =A0 }\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 np = of_find_compatible_node(NULL, NULL, \"fsl,mpc5121-gpio\");\n" + "> > + \302\240 \302\240 \302\240 if (!np) {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 pr_err(\"%s: Can't find 'mpc5121-gpio' node\\n\", __func__);\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -1;\n" + "> > + \302\240 \302\240 \302\240 }\n" + "> \n" "> return -ENODEV;\n" "\n" "Ok, fixed also.\n" "\n" "...\n" - "> > + =A0 =A0 =A0 pdm360ng_gpio_base =3D ioremap(r.start, resource_size(&r)=\n" - ");\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 pdm360ng_gpio_base = ioremap(r.start, resource_size(&r));\n" + "> \n" "> Or you could have simply used of_iomap() to eliminate some code.\n" "\n" "of_iomap() is used in next patch version.\n" @@ -122,68 +115,64 @@ "...\n" "> > +static int __init pdm360ng_touchscreen_init(void)\n" "> > +{\n" - "> > + =A0 =A0 =A0 struct device_node *np;\n" - "> > + =A0 =A0 =A0 struct of_device *of_dev;\n" - "> > + =A0 =A0 =A0 struct spi_board_info info;\n" - "> > + =A0 =A0 =A0 const u32 *prop;\n" - "> > + =A0 =A0 =A0 int bus_num =3D -1;\n" - "> > + =A0 =A0 =A0 int len;\n" + "> > + \302\240 \302\240 \302\240 struct device_node *np;\n" + "> > + \302\240 \302\240 \302\240 struct of_device *of_dev;\n" + "> > + \302\240 \302\240 \302\240 struct spi_board_info info;\n" + "> > + \302\240 \302\240 \302\240 const u32 *prop;\n" + "> > + \302\240 \302\240 \302\240 int bus_num = -1;\n" + "> > + \302\240 \302\240 \302\240 int len;\n" "> > +\n" - "> > + =A0 =A0 =A0 np =3D of_find_compatible_node(NULL, NULL, \"ti,ads7845\");\n" - "> > + =A0 =A0 =A0 if (!np)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;\n" + "> > + \302\240 \302\240 \302\240 np = of_find_compatible_node(NULL, NULL, \"ti,ads7845\");\n" + "> > + \302\240 \302\240 \302\240 if (!np)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -ENODEV;\n" "> > +\n" - "> > + =A0 =A0 =A0 memset(&info, 0, sizeof(info));\n" - "> > + =A0 =A0 =A0 info.irq =3D irq_of_parse_and_map(np, 0);\n" - "> > + =A0 =A0 =A0 if (info.irq =3D=3D NO_IRQ)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;\n" + "> > + \302\240 \302\240 \302\240 memset(&info, 0, sizeof(info));\n" + "> > + \302\240 \302\240 \302\240 info.irq = irq_of_parse_and_map(np, 0);\n" + "> > + \302\240 \302\240 \302\240 if (info.irq == NO_IRQ)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -ENODEV;\n" "> > +\n" - "> > + =A0 =A0 =A0 info.platform_data =3D &pdm360ng_ads7846_pdata;\n" - "> > + =A0 =A0 =A0 if (strlcpy(info.modalias, \"ads7846\",\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 SPI_NAME_SIZE) >=3D SPI_NAME_SIZE)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENOMEM;\n" + "> > + \302\240 \302\240 \302\240 info.platform_data = &pdm360ng_ads7846_pdata;\n" + "> > + \302\240 \302\240 \302\240 if (strlcpy(info.modalias, \"ads7846\",\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 SPI_NAME_SIZE) >= SPI_NAME_SIZE)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -ENOMEM;\n" "> > +\n" - "> > + =A0 =A0 =A0 np =3D of_get_next_parent(np);\n" - "> > + =A0 =A0 =A0 if (!np)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;\n" + "> > + \302\240 \302\240 \302\240 np = of_get_next_parent(np);\n" + "> > + \302\240 \302\240 \302\240 if (!np)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -ENODEV;\n" "> > +\n" - "> > + =A0 =A0 =A0 prop =3D of_get_property(np, \"cell-index\", &len);\n" - "> > + =A0 =A0 =A0 if (prop && len =3D=3D 4)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 bus_num =3D *prop;\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 prop = of_get_property(np, \"cell-index\", &len);\n" + "> > + \302\240 \302\240 \302\240 if (prop && len == 4)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 bus_num = *prop;\n" + "> \n" "> Blech. Don't use cell-index for bus enumeration. In fact, none of\n" "> this should be necessary at all (see below).\n" "\n" "I dropped this code entirely in the next patch version.\n" "\n" "> > +\n" - "> > + =A0 =A0 =A0 if (bus_num < 0 || bus_num > 11)\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;\n" + "> > + \302\240 \302\240 \302\240 if (bus_num < 0 || bus_num > 11)\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -ENODEV;\n" "> > +\n" - "> > + =A0 =A0 =A0 info.bus_num =3D bus_num;\n" + "> > + \302\240 \302\240 \302\240 info.bus_num = bus_num;\n" "> > +\n" - "> > + =A0 =A0 =A0 of_dev =3D of_find_device_by_node(np);\n" - "> > + =A0 =A0 =A0 of_node_put(np);\n" - "> > + =A0 =A0 =A0 if (of_dev) {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct fsl_spi_platform_data *pdata;\n" + "> > + \302\240 \302\240 \302\240 of_dev = of_find_device_by_node(np);\n" + "> > + \302\240 \302\240 \302\240 of_node_put(np);\n" + "> > + \302\240 \302\240 \302\240 if (of_dev) {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 struct fsl_spi_platform_data *pdata;\n" "> > +\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata =3D kzalloc(sizeof(*pdata), GFP_KER=\n" - "NEL);\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pdata) {\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->bus_num =3D bus_nu=\n" - "m;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->max_chipselect =3D=\n" - " 1;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_dev->dev.platform_data=\n" - " =3D pdata;\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }\n" - "> > + =A0 =A0 =A0 }\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 if (pdata) {\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 pdata->bus_num = bus_num;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 pdata->max_chipselect = 1;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 of_dev->dev.platform_data = pdata;\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 }\n" + "> > + \302\240 \302\240 \302\240 }\n" "> > +\n" - "> > + =A0 =A0 =A0 if (pdm360ng_penirq_init())\n" - "> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;\n" + "> > + \302\240 \302\240 \302\240 if (pdm360ng_penirq_init())\n" + "> > + \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 \302\240 return -ENODEV;\n" "> > +\n" - "> > + =A0 =A0 =A0 return spi_register_board_info(&info, 1);\n" - ">=20\n" + "> > + \302\240 \302\240 \302\240 return spi_register_board_info(&info, 1);\n" + "> \n" "> This ends up being a lot of code simply to attach a pdata structure to\n" "> an spi device. I've been thinking about this problem, and I think\n" "> there is a better way. Instead, use a bus notifier attached to the\n" @@ -191,20 +180,20 @@ "> gets bound to a driver. Then you can attach the pdata structure very\n" "> simply. Something like this I think (completely untested, or even\n" "> compiled. Details are left as an exercise to the developer):\n" - ">=20\n" + "> \n" "> static int pdm360ng_touchscreen_notifier_call(struct notifier_block *nb,\n" "> \t\t\t\t\tunsigned long event, void *__dev)\n" "> {\n" - "> \tstruct device *dev =3D __dev;\n" - ">=20\n" - "> \tif ((event =3D=3D BUS_NOTIFIY_ADD_DEVICE) && (dev->of_node =3D=3D [FOO]))\n" - "> \t\tdev->platform_data =3D [BAR];\n" + "> \tstruct device *dev = __dev;\n" + "> \n" + "> \tif ((event == BUS_NOTIFIY_ADD_DEVICE) && (dev->of_node == [FOO]))\n" + "> \t\tdev->platform_data = [BAR];\n" "> }\n" - ">=20\n" - "> static struct notifier_block pdm360ng_touchscreen_nb =3D {\n" - "> \tnotifier_call =3D pdm360ng_touchscreen_notifier_call;\n" + "> \n" + "> static struct notifier_block pdm360ng_touchscreen_nb = {\n" + "> \tnotifier_call = pdm360ng_touchscreen_notifier_call;\n" "> };\n" - ">=20\n" + "> \n" "> static int __init pdm360ng_touchscreen_init(void)\n" "> {\n" "> \tbus_register_notifier(&spi_bus_type, pdm360ng_touchscreen_nb);\n" @@ -220,7 +209,7 @@ "...\n" "> > +}\n" "> > +machine_device_initcall(pdm360ng, pdm360ng_touchscreen_init);\n" - ">=20\n" + "> \n" "> This code is *in the same file* as the board setup file. Don't use an\n" "> initcall. Call it from the init callback instead.\n" "\n" @@ -229,4 +218,4 @@ "Thanks,\n" Anatolij -b6b704831df8caf16320a84cd4ba115c674fe177f0846a7631a518c6bf7fa7c4 +8c7af70901294d9219646ee6586c81971082a13c1bf512ab99b00a5584d5cdeb
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.